Skip to content

Commit

Permalink
fix the lot report expiration_date and delay_experiration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebed-meleck committed Feb 3, 2024
1 parent 2580145 commit d2c80f9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/controllers/stock/reports/stock/lots_report.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const moment = require('moment');
const {
_, ReportManager, Stock, formatFilters, STOCK_LOTS_REPORT_TEMPLATE, stockStatusLabelKeys,
} = require('../common');
Expand Down Expand Up @@ -60,14 +61,16 @@ function stockLotsReport(req, res, next) {
'enterprisePurchaseInterval', 'exhausted', 'expired',
'inventory_uuid', 'lifetime_lot', 'min_delay',
'min_months_security_stock', 'mvt_quantity', 'near_expiration',
'purchase_interval', 'tag_name', 'tracking_consumption',
'tracking_expiration', 'wac'];
'purchase_interval', 'tag_name', 'tracking_consumption', 'wac'];

const dateKeys = ['min_stock_date', 'max_stock_date'];

return Stock.getLotsDepot(null, options)
.then((rows) => {
rows.forEach(row => {
const current = new Date();
const delay = moment(new Date(row.expiration_date)).diff(current);
row.delay_expiration = moment.duration(delay).humanize(true);
// Purge unneeded fields from the row
purgeKeys.forEach(key => {
delete row[key];
Expand Down

0 comments on commit d2c80f9

Please sign in to comment.