Skip to content

Commit

Permalink
fix(vouchers): compute quantities for reversals
Browse files Browse the repository at this point in the history
This commit updates the ReverseTransaction() stored procedure to compute
quantities for reversals.  Previously, this value was set to a default
of 0.
  • Loading branch information
jniles committed Oct 19, 2017
1 parent 7d46062 commit cb00962
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/models/procedures/voucher.sql
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ BEGIN
FROM general_ledger AS gl WHERE gl.record_uuid = uuid
) AS zz;

-- update the "amount" with the sum of the voucher_items. We could choose either
-- debits or credits to sum here ... they should be equivalent.
UPDATE voucher SET amount = (
SELECT SUM(vi.debit) FROM (
SELECT * FROM voucher_item) AS vi WHERE vi.voucher_uuid = voucher.uuid
) WHERE voucher.uuid = voucher_uuid;

-- make sure we update the invoice with the fact that it got reversed.
IF isInvoice THEN
UPDATE invoice SET reversed = 1 WHERE invoice.uuid = uuid;
Expand Down

0 comments on commit cb00962

Please sign in to comment.