|
@@ -504,37 +504,49 @@ module.exports = app => {
|
|
|
if (g) {
|
|
if (g) {
|
|
|
const list = this._.filter(changeList, { gcl_id: g });
|
|
const list = this._.filter(changeList, { gcl_id: g });
|
|
|
let spamount = 0;
|
|
let spamount = 0;
|
|
|
|
|
+ let positive_amount = 0;
|
|
|
|
|
+ let negative_amount = 0;
|
|
|
let valuation_amount = 0;
|
|
let valuation_amount = 0;
|
|
|
let unvaluation_amount = 0;
|
|
let unvaluation_amount = 0;
|
|
|
let unitPrice = 0;
|
|
let unitPrice = 0;
|
|
|
for (const cl of list) {
|
|
for (const cl of list) {
|
|
|
if (cl.spamount) {
|
|
if (cl.spamount) {
|
|
|
spamount = this.ctx.helper.add(spamount, cl.spamount);
|
|
spamount = this.ctx.helper.add(spamount, cl.spamount);
|
|
|
|
|
+ if (cl.spamount >= 0) {
|
|
|
|
|
+ positive_amount = this.ctx.helper.add(positive_amount, cl.spamount);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ negative_amount = this.ctx.helper.add(negative_amount, cl.spamount);
|
|
|
|
|
+ }
|
|
|
unitPrice = cl.unit_price;
|
|
unitPrice = cl.unit_price;
|
|
|
if (cl.is_valuation) {
|
|
if (cl.is_valuation) {
|
|
|
valuation_amount = this.ctx.helper.add(valuation_amount, cl.spamount);
|
|
valuation_amount = this.ctx.helper.add(valuation_amount, cl.spamount);
|
|
|
} else {
|
|
} else {
|
|
|
unvaluation_amount = this.ctx.helper.add(unvaluation_amount, cl.spamount);
|
|
unvaluation_amount = this.ctx.helper.add(unvaluation_amount, cl.spamount);
|
|
|
}
|
|
}
|
|
|
- // const posOrNePrice = this.ctx.helper.mul(cl.spamount, this.ctx.helper.round(cl.unit_price, up_decimal), tp_decimal);
|
|
|
|
|
- // if (posOrNePrice >= 0) {
|
|
|
|
|
- // positive_tp = this.ctx.helper.add(positive_tp, posOrNePrice);
|
|
|
|
|
- // } else {
|
|
|
|
|
- // negative_tp = this.ctx.helper.add(negative_tp, posOrNePrice);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ const posOrNePrice = this.ctx.helper.mul(cl.spamount, this.ctx.helper.round(cl.unit_price, up_decimal), tp_decimal);
|
|
|
|
|
+ if (posOrNePrice >= 0) {
|
|
|
|
|
+ positive_tp = this.ctx.helper.add(positive_tp, posOrNePrice);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ negative_tp = this.ctx.helper.add(negative_tp, posOrNePrice);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
const price = this.ctx.helper.mul(spamount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal);
|
|
const price = this.ctx.helper.mul(spamount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal);
|
|
|
|
|
+ // 正负数量分别汇总后计算金额,避免相互抵消。
|
|
|
|
|
+ const positive_price = this.ctx.helper.mul(positive_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
|
|
|
|
|
+ const negative_price = this.ctx.helper.mul(negative_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
|
|
|
|
|
+ positive_tp = this.ctx.helper.add(positive_tp, positive_price);
|
|
|
|
|
+ negative_tp = this.ctx.helper.add(negative_tp, negative_price);
|
|
|
const valuation_price = this.ctx.helper.mul(valuation_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
|
|
const valuation_price = this.ctx.helper.mul(valuation_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
|
|
|
const unvaluation_price = this.ctx.helper.mul(unvaluation_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
|
|
const unvaluation_price = this.ctx.helper.mul(unvaluation_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
|
|
|
valuation_tp = this.ctx.helper.add(valuation_tp, valuation_price);
|
|
valuation_tp = this.ctx.helper.add(valuation_tp, valuation_price);
|
|
|
unvaluation_tp = this.ctx.helper.add(unvaluation_tp, unvaluation_price);
|
|
unvaluation_tp = this.ctx.helper.add(unvaluation_tp, unvaluation_price);
|
|
|
total_price = this.ctx.helper.add(total_price, price);
|
|
total_price = this.ctx.helper.add(total_price, price);
|
|
|
- if (price >= 0) {
|
|
|
|
|
- positive_tp = this.ctx.helper.accAdd(positive_tp, price);
|
|
|
|
|
- } else {
|
|
|
|
|
- negative_tp = this.ctx.helper.accAdd(negative_tp, price);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (price >= 0) {
|
|
|
|
|
+ // positive_tp = this.ctx.helper.accAdd(positive_tp, price);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // negative_tp = this.ctx.helper.accAdd(negative_tp, price);
|
|
|
|
|
+ // }
|
|
|
} else {
|
|
} else {
|
|
|
const list = this._.filter(changeList, { gcl_id: g });
|
|
const list = this._.filter(changeList, { gcl_id: g });
|
|
|
for (const cl of list) {
|
|
for (const cl of list) {
|