diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bc93531c..ad384088b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # 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 + - 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 +- 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/Gemfile.lock b/Gemfile.lock index 1d1f8f54d..6c6c012ae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -529,6 +529,7 @@ GEM PLATFORMS x86_64-darwin-20 + x86_64-darwin-21 x86_64-linux DEPENDENCIES 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/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 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] 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] 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? 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 diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 603b0cf57..c5fc4289f 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -455,8 +455,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: @@ -1821,10 +1821,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" family_account: "Compte famille" family_account_info_html: "Le compte Famille permet à vos membres d'ajouter leurs enfants de moins de 18 ans sur leur propre compte et de les inscrire directement aux évènements de type Famille. Vous pouvez aussi demander des justificatifs pour chaque enfant et valider leur compte." enable_family_account: "Activer l'option Compte Famille" diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml index 65a91174f..da4ab59e1 100644 --- a/config/locales/app.public.fr.yml +++ b/config/locales/app.public.fr.yml @@ -186,8 +186,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/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 e2ff2a219..6c356f04d 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -406,6 +406,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 d7f2c85bc..7ebd887a0 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -406,6 +406,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" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 111004964..ebe8aa01f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -720,10 +720,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" 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 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", 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