Skip to content

Commit

Permalink
Fix: Prevent parent service to substract paid_to days
Browse files Browse the repository at this point in the history
With my childservice paymentlogic user could see increase of paid_to date.
For example with initial transaction extradays are added to parent
and chid services. It could be that shildservice after next payment is
paid more to future than new transaction gives. This commit fixes that.

Signed-off-by: Erkki Hietaranta <[email protected]>
  • Loading branch information
sbeach92 committed Mar 5, 2024
1 parent d207e86 commit 96f7736
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions utils/businesslogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ def _service_paid_by_transaction(servicesubscription, transaction, add_days):
else:
added_days = servicesubscription.paid_until - transaction.date
child_days = 0
# check if and howmuch forehand child servce is paid
if paid_servicesubscription.paid_until:
if paid_servicesubscription.paid_until > transaction.date:
child_date = (
Expand All @@ -476,6 +477,13 @@ def _service_paid_by_transaction(servicesubscription, transaction, add_days):
- {child_days}
= gained {extra_days} days more"""
)

if extra_days < 0:
logger.debug(
"Gained days are negative, using previous paid to date"
)
extra_days = 0

# Calculate child subscription payment to happen at same time that latest parrent subsciption,
# useful with custominvoices that pays Parent subscription multiple times
BusinessLogic._service_paid_by_transaction(
Expand Down

0 comments on commit 96f7736

Please sign in to comment.