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

(bug) wrong amount when pay a reservation with payment schedule

This commit is contained in:
Du Peng 2023-11-17 17:59:10 +01:00
parent 28f62228b0
commit b2c3851ddc
2 changed files with 12 additions and 11 deletions

View File

@ -1,5 +1,7 @@
# Changelog Fab-manager # Changelog Fab-manager
- fix a bug: wrong amount when pay a reservation with payment schedule
## v6.3.3 2023 November 14 ## v6.3.3 2023 November 14
- fix a bug: wrong currency unit for locale fr-CH - fix a bug: wrong currency unit for locale fr-CH

View File

@ -24,16 +24,14 @@ class PayZen::Service < Payment::Service
rrule: rrule(payment_schedule), rrule: rrule(payment_schedule),
order_id: order_id order_id: order_id
} }
if first_item.details['adjustment']&.zero? && first_item.details['other_items']&.zero? initial_amount = first_item.amount
initial_amount = first_item.amount initial_amount -= payment_schedule.wallet_amount if payment_schedule.wallet_amount
initial_amount -= payment_schedule.wallet_amount if payment_schedule.wallet_amount if initial_amount.zero?
if initial_amount.zero? params[:effect_date] = (first_item.due_date + 1.month).iso8601
params[:effect_date] = (first_item.due_date + 1.month).iso8601 params[:rrule] = rrule(payment_schedule, -1)
params[:rrule] = rrule(payment_schedule, -1) else
else params[:initial_amount] = payzen_amount(initial_amount)
params[:initial_amount] = payzen_amount(initial_amount) params[:initial_amount_number] = 1
params[:initial_amount_number] = 1
end
end end
pz_subscription = client.create_subscription(**params) pz_subscription = client.create_subscription(**params)
@ -141,7 +139,8 @@ class PayZen::Service < Payment::Service
transaction_date = Time.zone.parse(transaction['creationDate']).to_date transaction_date = Time.zone.parse(transaction['creationDate']).to_date
amount = payment_schedule_item.amount amount = payment_schedule_item.amount
if payment_schedule_item.details['adjustment']&.zero? && payment_schedule_item.payment_schedule.wallet_amount if payment_schedule_item == payment_schedule_item.payment_schedule.ordered_items.first &&
payment_schedule_item.payment_schedule.wallet_amount
amount -= payment_schedule_item.payment_schedule.wallet_amount amount -= payment_schedule_item.payment_schedule.wallet_amount
end end