Skip to content

Commit

Permalink
(bug) wrong amount when pay a reservation with payment schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed Nov 17, 2023
1 parent 28f6222 commit b2c3851
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog Fab-manager

- fix a bug: wrong amount when pay a reservation with payment schedule

## v6.3.3 2023 November 14

- fix a bug: wrong currency unit for locale fr-CH
Expand Down
21 changes: 10 additions & 11 deletions lib/pay_zen/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ def create_subscription(payment_schedule, order_id, *_args)
rrule: rrule(payment_schedule),
order_id: order_id
}
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?
params[:effect_date] = (first_item.due_date + 1.month).iso8601
params[:rrule] = rrule(payment_schedule, -1)
else
params[:initial_amount] = payzen_amount(initial_amount)
params[:initial_amount_number] = 1
end
initial_amount = first_item.amount
initial_amount -= payment_schedule.wallet_amount if payment_schedule.wallet_amount
if initial_amount.zero?
params[:effect_date] = (first_item.due_date + 1.month).iso8601
params[:rrule] = rrule(payment_schedule, -1)
else
params[:initial_amount] = payzen_amount(initial_amount)
params[:initial_amount_number] = 1
end
pz_subscription = client.create_subscription(**params)

Expand Down Expand Up @@ -141,7 +139,8 @@ 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 == payment_schedule_item.payment_schedule.ordered_items.first &&
payment_schedule_item.payment_schedule.wallet_amount
amount -= payment_schedule_item.payment_schedule.wallet_amount
end

Expand Down

0 comments on commit b2c3851

Please sign in to comment.