diff --git a/CHANGELOG.md b/CHANGELOG.md index 829972a4a..70af09fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog Fab-manager +## v6.0.10 2023 July 13 + +- Fix a bug: unable to confirm payment of store for admin +- Fix a bug: unable to update payment schedule item +- Fix a bug: event reserved places compute error +- [TODO DEPLOY] `rails fablab:setup:build_places_cache` + ## 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 @@ def payment 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 @@ def payment(order, operator, coupon_code, payment_id = '') 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/slots/places_cache_service.rb b/app/services/slots/places_cache_service.rb index d063aafc8..65a19b733 100644 --- a/app/services/slots/places_cache_service.rb +++ b/app/services/slots/places_cache_service.rb @@ -30,10 +30,14 @@ def refresh(slot) reservations = Slots::ReservationsService.reservations(slot.slots_reservations, [reservable]) pending = Slots::ReservationsService.pending_reservations(slot.cart_item_reservation_slots.map(&:id), [reservable]) + reserved_places = (reservations[:reservations].count || 0) + (pending[:reservations].count || 0) + if slot.availability.available_type == 'event' + reserved_places = slot.availability.event.nb_total_places - slot.availability.event.nb_free_places + end places.push({ reservable_type: reservable.class.name, reservable_id: reservable.try(&:id), - reserved_places: (reservations[:reservations].count || 0) + (pending[:reservations].count || 0), + reserved_places: reserved_places, user_ids: reservations[:user_ids] + pending[:user_ids] }) end 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" 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 @@ def create_subscription(payment_schedule, order_id, *_args) 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 @@ def transaction_matches?(transaction, payment_schedule_item) 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 27cba320f..4f5e16cdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "6.0.9", + "version": "6.0.10", "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