|
@@ -24,11 +24,12 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
async gatherBgBills (tid) {
|
|
|
- const sql = 'SELECT code, name, unit, unit_price, Sum(camount) as quantity' +
|
|
|
- ' FROM ' + this.tableName +
|
|
|
- ' WHERE tid = ?' +
|
|
|
+ const sql = 'SELECT cb.code, cb.name, cb.unit, cb.unit_price, Sum(cb.samount + 0) as quantity' +
|
|
|
+ ' FROM ' + this.tableName + ' cb' +
|
|
|
+ ' LEFT JOIN ' + this.ctx.service.change.tableName + ' c ON cb.cid = c.cid' +
|
|
|
+ ' WHERE cb.tid = ? and c.status = ?' +
|
|
|
' GROUP BY code, name, unit, unit_price';
|
|
|
- const param = [tid];
|
|
|
+ const param = [tid, audit.flow.status.checked];
|
|
|
const result = await this.db.query(sql, param);
|
|
|
for (const b of result) {
|
|
|
b.total_price = this.ctx.helper.mul(b.unit_price, b.quantity, this.ctx.tender.info.decimal.tp);
|