Skip to content

Commit

Permalink
fix(stock): bhStockOut indicator dates
Browse files Browse the repository at this point in the history
Fixes the date parsing in the bhStockOut component.
  • Loading branch information
jniles committed Mar 4, 2022
1 parent 8f9e00f commit b2eea8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions client/src/js/components/bhStockOut/bhStockOut.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ bhStockOutController.$inject = ['DepotService', 'moment', 'NotifyService', '$fil
*/
function bhStockOutController(Depots, moment, Notify, $filter, $q) {
const $ctrl = this;

$ctrl.loading = false;
$ctrl.stockOutInventories = [];

const $date = $filter('date');

$ctrl.$onInit = () => {
$ctrl.loading = false;
$ctrl.stockOutInventories = [];

fetchStockOuts();
};

Expand All @@ -48,9 +47,11 @@ function bhStockOutController(Depots, moment, Notify, $filter, $q) {
])
.then(([inventories, depot]) => {

console.log('inventories:', inventories);

inventories.forEach(inventory => {
inventory.stock_out_date_raw = $date(inventory.stock_out_date);
inventory.stock_out_date_parsed = moment(inventory.stock_out_date).fromNow();
inventory.stock_out_date_raw = $date(inventory.date);
inventory.stock_out_date_parsed = moment(inventory.date).fromNow();
});

$ctrl.depot = depot;
Expand Down
3 changes: 2 additions & 1 deletion server/controllers/inventory/depots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ async function getStockOuts(req, res, next) {

try {
const sql = `
SELECT sms.date, BUID(sms.inventory_uuid) AS uuid, sms.sum_quantity AS quantity,
SELECT sms.date, BUID(sms.inventory_uuid) AS uuid,
sms.sum_quantity AS quantity,
inventory.code, inventory.text
FROM stock_movement_status AS sms JOIN (
SELECT inside.inventory_uuid, MAX(inside.date) AS date
Expand Down

0 comments on commit b2eea8d

Please sign in to comment.