Skip to content

Commit

Permalink
Merge pull request #602 from sussol/#69-Allow-Finalising-of-zero-diff…
Browse files Browse the repository at this point in the history
…erence-stockake

#69-Allow-Finalising-of-zero-difference-stockake
  • Loading branch information
Chris-Petty authored Feb 7, 2018
2 parents b5a8e51 + 59df6fc commit 6bbdc9b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/database/DataTypes/Stocktake.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Stocktake extends Realm.Object {
}

get hasSomeCountedItems() {
return this.items.some(item => item.hasBatchWithQuantityChange);
return this.items.some(item => item.hasCountedBatches);
}

get numberOfBatches() {
Expand Down Expand Up @@ -129,7 +129,7 @@ export class Stocktake extends Realm.Object {
adjustInventory(database) {
// Prune all StocktakeItems with no quantity change
database.delete('StocktakeItem', this.items.filter(stocktakeItem =>
!stocktakeItem.hasBatchWithQuantityChange));
!stocktakeItem.hasCountedBatches));
// Get list of all StocktakeBatches associated with this stocktake
const stocktakeBatches = database.objects('StocktakeBatch')
.filtered('stocktake.id = $0', this.id);
Expand Down
4 changes: 0 additions & 4 deletions src/database/DataTypes/StocktakeItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ export class StocktakeItem extends Realm.Object {
* for StocktakeItem is 0.
* @return {boolean} True if StocktakeBatches have adjustments
*/
get hasBatchWithQuantityChange() {
return this.batches.some(stocktakeBatch => stocktakeBatch.difference !== 0);
}

get hasCountedBatches() {
return this.batches.some(stocktakeBatch => stocktakeBatch.hasBeenCounted);
}
Expand Down

0 comments on commit 6bbdc9b

Please sign in to comment.