|
@@ -24,7 +24,7 @@ module.exports = app => {
|
|
|
|
|
|
async getStageData(sid) {
|
|
|
const data = await this.getAllDataByCondition({where: { sid: sid }});
|
|
|
- if (this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
|
|
|
+ if (this.ctx.stage && this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
|
|
|
for (const d of data) {
|
|
|
const his = d.shistory ? JSON.parse(d.shistory) : [];
|
|
|
const h = this.ctx.helper._.find(his, {
|
|
@@ -125,27 +125,29 @@ module.exports = app => {
|
|
|
const nd = {id: od.id};
|
|
|
if (d.name) nd.name = d.name;
|
|
|
if (od.pre_used === null || od.pre_used === undefined || od.pre_used === 0) {
|
|
|
- if (d.unit) nd.unit = d.unit;
|
|
|
- nd.unit_price = d.unit_price ? this.ctx.helper.round(d.unit_price, info.decimal.up) : od.unit_price;
|
|
|
+ if (d.unit !== undefined) nd.unit = d.unit;
|
|
|
+ nd.unit_price = d.unit_price !== undefined ? this.ctx.helper.round(d.unit_price, info.decimal.up) : od.unit_price;
|
|
|
+ } else {
|
|
|
+ nd.unit_price = od.unit_price;
|
|
|
}
|
|
|
const precision = this.ctx.helper.findPrecision(info.precision, d.unit_price);
|
|
|
- if (d.arrive_qty) {
|
|
|
+ if (d.arrive_qty !== undefined) {
|
|
|
nd.arrive_qty = this.ctx.helper.round(d.arrive_qty, precision.value);
|
|
|
nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, info.decimal.tp);
|
|
|
- } else if (d.unit_price) {
|
|
|
+ } else if (d.unit_price !== undefined) {
|
|
|
nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, od.arrive_qty, info.decimal.tp);
|
|
|
}
|
|
|
- if (d.deduct_qty) {
|
|
|
+ if (d.deduct_qty !== undefined) {
|
|
|
nd.deduct_qty = this.ctx.helper.round(d.deduct_qty, precision.value);
|
|
|
nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, info.decimal.tp);
|
|
|
- } else if (d.unit_price) {
|
|
|
+ } else if (d.unit_price !== undefined) {
|
|
|
nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, od.deduct_qty, info.decimal.tp);
|
|
|
}
|
|
|
- if (d.source) nd.source = d.source;
|
|
|
- if (d.bills_code) nd.bills_code = d.bills_code;
|
|
|
- if (d.check_code) nd.check_code = d.check_code;
|
|
|
- if (d.memo) nd.memo = d.memo;
|
|
|
- if (d.order) nd.order = d.order;
|
|
|
+ if (d.source !== undefined) nd.source = d.source;
|
|
|
+ if (d.bills_code !== undefined) nd.bills_code = d.bills_code;
|
|
|
+ if (d.check_code !== undefined) nd.check_code = d.check_code;
|
|
|
+ if (d.memo !== undefined) nd.memo = d.memo;
|
|
|
+ if (d.order !== undefined) nd.order = d.order;
|
|
|
uDatas.push(nd);
|
|
|
}
|
|
|
if (uDatas.length > 0) {
|