Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for payment issue due to due date #1107

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions ledger/payments/invoice/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ def _get_payment_choice(payment_method):
def create_invoice_crn(order_number, amount, crn_string, system, text, payment_method=None, invoice_name='', due_date=None):
'''Make a new Invoice object using crn
'''
inv,created = Invoice.objects.get_or_create(
order_number=order_number,
amount=amount,
reference = getCRN(crn_string),
invoice_name=invoice_name,
due_date=due_date
)

print ("create_invoice_crn!!! <<- JASON")
print (inv)
inv_lookup = Invoice.objects.filter(order_number=order_number)
if inv_lookup.count() > 0:
inv = Invoice.objects.get(order_number=order_number)
created = inv.created
else:
Invoice.objects.create(
order_number=order_number,
amount=amount,
reference = getCRN(crn_string),
invoice_name=invoice_name,
due_date=due_date
)
inv = Invoice.objects.get(order_number=order_number)
created = inv.created

if created:
if payment_method:
Expand All @@ -47,13 +52,23 @@ def create_invoice_icrn(order_number, amount, crn_string, _format, system, text,
if not date:
raise ValueError('Date is required to generate ICRN number')
icrn = getICRN(crn_string,amount,_format)
inv, created = Invoice.objects.get_or_create(
order_number=order_number,
amount=amount,
reference = icrn,
invoice_name=invoice_name,
due_date=due_date
)


inv_lookup = Invoice.objects.filter(order_number=order_number)
if inv_lookup.count() > 0:
inv = Invoice.objects.get(order_number=order_number)
created = inv.created
else:
Invoice.objects.create(
order_number=order_number,
amount=amount,
reference = icrn,
invoice_name=invoice_name,
due_date=due_date
)
inv = Invoice.objects.get(order_number=order_number)
created = inv.created

if created:
if payment_method:
inv.payment_method = _get_payment_choice(payment_method)
Expand Down
Loading