|
@@ -1139,12 +1139,8 @@ let generateStep3Form = (p = {}) => {
|
|
})
|
|
})
|
|
|
|
|
|
if (n <= 2) {
|
|
if (n <= 2) {
|
|
- temp.cn_freight_cost = savePrecision(
|
|
|
|
- mathjs
|
|
|
|
- .chain(i[`cn_price_${n}`])
|
|
|
|
- .multiply(setting.value.rate_rmb_aud)
|
|
|
|
- .done(),
|
|
|
|
- )
|
|
|
|
|
|
+ console.log(i, 'i')
|
|
|
|
+ temp.cn_freight_cost = savePrecision(i[`cn_price_${n}`]) // 这个是人民币
|
|
|
|
|
|
temp.local_freight_cost = savePrecision(i[`city_price_${n}`]).toFixed(
|
|
temp.local_freight_cost = savePrecision(i[`city_price_${n}`]).toFixed(
|
|
2,
|
|
2,
|
|
@@ -1155,7 +1151,13 @@ let generateStep3Form = (p = {}) => {
|
|
temp.freight_cost = mathjs
|
|
temp.freight_cost = mathjs
|
|
.chain(i[`midway_price_${n}`])
|
|
.chain(i[`midway_price_${n}`])
|
|
.add(i[`city_price_${n}`])
|
|
.add(i[`city_price_${n}`])
|
|
- .add(i[`cn_price_${n}`])
|
|
|
|
|
|
+ .add(
|
|
|
|
+ mathjs
|
|
|
|
+ .chain(i[`cn_price_${n}`])
|
|
|
|
+ .divide(setting.value.rate_rmb_aud)
|
|
|
|
+ .done(),
|
|
|
|
+ )
|
|
|
|
+
|
|
.done()
|
|
.done()
|
|
.toFixed(2)
|
|
.toFixed(2)
|
|
// 用demo默认值是重新计算的数据. 如果是初始化时需要用保存到数据库的数据覆盖掉这个.
|
|
// 用demo默认值是重新计算的数据. 如果是初始化时需要用保存到数据库的数据覆盖掉这个.
|
|
@@ -1542,9 +1544,15 @@ let calcTaxFee = (form: any) => {
|
|
mathjs.chain(form.product_cost).multiply(form.tax).divide(100).done(),
|
|
mathjs.chain(form.product_cost).multiply(form.tax).divide(100).done(),
|
|
).toFixed(2)
|
|
).toFixed(2)
|
|
}
|
|
}
|
|
|
|
+// 利润 = 售卖总价 - setup cost - add freight cost - 总成本
|
|
let calcProfit = (form: any) => {
|
|
let calcProfit = (form: any) => {
|
|
form.profit = savePrecision(
|
|
form.profit = savePrecision(
|
|
- mathjs.chain(form.sold_price).subtract(form.total_cost).done(),
|
|
|
|
|
|
+ mathjs
|
|
|
|
+ .chain(form.sold_price)
|
|
|
|
+ .subtract(form.setup_cost)
|
|
|
|
+ .subtract(form.add_freight_cost)
|
|
|
|
+ .subtract(form.total_cost)
|
|
|
|
+ .done(),
|
|
).toFixed(2)
|
|
).toFixed(2)
|
|
}
|
|
}
|
|
let calcProfitMargin = (form: any) => {
|
|
let calcProfitMargin = (form: any) => {
|
|
@@ -1570,13 +1578,15 @@ let calcTotalCost = (form: any) => {
|
|
.toFixed(2)
|
|
.toFixed(2)
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
- * 用利润率计算售价总价
|
|
|
|
|
|
+ * 用利润率计算售价总价. 总成本 * (利润率 + 100) / 100 + setup cost + add freight cost
|
|
**/
|
|
**/
|
|
let calcSoldPriceByProfitMargin = (form: any) => {
|
|
let calcSoldPriceByProfitMargin = (form: any) => {
|
|
form.sold_price = savePrecision(
|
|
form.sold_price = savePrecision(
|
|
mathjs
|
|
mathjs
|
|
.chain(form.total_cost)
|
|
.chain(form.total_cost)
|
|
.multiply(mathjs.chain(form.profit_margin).add(100).divide(100).done())
|
|
.multiply(mathjs.chain(form.profit_margin).add(100).divide(100).done())
|
|
|
|
+ .add(form.setup_cost)
|
|
|
|
+ .add(form.add_freight_cost)
|
|
.done(),
|
|
.done(),
|
|
).toFixed(2)
|
|
).toFixed(2)
|
|
}
|
|
}
|