changes to the status changes
This commit is contained in:
+22
-3
@@ -3308,7 +3308,7 @@ def booking_payment():
|
||||
)
|
||||
billing_update = {
|
||||
"package": ",".join(effective_package_keys),
|
||||
"status": "ready",
|
||||
"status": reuse_instance.get("status") or "ready",
|
||||
"last_message": (
|
||||
"Ausgewählte Module wurden entfernt. Die bestehende Jahresrechnung bleibt unverändert."
|
||||
if booking_action == "downgrade"
|
||||
@@ -3323,6 +3323,17 @@ def booking_payment():
|
||||
"payment_status": "pending",
|
||||
"payment_due_at": (date.today() + timedelta(days=PAYMENT_GRACE_DAYS)).isoformat(),
|
||||
})
|
||||
else:
|
||||
# A downgrade changes only the module configuration. Keep
|
||||
# the existing billing state and invoice untouched.
|
||||
for billing_field in (
|
||||
"billing_state",
|
||||
"payment_status",
|
||||
"payment_due_at",
|
||||
"invoice_id",
|
||||
):
|
||||
if billing_field in reuse_instance:
|
||||
billing_update[billing_field] = reuse_instance[billing_field]
|
||||
if reuse_instance.get("is_trial"):
|
||||
billing_update.update({
|
||||
"is_trial": False,
|
||||
@@ -3365,10 +3376,18 @@ def booking_payment():
|
||||
"amount_gross_eur": 0.0 if booking_action == "downgrade" else gross_price,
|
||||
"amount_net_eur": 0.0 if booking_action == "downgrade" else net_price,
|
||||
"booking_flow": booking_flow,
|
||||
"invoice_id": invoice_id,
|
||||
"invoice_id": (
|
||||
reuse_instance.get("invoice_id")
|
||||
if booking_action == "downgrade"
|
||||
else invoice_id
|
||||
),
|
||||
"subdomain": subdomain,
|
||||
"domain": reuse_instance.get("domain") or f"{subdomain}.invario-software.de",
|
||||
"payment_due_at": (date.today() + timedelta(days=PAYMENT_GRACE_DAYS)).isoformat(),
|
||||
"payment_due_at": (
|
||||
reuse_instance.get("payment_due_at")
|
||||
if booking_action == "downgrade"
|
||||
else (date.today() + timedelta(days=PAYMENT_GRACE_DAYS)).isoformat()
|
||||
),
|
||||
"avv_version": form_data.get("avv_version"),
|
||||
"legal_consents_accepted_at": form_data.get("legal_consents_accepted_at"),
|
||||
"notes": form_data.get("notes"),
|
||||
|
||||
Reference in New Issue
Block a user