Skip to content

Commit

Permalink
Improved shipment document
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Apr 27, 2022
1 parent d21f781 commit ecf2670
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
<th>{{translate 'STOCK.INVENTORY'}}</th>
<th>{{translate 'STOCK.LOT'}}</th>
<th>{{translate 'STOCK.QUANTITY'}}</th>
<th>{{translate 'SHIPMENT.LOT_CONDITION'}}</th>
<th>{{translate 'STOCK.UNIT_COST'}}</th>
<th>{{translate 'STOCK.COST'}}</th>
<th>{{translate 'SHIPMENT.DATE_PACKED'}}</th>
</tr>
</thead>
Expand All @@ -158,7 +159,8 @@
<td>{{inventory_label}}</td>
<td>{{lot_label}}</td>
<td>{{quantity_sent}}</td>
<td>{{translate condition}}</td>
<td>{{currency unit_price ../metadata.enterprise.currency_id}}</td>
<td>{{currency cost ../metadata.enterprise.currency_id}}</td>
<td>{{date date_packed}}</td>
</tr>
{{else}}
Expand All @@ -167,7 +169,8 @@
</tbody>
<tfoot>
<tr style="font-weight: bold;">
<td colspan="6">{{records.length}} {{translate 'STOCK.ITEMS'}}</td>
<td colspan="5">{{records.length}} {{translate 'STOCK.ITEMS'}}</td>
<td>{{currency totalCost metadata.enterprise.currency_id}}</td>
</tr>
</tfoot>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ async function getShipmentOverview(req, res, next) {
});
const single = await shipment.lookupSingle(uuid);
const records = await shipment.getPackingList(uuid);
records.forEach(row => {
row.cost = row.quantity_sent * row.unit_price;
});
const totalCost = records.reduce((agg, row) => agg + row.cost, 0);

const log = await shipment.getShipmentInfo(uuid);
const step = shipment.getStep(single.status_name);

const data = {
step,
single,
records,
totalCost,
log,
date : new Date(),
};
Expand Down
5 changes: 3 additions & 2 deletions server/controllers/asset_management/shipment/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,15 @@ async function getPackingList(identifier) {
sh.anticipated_delivery_date,
sh.receiver, u.display_name AS created_by,
shi.quantity_sent, shi.quantity_delivered, shi.date_packed,
l.label AS lot_label, i.code AS inventory_code,
i.text AS inventory_label, i.is_asset,
l.label AS lot_label, sv.wac AS unit_price,
i.code AS inventory_code, i.text AS inventory_label, i.is_asset,
dm.text AS reference
FROM shipment sh
JOIN shipment_status ss ON ss.id = sh.status_id
JOIN shipment_item shi ON shi.shipment_uuid = sh.uuid
JOIN lot l ON l.uuid = shi.lot_uuid
JOIN inventory i ON i.uuid = l.inventory_uuid
JOIN stock_value sv ON sv.inventory_uuid = i.uuid
JOIN user u ON u.id = sh.created_by
JOIN document_map dm ON dm.uuid = sh.uuid
WHERE sh.uuid = ?
Expand Down

0 comments on commit ecf2670

Please sign in to comment.