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

19939 - EFT - Invoice Reference #1436

Merged
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
17 changes: 9 additions & 8 deletions pay-api/src/pay_api/services/eft_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pay_api.models import Payment as PaymentModel
from pay_api.models import PaymentAccount as PaymentAccountModel
from pay_api.models import Receipt as ReceiptModel
from pay_api.utils.enums import InvoiceReferenceStatus, InvoiceStatus, PaymentMethod, PaymentStatus
from pay_api.utils.enums import InvoiceReferenceStatus, PaymentMethod, PaymentStatus

from .deposit_service import DepositService
from .invoice import Invoice
Expand All @@ -40,7 +40,12 @@ def get_payment_method_code(self):
def create_invoice(self, payment_account: PaymentAccount, line_items: [PaymentLineItem], invoice: Invoice,
**kwargs) -> InvoiceReference:
"""Return a static invoice number for direct pay."""
# Do nothing here as the invoice references will be created later for eft payment reconciliations (TDI17).
payment: PaymentModel = PaymentModel.find_payment_for_invoice(invoice.id)
invoice_reference = self.create_invoice_reference(invoice=invoice, payment=payment)

invoice_reference.save()

return invoice_reference

def apply_credit(self,
invoice: Invoice,
Expand All @@ -59,15 +64,13 @@ def apply_credit(self,
payment_date=payment_date,
paid_amount=invoice_balance - new_invoice_balance)

invoice_ref = self.create_invoice_reference(invoice=invoice_model, payment=payment)
receipt = self.create_receipt(invoice=invoice_model, payment=payment)

if auto_save:
payment.save()
invoice_ref.save()
receipt.save()

return payment, invoice_ref, receipt
return payment, receipt

def complete_post_invoice(self, invoice: Invoice, invoice_reference: InvoiceReference) -> None:
"""Complete any post invoice activities if needed."""
Expand Down Expand Up @@ -97,9 +100,7 @@ def create_invoice_reference(invoice: InvoiceModel, payment: PaymentModel) -> In

invoice_reference.invoice_id = invoice.id
invoice_reference.invoice_number = payment.invoice_number
invoice_reference.status_code = InvoiceReferenceStatus.COMPLETED.value \
if invoice.invoice_status_code == InvoiceStatus.PAID.value \
else InvoiceReferenceStatus.ACTIVE.value
invoice_reference.status_code = InvoiceReferenceStatus.ACTIVE.value

return invoice_reference

Expand Down
Loading