1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

Merge branch 'dev' into payzen

This commit is contained in:
Sylvain 2021-05-26 14:00:51 +02:00
commit c79078c8e1
9 changed files with 83 additions and 21 deletions

View File

@ -1,14 +0,0 @@
This issue tracker is **reserved** for bug reports.
The place to ask a question or call for help is at [Fab-manager forums](https://forum.fab-manager.com)
The place to request or vote for new feature is on the [feedback website](https://feedback.fab-manager.com)
To report a bug, please describe:
- Expected behavior and actual behavior.
- Steps to reproduce the problem.
- Specifications like the version of the project, operating system, or hardware.
The following elements may help to quickly resolve your issue:
- Server logs `tail -f /apps/fabmanager/log/app-stdout.log` on the server
- Client logs `Ctrl`+`Maj`+`i` > `Console` in the browser

36
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,36 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Server (please complete the following information):**
- OS: [report here the result of `lsb_release -a`]
- Kernel: [report here the result of `uname -a`]
- Fab-manager version [report here the result of `\curl -sSL run.fab.mn | bash -s "fablab:maintenance:version"`]
**Browser (please complete the following information):**
- Name: [e.g. Firefox]
- Version: [e.g. 88.0.1, please refer to the About menu of your browser]
**Additional context**
Add any other context about the problem here.

View File

@ -0,0 +1,10 @@
---
name: Feature request
about: Suggest an idea for Fab-manager
title: ''
labels: ''
assignees: ''
---
Please visit [feedback.fab-manager.com](https://feedback.fab-manager.com/) and vote for existing feature requests or propose a new one.

10
.github/ISSUE_TEMPLATE/support.md vendored Normal file
View File

@ -0,0 +1,10 @@
---
name: Support
about: Call for help while using Fab-manager
title: ''
labels: ''
assignees: ''
---
Please visit [the forum](https://forum.fab-manager.com/) to get assistance from the community. If you subscribed to paid assistance, please contact us by email for a faster reply.

View File

@ -11,7 +11,6 @@
- Fix a bug: unable to set date formats during installation
- Fix a bug: unable to cancel the upgrade before it begins
- Fix a bug: in the admin calendar, the trainings' info panel shows "duration: null minutes"
- Fix a bug: new installation with mapping to an external network does not connect fab-manager to elasticsearch
- `SUPERADMIN_EMAIL` renamed to `ADMINSYS_EMAIL`
- `scripts/run-tests.sh` renamed to `scripts/tests.sh`
- [BREAKING CHANGE] GET `open_api/v1/invoices` won't return `stp_invoice_id` OR `stp_payment_intent_id` anymore. The new field `payment_gateway_object` will contain some similar data if the invoice was paid online by card.
@ -19,6 +18,13 @@
- [TODO DEPLOY] `rails fablab:maintenance:rebuild_stylesheet`
- [TODO DEPLOY] `\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/rename-adminsys.sh | bash`
## v4.7.11 2021 May 26
- Updated ffi to 1.15.1
- Updated GitHub issue templates
- Fix a bug: zero-decimal currencies were charged multiplied by 100
- Fix a bug: fablab:fix_invoices task fails to recreate the data if the date is in english
## v4.7.10 2021 May 25
- CAD lists of types and extensions are now ordered alphabetically

View File

@ -140,7 +140,7 @@ GEM
i18n (>= 1.6, < 2)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
ffi (1.14.2)
ffi (1.15.1)
foreman (0.87.0)
forgery (0.7.0)
friendly_id (5.1.0)

View File

@ -3,6 +3,7 @@
# API Controller for handling the payments process in the front-end, using the Stripe gateway
class API::StripeController < API::PaymentsController
require 'stripe/helper'
require 'stripe/service'
##
# Client requests to confirm a card payment will ask this endpoint.
@ -26,7 +27,7 @@ class API::StripeController < API::PaymentsController
intent = Stripe::PaymentIntent.create(
{
payment_method: params[:payment_method_id],
amount: amount[:amount],
amount: Stripe::Service.stripe_amount(amount[:amount]),
currency: Setting.get('stripe_currency'),
confirmation_method: 'manual',
confirm: true,

View File

@ -54,7 +54,7 @@ class Stripe::Service < Payment::Service
stp_coupon = { id: coupon.code }
if coupon.type == 'percent_off'
stp_coupon[:percent_off] = coupon.percent_off
elsif coupon.type == 'amount_off'
elsif coupon.type == stripe_amount('amount_off')
stp_coupon[:amount_off] = coupon.amount_off
stp_coupon[:currency] = Setting.get('stripe_currency')
end
@ -77,6 +77,13 @@ class Stripe::Service < Payment::Service
raise PaymentGatewayError(e)
end
def stripe_amount(amount)
currency = Setting.get('stripe_currency')
return amount / 100 if zero_decimal_currencies.any? { |s| s.casecmp(currency).zero? }
amount
end
private
def subscription_invoice_items(payment_schedule, subscription, first_item, reservable_stp_id)
@ -107,7 +114,7 @@ class Stripe::Service < Payment::Service
def create_price(amount, stp_product_id, name, monthly: false)
params = {
unit_amount: amount,
unit_amount: stripe_amount(amount),
currency: Setting.get('stripe_currency'),
product: stp_product_id,
nickname: name
@ -123,4 +130,9 @@ class Stripe::Service < Payment::Service
customer_id = payment_schedule.invoicing_profile.user.payment_gateway_object.gateway_object_id
Stripe::Customer.update(customer_id, { balance: -payment_schedule.wallet_amount }, { api_key: Setting.get('stripe_secret_key') })
end
# @see https://stripe.com/docs/currencies#zero-decimal
def zero_decimal_currencies
%w[BIF CLP DJF GNF JPY KMF KRW MGA PYG RWF UGX VND VUV XAF XOF XPF]
end
end

View File

@ -98,8 +98,9 @@ namespace :fablab do
description = ii.description
# DateTime.parse only works with english dates, so translate the month name
month_idx = I18n.t('date.month_names').find_index { |month| month && description.include?(month) }
description.gsub!(/#{I18n.t('date.month_names')[month_idx]}/, I18n.t('date.month_names', locale: :en)[month_idx])
unless month_idx.nil?
description.gsub!(/#{I18n.t('date.month_names')[month_idx]}/, I18n.t('date.month_names', locale: :en)[month_idx])
end
start = DateTime.parse(description)
end_time = DateTime.parse(/- (.+)$/.match(description)[1])
[start, DateTime.new(start.year, start.month, start.day, end_time.hour, end_time.min, end_time.sec, DateTime.current.zone)]