fix(payable): 修复应付与库存更新字段被清空问题
- 合并收款对话框补充传递订单税率,确保前端税率数据完整 - 应付账单服务调整税率取值逻辑,避免默认税率覆盖订单税率 - 库存信息更新时对授权码和应付单号保留原值,防止部分更新误清空cp_1.0.0
parent
e6ce4865c8
commit
042588a49d
|
|
@ -317,6 +317,7 @@ export default {
|
|||
payableOrders: this.payableOrdersWithPlans.map(order => ({
|
||||
id: order.id,
|
||||
payableBillCode: order.payableBillCode,
|
||||
taxRate: order.taxRate,
|
||||
ticketPlans: order.ticketPlans.map(plan => ({
|
||||
planTicketDate: plan.planTicketDate,
|
||||
planAmount: plan.planAmount,
|
||||
|
|
|
|||
|
|
@ -231,14 +231,15 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
|||
// Fetch bills once
|
||||
Date minPaymentDate = DateUtils.getNowDate();
|
||||
for (PayableOrderDto order : dto.getPayableOrders()) {
|
||||
BigDecimal taxRate = order.getTaxRate();
|
||||
if (taxRate == null || taxRate.compareTo(BigDecimal.ZERO) < 0) {
|
||||
// 如果税率为空或小于0,则默认为0
|
||||
taxRate = new BigDecimal(defaultTax);
|
||||
}
|
||||
for (OmsPayablePaymentPlan plan : order.getPaymentPlans()) {
|
||||
minPaymentDate = minPaymentDate.after(plan.getPlanPaymentDate()) ? plan.getPlanPaymentDate() : minPaymentDate;
|
||||
// 计算每个 plan 的未税金额 = planAmount / (1 + 税率),保留两位小数
|
||||
BigDecimal taxRate = order.getTaxRate();
|
||||
if (taxRate == null || taxRate.compareTo(BigDecimal.ZERO) < 0) {
|
||||
// 如果税率为空或小于0,则默认为0
|
||||
taxRate = new BigDecimal(defaultTax);
|
||||
}
|
||||
|
||||
// 计算未税金额 = planAmount / (1 + 税率)
|
||||
BigDecimal divisor = BigDecimal.ONE.add(taxRate);
|
||||
BigDecimal planWithoutTax = plan.getPlanAmount().divide(divisor, 2, java.math.RoundingMode.HALF_UP);
|
||||
|
|
@ -344,15 +345,14 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
|||
Date minTicketDate = DateUtils.getNowDate();
|
||||
// Fetch bills once
|
||||
for (PayableOrderReceiptDto order : dto.getPayableOrders()) {
|
||||
|
||||
BigDecimal taxRate = order.getTaxRate();
|
||||
if (taxRate == null || taxRate.compareTo(BigDecimal.ZERO) < 0) {
|
||||
// 如果税率为空或小于0,则默认为0
|
||||
taxRate = new BigDecimal(defaultTax);
|
||||
}
|
||||
for (OmsPayableTicketPlan plan : order.getTicketPlans()) {
|
||||
minTicketDate = minTicketDate.after(plan.getPlanTicketDate()) ? plan.getPlanTicketDate() : minTicketDate;
|
||||
// 计算每个 plan 的未税金额 = planAmount / (1 + 税率),保留两位小数
|
||||
BigDecimal taxRate = order.getTaxRate();
|
||||
if (taxRate == null || taxRate.compareTo(BigDecimal.ZERO) < 0) {
|
||||
// 如果税率为空或小于0,则默认为0
|
||||
taxRate = new BigDecimal(defaultTax);
|
||||
}
|
||||
// 计算未税金额 = planAmount / (1 + 税率)
|
||||
BigDecimal divisor = BigDecimal.ONE.add(taxRate);
|
||||
BigDecimal planWithoutTax = plan.getPlanAmount().divide(divisor, 2, java.math.RoundingMode.HALF_UP);
|
||||
|
|
|
|||
|
|
@ -199,11 +199,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
, #{item.warehouseId}, #{item.innerPrice}, #{item.outerPrice}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime},#{item.payableBillCode},#{item.taxRate},#{item.orderCode})
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
license_key = VALUES(license_key),
|
||||
<!-- 发货等只更新部分字段的调用方不传授权码/应付单号,避免把库存原值清空(传空即保留原值) -->
|
||||
license_key = COALESCE(NULLIF(VALUES(license_key), ''), license_key),
|
||||
inventory_status = VALUES(inventory_status),
|
||||
outer_code = VALUES(outer_code),
|
||||
outer_price = VALUES(outer_price),
|
||||
payable_bill_code = VALUES(payable_bill_code),
|
||||
payable_bill_code = COALESCE(NULLIF(VALUES(payable_bill_code), ''), payable_bill_code),
|
||||
update_by = VALUES(update_by),
|
||||
update_time = now(),
|
||||
order_code = VALUES(order_code)
|
||||
|
|
|
|||
Loading…
Reference in New Issue