feat(reports): inventory valuation report.

feat(reports): sales by items report.
feat(reports): purchases by items report.
This commit is contained in:
a.bouhuolia
2021-03-29 10:51:24 +02:00
parent 9a204282a2
commit 2d6d642f3b
19 changed files with 1106 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
import { Model } from 'objection';
import { Model, raw } from 'objection';
import moment from 'moment';
import TenantModel from 'models/TenantModel';
@@ -34,6 +34,22 @@ export default class InventoryTransaction extends TenantModel {
query.where('date', '<=', toDate);
}
},
itemsTotals(builder) {
builder.select('itemId');
builder.sum('rate as rate');
builder.sum('quantity as quantity');
builder.select(raw('SUM(`QUANTITY` * `RATE`) as COST'));
builder.groupBy('itemId');
},
INDirection(builder) {
builder.where('direction', 'IN');
},
OUTDirection(builder) {
builder.where('direction', 'OUT');
},
};
}