|
@@ -35,13 +35,23 @@ module.exports = app => {
|
|
|
const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
|
|
|
const advance = await this.db.query(sql, sqlParam);
|
|
|
for (const item of advance) {
|
|
|
- item.pay_ratio = this.ctx.helper.mul(this.ctx.helper.div(item.cur_amount, advancePayTotal), 100, 2) || 0;
|
|
|
- const s1 = item.cur_amount && item.cur_amount.toString().split('.')[1];
|
|
|
+ let s1,
|
|
|
+ s3;
|
|
|
const s2 = item.prev_amount.toString().split('.')[1];
|
|
|
- const s3 = item.prev_total_amount.toString().split('.')[1];
|
|
|
- item.cur_amount = this.ctx.helper.formatMoney(item.cur_amount, ',', s1 && s1.length || 0);
|
|
|
+ item.pay_ratio = this.ctx.helper.mul(this.ctx.helper.div(item.cur_amount, advancePayTotal), 100, 2) || 0;
|
|
|
+ if (item.status === auditConst.status.uncheck || item.status === auditConst.status.checkNo) {
|
|
|
+ const cur_amount = item.cur_amount && this.ctx.helper.round(item.cur_amount, decimal) || 0;
|
|
|
+ s1 = parseFloat(cur_amount).toString().split('.')[1];
|
|
|
+ s3 = parseFloat(this.ctx.helper.add(cur_amount, item.prev_amount)).toString().split('.')[1];
|
|
|
+ item.cur_amount = this.ctx.helper.formatMoney(cur_amount, ',', s1 && s1.length || 0);
|
|
|
+ item.prev_total_amount = this.ctx.helper.formatMoney(this.ctx.helper.add(cur_amount, item.prev_amount), ',', s3 && s3.length || 0);
|
|
|
+ } else {
|
|
|
+ s1 = item.cur_amount && item.cur_amount.toString().split('.')[1];
|
|
|
+ s3 = item.prev_total_amount.toString().split('.')[1];
|
|
|
+ item.cur_amount = this.ctx.helper.formatMoney(item.cur_amount, ',', s1 && s1.length || 0);
|
|
|
+ item.prev_total_amount = this.ctx.helper.formatMoney(item.prev_total_amount, ',', s3 && s3.length || 0);
|
|
|
+ }
|
|
|
item.prev_amount = this.ctx.helper.formatMoney(item.prev_amount, ',', s2 && s2.length || 0);
|
|
|
- item.prev_total_amount = this.ctx.helper.formatMoney(item.prev_total_amount, ',', s3 && s3.length || 0);
|
|
|
item.curAuditor = await this.ctx.service.advanceAudit.getAuditorByStatus(item.id, item.status, item.times);
|
|
|
if (item.status === auditConst.status.checkNoPre) {
|
|
|
item.curAuditor2 = await this.ctx.service.advanceAudit.getAuditorByStatus(item.id, auditConst.status.checking);
|