Skip to content

Commit

Permalink
fix(Report to compare invoiced items to received stock)
Browse files Browse the repository at this point in the history
- Correction of error on the table
- Display of the difference in costs (invoicing on distribution) instead of
the difference in the cost of invoicing the item on compared to the cost
of distribution
- Correction in the joint concerning the unit cost of distribution
  • Loading branch information
lomamech committed May 8, 2020
1 parent 6bce38d commit a4f3e05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.report = report;
// default report parameters
const DEFAULT_PARAMS = {
csvKey : 'invoiced_received_stock',
filename : 'REPORT.PATIENT_STANDING.DESCRIPTION',
filename : 'REPORT.COMPARE_INVOICED_RECEIVED.TITLE',
orientation : 'landscape',
};

Expand Down Expand Up @@ -50,9 +50,7 @@ function report(req, res, next) {
SELECT aggr.reference, BUID(aggr.inventory_uuid) AS inventory_uuid, aggr.inventory_text,
SUM(aggr.quantity) AS quantity_invoiced, aggr.price_invoiced,
BUID(aggr.invoice_uuid) AS invoice_uuid, aggr.invoice_date,
SUM(aggr.quantity_distributed) AS quantity_distributed, aggr.cost_distributed,
(aggr.quantity - aggr.quantity_distributed) AS quantity_difference,
(aggr.price_invoiced - aggr.cost_distributed) AS cost_difference
SUM(aggr.quantity_distributed) AS quantity_distributed, SUM(aggr.cost_distributed) AS cost_distributed
FROM (
SELECT map.text AS reference, inv.uuid AS inventory_uuid, inv.text AS inventory_text, item.quantity,
item.inventory_price AS price_invoiced,iv.uuid AS invoice_uuid, iv.date AS invoice_date, 0 AS quantity_distributed,
Expand Down Expand Up @@ -140,6 +138,9 @@ function report(req, res, next) {
inventory.total_item_invoiced = inventory.quantity_invoiced * inventory.price_invoiced;
inventory.total_item_distributed = inventory.quantity_distributed * inventory.cost_distributed;

inventory.quantity_difference = inventory.quantity_invoiced - inventory.quantity_distributed;
inventory.cost_difference = inventory.total_item_invoiced - inventory.total_item_distributed;

totalInvoice += inventory.total_item_invoiced;
totalDistribution += inventory.total_item_distributed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
{{/if}}
</td>
<td class="text-right">
{{/each}}
{{#if total_item_invoiced }}
<strong>{{ debcred total_item_invoiced ../../metadata.enterprise.currency_id }}</strong>
{{/if}}
Expand All @@ -92,6 +91,7 @@
<td class="text-right"> <strong> {{ lessZero quantity_difference }} </strong></td>
<td class="text-right"> <strong> {{ debcred cost_difference ../../metadata.enterprise.currency_id }} </strong></td>
</tr>
{{/each}}
<tr>
<td></td>
<td class="text-right text-uppercase" colspan="2"><strong> {{translate 'TABLE.COLUMNS.TOTAL_INVOICE'}} </strong></td>
Expand Down

0 comments on commit a4f3e05

Please sign in to comment.