Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with entry of multiple assets via Lots entry modal #6710

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/src/modules/stock/entry/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,10 @@ function StockEntryController(
stockLine.tracking_expiration = inventory.tracking_expiration;
stockLine.unique_item = inventory.unique_item;
stockLine.is_asset = inventory.is_asset;
if (inventory.is_asset) {
stockLine.quantity = 1;
if (stockLine.lots && stockLine.lots.length > 0) {
stockLine.quantity = stockLine.lots.reduce((n, row) => n + row.quantity, 0);
} else {
stockLine.quantity = inventory.is_asset ? 1 : 0;
}

StockModal.openDefineLots({
Expand Down
1 change: 0 additions & 1 deletion client/src/modules/stock/entry/modals/lots.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

<input
ng-if="$ctrl.isCostEditable"
ng-disabled="$ctrl.stockLine.is_asset"
class="form-control"
type="number"
ng-change="$ctrl.onChangeQuantity()"
Expand Down
6 changes: 4 additions & 2 deletions client/src/modules/stock/entry/modals/lots.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function StockDefineLotsModalController(
}

// Hide columns in the grid when it doesn't apply to this inventory item.
const shouldShowSerialNumber = Data.stockLine.is_asset;
const isAsset = Data.stockLine.is_asset;
const showShowExpirationDate = !(Data.stockLine.tracking_expiration === false || Data.stockLine.is_asset);

Data.stockLine.prev_unit_cost = Data.stockLine.unit_cost; // Save for later checks
Expand All @@ -50,6 +50,7 @@ function StockDefineLotsModalController(
vm.stockLine = angular.copy(Data.stockLine);
vm.entryType = Data.entry_type;
vm.entryDate = Data.entry_date;
vm.isAsset = Data.stockLine.is_asset;

vm.currencyId = Data.currency_id !== undefined
? Data.currency_id : vm.enterprise.currency_id;
Expand Down Expand Up @@ -110,7 +111,7 @@ function StockDefineLotsModalController(
displayName : 'TABLE.COLUMNS.SERIAL_NUMBER',
headerCellFilter : 'translate',
aggregationHideLabel : true,
visible : shouldShowSerialNumber,
visible : isAsset,
width : 220,
cellTemplate : 'modules/stock/entry/modals/templates/serial_number.input.tmpl.html',
}, {
Expand All @@ -129,6 +130,7 @@ function StockDefineLotsModalController(
aggregationHideLabel : true,
footerCellClass : 'text-right',
cellTemplate : 'modules/stock/entry/modals/templates/lot.quantity.tmpl.html',
visible : !isAsset,
}, {
field : 'expiration_date',
type : 'date',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="ui-grid-cell-contents">

<input
min="0"
type="number"
Expand Down