From 3c42f5e3a11ae4d06150867f460283c23a0319fe Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 26 May 2021 10:04:56 +0200 Subject: [PATCH 1/6] updated ffi to 1.15.1 --- CHANGELOG.md | 2 ++ Gemfile.lock | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fba92ad03..82c7d3aa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +- Updated ffi to 1.15.1 + ## v4.7.10 2021 May 25 - CAD lists of types and extensions are now ordered alphabetically diff --git a/Gemfile.lock b/Gemfile.lock index 7df5befc7..b4562b85d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) From be3352d2bf75f0df7fbff8acbb736671a16ec09c Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 26 May 2021 11:46:37 +0200 Subject: [PATCH 2/6] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 36 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.md | 10 +++++++ .github/ISSUE_TEMPLATE/support.md | 10 +++++++ 3 files changed, 56 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/support.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..e138fc22c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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. diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 000000000..30fed6323 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -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. diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md new file mode 100644 index 000000000..177d54761 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support.md @@ -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. From 462680c51d7f43dcd7b2e7161eadc4c832e3fd99 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 26 May 2021 11:47:42 +0200 Subject: [PATCH 3/6] Delete ISSUE_TEMPLATE.md This is not used anymore --- .github/ISSUE_TEMPLATE.md | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 6f9669cf3..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -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 From 4e601b672a672272ee9b4c95b5f9538397854cc0 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 26 May 2021 11:49:52 +0200 Subject: [PATCH 4/6] [bug] fablab:fix_invoices date parsing error --- CHANGELOG.md | 2 ++ lib/tasks/fablab/fix_invoices.rake | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82c7d3aa1..2a66091ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog Fab-manager - Updated ffi to 1.15.1 +- Updated GitHub issue templates +- Fix a bug: fablab:fix_invoices task fails to recreate the data if the date is in english ## v4.7.10 2021 May 25 diff --git a/lib/tasks/fablab/fix_invoices.rake b/lib/tasks/fablab/fix_invoices.rake index 20e2119ab..74747a2da 100644 --- a/lib/tasks/fablab/fix_invoices.rake +++ b/lib/tasks/fablab/fix_invoices.rake @@ -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)] From 413bb57c38a1023d4a3ae996e2d1a3e18259c3aa Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 26 May 2021 13:38:16 +0200 Subject: [PATCH 5/6] [bug] zero-decimal currencies w/ stripe --- CHANGELOG.md | 1 + app/controllers/api/payments_controller.rb | 2 +- app/services/stripe_service.rb | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a66091ac..2aad0136d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - 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 diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 350377e91..2d5df145e 100644 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -26,7 +26,7 @@ class API::PaymentsController < API::ApiController intent = Stripe::PaymentIntent.create( { payment_method: params[:payment_method_id], - amount: amount[:amount], + amount: StripeService.stripe_amount(amount[:amount]), currency: Setting.get('stripe_currency'), confirmation_method: 'manual', confirm: true, diff --git a/app/services/stripe_service.rb b/app/services/stripe_service.rb index fdf10443d..7c4713d46 100644 --- a/app/services/stripe_service.rb +++ b/app/services/stripe_service.rb @@ -50,7 +50,7 @@ class StripeService if coupon.type == 'percent_off' stp_coupon[:percent_off] = coupon.percent_off elsif coupon.type == 'amount_off' - stp_coupon[:amount_off] = coupon.amount_off + stp_coupon[:amount_off] = stripe_amount(coupon.amount_off) stp_coupon[:currency] = Setting.get('stripe_currency') end @@ -61,6 +61,13 @@ class StripeService Stripe::Coupon.create(stp_coupon, api_key: Setting.get('stripe_secret_key')) 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) @@ -91,7 +98,7 @@ class StripeService 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 @@ -107,5 +114,10 @@ class StripeService customer_id = payment_schedule.invoicing_profile.user.stp_customer_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 end From d81e25b88ea0f93ecb68226e38be8abc1752b911 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 26 May 2021 13:42:17 +0200 Subject: [PATCH 6/6] Version 4.7.11 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aad0136d..6d522fb75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +## 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 diff --git a/package.json b/package.json index 9fdbfaead..758186a6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "4.7.10", + "version": "4.7.11", "description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.", "keywords": [ "fablab",