Details
-
Story
-
Status: Closed (View Workflow)
-
P2
-
Resolution: Done
-
None
-
ACQ Sprint 84, ACQ Sprint 85
-
5
-
Thunderjet
Description
Overview
When an invoice is processed payments or credits need to be created again the Funds that are responsible for accounting for the invoices value.
Approach:
Current assumption is that payments will be created for all positive fund distributions and credits will be created for all negative fund distributions.
- Determine the expected number of payments & credits.
- Check if the payments have already been processed. If yes, go to step 5
- use GET /finance/transactions?query=invoiceInvoiceId==<invoiceId>.
- Create payment_summary
- Use POST /finance/invoice-payment-summaries
- Generate and send payments & credits for processing
- One payment or credit for each fundDistribution for each invoiceLine (see example below)
- Use POST /finance/payments and POST /finance/credits
- Update invoice status to Paid.
NOTE: If any of these steps fail, an appropriate error message should be returned to the client - saying that paying the invoice failed, and they can retry.
NOTE: The transactions can happen in parallel. If needed we can look at batching these in the future but that's outside the scope of this story.
Example of Generating Payments/Credits
Invoice XYZ
- invoiceLine A
- Fund Distro $50, USHIST
- Fund Distro $25, HIST
- invoiceLine B
- Fund Distro $25, LAW
- Fund Distro $25, MATH
- Fund Distro $25, HIST
- invoiceLine C
- Fund Distro -$10, USHIST
InvoicePaymentSummary:
- Invoice: XYZ
- NumPayments: 6
Payments:
- $50 USHIST (Invoice: XYZ, InvoiceLine: A)
- $25 HIST (Invoice: XYZ, InvoiceLine: A)
- $25 LAW (Invoice: XYZ, InvoiceLine: B)
- $25 MATH (Invoice: XYZ, InvoiceLine: B)
- $25 HIST (Invoice: XYZ, InvoiceLine: B)
Credits:
- $10 USHIST (Invoice: XYZ, InvoiceLine: C)
Additional Background/Context/Details
See related section/flowchart on this spike page
See the wiki for additional details
Acceptance criteria:
- The business logic described above has been added
- Unit tests are updated
- API tests are updated
TestRail: Results
Attachments
Issue Links
- blocks
-
MODINVOICE-150 Create MODINVOICE bugfix release
-
- Closed
-
- has to be done before
-
UINV-83 Prevent paying with Funds that have insufficient amounts to cover distribution
-
- Closed
-
- is blocked by
-
MODFIN-71 Create transaction APIs - Payments, Credits
-
- Closed
-
-
MODFISTO-95 Not able to pay invoice after approval
-
- Closed
-
- relates to
-
UXPROD-2167 Value management through transactions Part 2 - Payments, Credits and limits
-
- Closed
-