From bd6e4fe0abc97dd4ad13dac9519c5f15a9cb1008 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Thu, 6 Jul 2023 10:15:05 +0200 Subject: [PATCH 01/10] (bug) unable to update Store Order sub type in statistics --- CHANGELOG.md | 2 ++ app/services/orders/order_service.rb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bc93531c..1f44734fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog Fab-manager - Fix a bug: unable to show project step image in markdown file +- Fix a bug: unable to update Store Order sub type in statistics +- [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2014,1]` ## v6.0.8 2023 July 03 diff --git a/app/services/orders/order_service.rb b/app/services/orders/order_service.rb index 24d6a4338..1d25857c9 100644 --- a/app/services/orders/order_service.rb +++ b/app/services/orders/order_service.rb @@ -45,7 +45,13 @@ class Orders::OrderService # update in elasticsearch (statistics) stat_order = Stats::Order.search(query: { term: { orderId: order.id } }) - stat_order.map { |s| s.update(state: state) } + sub_type = if state.in?(%w[paid in_progress ready delivered]) + 'paid-processed' + elsif state.in?(%w[payment_failed refunded canceled]) + 'aborted' + end + + stat_order.map { |s| s.update(subType: sub_type, state: state) } if sub_type.present? order end From 751920893a28b5c49c8449a479bdb2217abbc7c4 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 6 Jul 2023 14:28:46 +0200 Subject: [PATCH 02/10] translations for project filters --- config/locales/app.admin.fr.yml | 12 ++++++------ config/locales/app.public.fr.yml | 4 ++-- config/locales/fr.yml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 0f2daaeac..ea0eba305 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -447,8 +447,8 @@ fr: open_lab_app_secret: "Secret" openlab_default_info_html: "Dans la galerie de projets, les visiteurs peuvent choisir entre deux vues : tous les projets de l'ensemble du réseau OpenLab, ou uniquement les projets documentés dans votre Fab Lab.
Ici, vous pouvez choisir quelle vue est affichée par défaut." default_to_openlab: "Afficher OpenLab par défaut" - filters: Filtres de la liste des projets - project_categories: Catégories + filters: Affichage des filtres + project_categories: Personnalisation du filtre Catégories project_categories: name: "Nom" projects_setting: @@ -1779,10 +1779,10 @@ fr: extended_prices_in_same_day: "Prix étendus le même jour" public_registrations: "Inscriptions publiques" show_username_in_admin_list: "Afficher le nom d'utilisateur dans la liste" - projects_list_member_filter_presence: "Présence de filtre des membres dans la liste des projets" - projects_list_date_filters_presence: "Filtres de date présents dans la liste des projets" - project_categories_filter_placeholder: "Placeholder pour le filtre des catégories dans la galerie de projet" - project_categories_wording: "Mots utilisés pour remplacer les \"catégories\" sur les pages publiques" + projects_list_member_filter_presence: "Permettre la recherche de projets par membre" + projects_list_date_filters_presence: "Permettre la recherche de projets par dates" + project_categories_filter_placeholder: "Dans la galerie de projets, renommer le filtre \"Toutes les catégories\"" + project_categories_wording: "Dans la fiche projet, renommer l'intitulé de l'encart Catégories" overlapping_options: training_reservations: "Formations" machine_reservations: "Machines" diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml index dbab0f257..a88411e71 100644 --- a/config/locales/app.public.fr.yml +++ b/config/locales/app.public.fr.yml @@ -185,8 +185,8 @@ fr: load_next_projects: "Charger les projets suivants" rough_draft: "Brouillon" filter_by_member: "Filtrer par membre" - created_from: Créé depuis - created_to: Créés le + created_from: Créés depuis le + created_to: Créés jusqu'au download_archive: Télécharger status_filter: all_statuses: "Tous les statuts" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 054f07896..5fcc25b29 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -697,10 +697,10 @@ fr: trainings_authorization_validity_duration: "Durée de la période de validité des formations" trainings_invalidation_rule: "Invalidation automatique des formations" trainings_invalidation_rule_period: "Période de grâce avant d'invalider une formation" - projects_list_member_filter_presence: "Présence de filtre des membres dans la liste des projets" + projects_list_member_filter_presence: "Permettre la recherche de projets par membre" projects_list_date_filters_presence: "Filtre de présence de dates sur la liste des projets" - project_categories_filter_placeholder: "Placeholder pour le filtre des catégories dans la galerie de projet" - project_categories_wording: "Mots utilisés pour remplacer les \"catégories\" sur les pages publiques" + project_categories_filter_placeholder: "Dans la galerie de projets, renommer le filtre \"Toutes les catégories\"" + project_categories_wording: "Dans la fiche projet, renommer l'intitulé de l'encart Catégories" #statuses of projects statuses: new: "Nouveau" From d7d996bc6dfca00cefb07145f1438f1071fb9b27 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Thu, 6 Jul 2023 15:31:24 +0200 Subject: [PATCH 03/10] (feat) Ability to show all availabilities in calender for admin --- CHANGELOG.md | 1 + app/services/availabilities/visibility_service.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f44734fb..d45cb3e51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Fix a bug: unable to show project step image in markdown file - Fix a bug: unable to update Store Order sub type in statistics +- Ability to show all availabilities in calender for admin - [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2014,1]` ## v6.0.8 2023 July 03 diff --git a/app/services/availabilities/visibility_service.rb b/app/services/availabilities/visibility_service.rb index 21da2b8c1..0651c8bb1 100644 --- a/app/services/availabilities/visibility_service.rb +++ b/app/services/availabilities/visibility_service.rb @@ -22,7 +22,7 @@ class Availabilities::VisibilityService # @return [Array] as: [start,end] def visibility(user, available_type, range_start, range_end) if user&.privileged? - window_start = [range_start, 1.month.ago].max + window_start = range_start window_end = range_end else end_at = @maximum_visibility[:other] From 9bc146d0377bb8ecd0196f99b05810405db4cbee Mon Sep 17 00:00:00 2001 From: Du Peng Date: Fri, 7 Jul 2023 09:14:47 +0200 Subject: [PATCH 04/10] (bug) unable to create plan with plan limitation --- CHANGELOG.md | 1 + Gemfile.lock | 1 + app/models/plan_limitation.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d45cb3e51..0050cd1e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Fix a bug: unable to show project step image in markdown file - Fix a bug: unable to update Store Order sub type in statistics +- Fix a bug: unable to create plan with plan limitation - Ability to show all availabilities in calender for admin - [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2014,1]` diff --git a/Gemfile.lock b/Gemfile.lock index cd14fbf34..6c6c012ae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -528,6 +528,7 @@ GEM zeitwerk (2.6.7) PLATFORMS + x86_64-darwin-20 x86_64-darwin-21 x86_64-linux diff --git a/app/models/plan_limitation.rb b/app/models/plan_limitation.rb index ae30ee215..e672c6383 100644 --- a/app/models/plan_limitation.rb +++ b/app/models/plan_limitation.rb @@ -8,7 +8,7 @@ class PlanLimitation < ApplicationRecord belongs_to :machine, foreign_key: 'limitable_id', inverse_of: :plan_limitations belongs_to :machine_category, foreign_key: 'limitable_id', inverse_of: :plan_limitations - validates :limitable_id, :limitable_type, :limit, :plan_id, presence: true + validates :limitable_id, :limitable_type, :limit, presence: true validates :limitable_id, uniqueness: { scope: %i[limitable_type plan_id] } # @return [Array] From b0a204dd1dd1ca835ab038ba7674cfef64ffcad6 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Fri, 7 Jul 2023 16:17:34 +0200 Subject: [PATCH 05/10] (feat) Improved performance when marking all notifications as read --- CHANGELOG.md | 1 + app/controllers/api/notifications_controller.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0050cd1e8..05409c48a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix a bug: unable to update Store Order sub type in statistics - Fix a bug: unable to create plan with plan limitation - Ability to show all availabilities in calender for admin +- Improved performance when marking all notifications as read - [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2014,1]` ## v6.0.8 2023 July 03 diff --git a/app/controllers/api/notifications_controller.rb b/app/controllers/api/notifications_controller.rb index 82fc87583..919d1aa5a 100644 --- a/app/controllers/api/notifications_controller.rb +++ b/app/controllers/api/notifications_controller.rb @@ -65,7 +65,8 @@ class API::NotificationsController < API::APIController end def update_all - current_user.notifications.where(is_read: false).find_each(&:mark_as_read) + current_user.notifications.where(is_read: false) + .update_all(is_read: true, updated_at: Time.current) # rubocop:disable Rails/SkipsModelValidations head :no_content end From 9bd570bf1da75fd06000347877b4e6ee59035188 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Fri, 7 Jul 2023 16:39:22 +0200 Subject: [PATCH 06/10] Version 6.0.9 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05409c48a..829972a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +## v6.0.9 2023 July 07 + - Fix a bug: unable to show project step image in markdown file - Fix a bug: unable to update Store Order sub type in statistics - Fix a bug: unable to create plan with plan limitation diff --git a/package.json b/package.json index 3d86e5e37..27cba320f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "6.0.8", + "version": "6.0.9", "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", From e430ae14e2f36bb92c636153571d0d57a01eb972 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Fri, 7 Jul 2023 18:05:40 +0200 Subject: [PATCH 07/10] (i18n) updated translations --- config/locales/app.shared.de.yml | 1 + config/locales/app.shared.en.yml | 1 + config/locales/app.shared.es.yml | 1 + config/locales/app.shared.fr.yml | 1 + config/locales/app.shared.it.yml | 1 + config/locales/app.shared.no.yml | 1 + config/locales/app.shared.pt.yml | 1 + config/locales/app.shared.zu.yml | 1 + 8 files changed, 8 insertions(+) diff --git a/config/locales/app.shared.de.yml b/config/locales/app.shared.de.yml index 2e5b7333e..1b3933934 100644 --- a/config/locales/app.shared.de.yml +++ b/config/locales/app.shared.de.yml @@ -403,6 +403,7 @@ de: state_new: "Not yet due" state_pending_check: "Waiting for the cashing of the check" state_pending_transfer: "Waiting for the tranfer confirmation" + state_pending_card: "Waiting for the card payment" state_requires_payment_method: "The credit card must be updated" state_requires_action: "Action required" state_paid: "Paid" diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index bfe88a627..52a29cb13 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -403,6 +403,7 @@ en: state_new: "Not yet due" state_pending_check: "Waiting for the cashing of the check" state_pending_transfer: "Waiting for the tranfer confirmation" + state_pending_card: "Waiting for the card payment" state_requires_payment_method: "The credit card must be updated" state_requires_action: "Action required" state_paid: "Paid" diff --git a/config/locales/app.shared.es.yml b/config/locales/app.shared.es.yml index f2d54ba74..f4ec89c84 100644 --- a/config/locales/app.shared.es.yml +++ b/config/locales/app.shared.es.yml @@ -403,6 +403,7 @@ es: state_new: "Not yet due" state_pending_check: "Waiting for the cashing of the check" state_pending_transfer: "Waiting for the tranfer confirmation" + state_pending_card: "Waiting for the card payment" state_requires_payment_method: "The credit card must be updated" state_requires_action: "Action required" state_paid: "Paid" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index 1f683472f..e5161a6a7 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -403,6 +403,7 @@ fr: state_new: "Pas encore à l'échéance" state_pending_check: "En attente de l'encaissement du chèque" state_pending_transfer: "En attente de la confirmation du prélèvement" + state_pending_card: "En attente du paiement par carte" state_requires_payment_method: "La carte bancaire doit être mise à jour" state_requires_action: "Action requise" state_paid: "Payée" diff --git a/config/locales/app.shared.it.yml b/config/locales/app.shared.it.yml index 0186856bb..785ca0ad6 100644 --- a/config/locales/app.shared.it.yml +++ b/config/locales/app.shared.it.yml @@ -403,6 +403,7 @@ it: state_new: "Non ancora scaduto" state_pending_check: "In attesa di incasso dell'assegno" state_pending_transfer: "In attesa conferma del bonifico bancario" + state_pending_card: "Waiting for the card payment" state_requires_payment_method: "La carta di credito deve essere aggiornata" state_requires_action: "Azione richiesta" state_paid: "Pagato" diff --git a/config/locales/app.shared.no.yml b/config/locales/app.shared.no.yml index da0d91a74..794b127c9 100644 --- a/config/locales/app.shared.no.yml +++ b/config/locales/app.shared.no.yml @@ -403,6 +403,7 @@ state_new: "Not yet due" state_pending_check: "Waiting for the cashing of the check" state_pending_transfer: "Waiting for the tranfer confirmation" + state_pending_card: "Waiting for the card payment" state_requires_payment_method: "The credit card must be updated" state_requires_action: "Action required" state_paid: "Paid" diff --git a/config/locales/app.shared.pt.yml b/config/locales/app.shared.pt.yml index de9c0ad2d..45fdce1af 100644 --- a/config/locales/app.shared.pt.yml +++ b/config/locales/app.shared.pt.yml @@ -403,6 +403,7 @@ pt: state_new: "Ainda não vencido" state_pending_check: "Esperando a validação manual" state_pending_transfer: "Aguardando a confirmação da transferência" + state_pending_card: "Waiting for the card payment" state_requires_payment_method: "O cartão de crédito deve ser atualizado" state_requires_action: "Ação necessária" state_paid: "Pago" diff --git a/config/locales/app.shared.zu.yml b/config/locales/app.shared.zu.yml index fc1b8764d..d2a83c3a4 100644 --- a/config/locales/app.shared.zu.yml +++ b/config/locales/app.shared.zu.yml @@ -403,6 +403,7 @@ zu: state_new: "crwdns29422:0crwdne29422:0" state_pending_check: "crwdns29424:0crwdne29424:0" state_pending_transfer: "crwdns29426:0crwdne29426:0" + state_pending_card: "crwdns37663:0crwdne37663:0" state_requires_payment_method: "crwdns29428:0crwdne29428:0" state_requires_action: "crwdns29430:0crwdne29430:0" state_paid: "crwdns29432:0crwdne29432:0" From 390cf72ddf1f1609e2e373be007a62997e037f0d Mon Sep 17 00:00:00 2001 From: Du Peng Date: Mon, 10 Jul 2023 13:46:02 +0200 Subject: [PATCH 08/10] (test) fix a test for availabilites --- test/services/availabilities/availabilities_service_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/services/availabilities/availabilities_service_test.rb b/test/services/availabilities/availabilities_service_test.rb index 9d9e40315..cb3827029 100644 --- a/test/services/availabilities/availabilities_service_test.rb +++ b/test/services/availabilities/availabilities_service_test.rb @@ -35,12 +35,12 @@ class Availabilities::AvailabilitiesServiceTest < ActiveSupport::TestCase assert_empty slots end - test 'admin cannot see past availabilities further than 1 month' do + test 'admin can see past availabilities further than 1 month' do service = Availabilities::AvailabilitiesService.new(@admin) slots = service.machines([Machine.find(2)], @no_subscription, { start: Time.zone.parse('2015-06-15').beginning_of_day, end: Time.zone.parse('2015-06-15').end_of_day }) - assert_empty slots + assert_not_empty slots end test 'admin can see past availabilities in 1 month ago' do From 1ff61c938092a45368d91c89d146eb247df4351b Mon Sep 17 00:00:00 2001 From: Du Peng Date: Mon, 10 Jul 2023 13:49:39 +0200 Subject: [PATCH 09/10] (bug) unable to confirm payment of store for admin --- CHANGELOG.md | 2 ++ app/controllers/api/checkout_controller.rb | 2 +- app/services/checkout/payment_service.rb | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 829972a4a..a10534d92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +- Fix a bug: unable to confirm payment of store for admin + ## v6.0.9 2023 July 07 - Fix a bug: unable to show project step image in markdown file diff --git a/app/controllers/api/checkout_controller.rb b/app/controllers/api/checkout_controller.rb index 54f9c876a..d54e3edbb 100644 --- a/app/controllers/api/checkout_controller.rb +++ b/app/controllers/api/checkout_controller.rb @@ -31,7 +31,7 @@ class API::CheckoutController < API::APIController def confirm_payment authorize @current_order, policy_class: CheckoutPolicy - res = Checkout::PaymentService.new.confirm_payment(@current_order, current_user, params[:coupon_code], params[:payment_id]) + res = Checkout::PaymentService.new.confirm_payment(@current_order, params[:coupon_code], params[:payment_id]) render json: res rescue StandardError => e render json: e, status: :unprocessable_entity diff --git a/app/services/checkout/payment_service.rb b/app/services/checkout/payment_service.rb index 96a5df497..fbfef70e4 100644 --- a/app/services/checkout/payment_service.rb +++ b/app/services/checkout/payment_service.rb @@ -29,9 +29,7 @@ class Checkout::PaymentService end end - def confirm_payment(order, operator, coupon_code, payment_id = '') - return unless operator.member? - + def confirm_payment(order, coupon_code, payment_id = '') if Stripe::Helper.enabled? Payments::StripeService.new.confirm_payment(order, coupon_code, payment_id) elsif PayZen::Helper.enabled? From d22c3db4c2a0858eb08426348dbd834c973233d0 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Mon, 10 Jul 2023 20:53:02 +0200 Subject: [PATCH 10/10] (bug) unable to update payment schedule item --- CHANGELOG.md | 2 ++ lib/pay_zen/service.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a10534d92..ad384088b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog Fab-manager - Fix a bug: unable to confirm payment of store for admin +- Fix a bug: unable to update payment schedule item + ## v6.0.9 2023 July 07 diff --git a/lib/pay_zen/service.rb b/lib/pay_zen/service.rb index f3b15be56..d4d1759a2 100644 --- a/lib/pay_zen/service.rb +++ b/lib/pay_zen/service.rb @@ -24,7 +24,7 @@ class PayZen::Service < Payment::Service rrule: rrule(payment_schedule), order_id: order_id } - unless first_item.details['adjustment']&.zero? && first_item.details['other_items']&.zero? + if first_item.details['adjustment']&.zero? && first_item.details['other_items']&.zero? initial_amount = first_item.amount initial_amount -= payment_schedule.wallet_amount if payment_schedule.wallet_amount if initial_amount.zero? @@ -140,7 +140,7 @@ class PayZen::Service < Payment::Service transaction_date = Time.zone.parse(transaction['creationDate']).to_date amount = payment_schedule_item.amount - if !payment_schedule_item.details['adjustment']&.zero? && payment_schedule_item.payment_schedule.wallet_amount + if payment_schedule_item.details['adjustment']&.zero? && payment_schedule_item.payment_schedule.wallet_amount amount -= payment_schedule_item.payment_schedule.wallet_amount end