Skip to content

Commit

Permalink
feat(stock): highlight expired lots in adjustment
Browse files Browse the repository at this point in the history
Highlights the expired lots in the inventory adjustment module.

Closes #5187.
  • Loading branch information
jniles committed Jan 26, 2021
1 parent d2099f1 commit 621867d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function StockInventoryAdjustmentController(
vm.submit = submit;

const expirationDateCellTemplate = `
<div class="ui-grid-cell-contents">
<div class="ui-grid-cell-contents"
ng-class="{ 'bg-danger text-danger' : row.entity.isExpired }"
title="{{row.entity.expiration_date | date }}">
<span am-time-ago="row.entity.expiration_date"></span>
</div>
`;
Expand Down Expand Up @@ -152,6 +154,8 @@ function StockInventoryAdjustmentController(
vm.loading = true;
setupStock();

const today = new Date();

Stock.lots.read(null, {
depot_uuid : depot.uuid,
includeEmptyLot : vm.includeEmptyLot || 0,
Expand All @@ -171,6 +175,8 @@ function StockInventoryAdjustmentController(
Object.assign(row, {
old_quantity : row.quantity,

isExpired : (new Date(lot.expiration_date) < today),

// overwrite the default validation function as it doesn't make sense in
// this case.
validate() {
Expand Down

0 comments on commit 621867d

Please sign in to comment.