5 天以前 9bb07cede2c66972526ee3ace524991570c1a31c
fix(account): 修复出库金额计算中的除零错误

- 在AccountInvoiceApplicationMapper.xml中添加单量为零的检查
- 在AccountSalesCollectionMapper.xml中实现安全的除法运算
- 在CustomerMapper.xml的两个查询中增加零值保护逻辑
- 在StockOutRecordMapper.xml中统一金额计算方式
- 使用IFNULL和NULLIF函数防止数据库计算异常
已修改4个文件
10 ■■■■ 文件已修改
src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/basic/CustomerMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockOutRecordMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
@@ -36,7 +36,7 @@
        p.product_name,
        pm.model as specification_model,
        slp.tax_rate,
        sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
        sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1) as outboundAmount,
        s.shipping_no,
        sl.sales_contract_no
        FROM stock_out_record sor
src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
@@ -65,7 +65,7 @@
        p.product_name,
        pm.model as specification_model,
        slp.tax_rate,
        sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
        sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1) as outboundAmount,
        s.shipping_no,
        sl.sales_contract_no
        FROM stock_out_record sor
src/main/resources/mapper/basic/CustomerMapper.xml
@@ -118,7 +118,7 @@
        left join (
            SELECT
                sl.customer_id,
                sum(sor.stock_out_num * slp.tax_inclusive_unit_price) as outboundAmount
                sum(sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1)) as outboundAmount
            FROM stock_out_record sor
            LEFT join shipping_info s on sor.record_id = s.id
            LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
@@ -169,7 +169,7 @@
        left join (
            SELECT
                sl.id,
                sum(sor.stock_out_num * slp.tax_inclusive_unit_price) as outboundAmount
                sum(sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1)) as outboundAmount
            FROM stock_out_record sor
                     left join shipping_info s on sor.record_id = s.id
                     LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -101,7 +101,7 @@
        p.product_name,
        pm.model as specification_model,
        slp.tax_rate,
        sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
        sor.stock_out_num * slp.tax_inclusive_unit_price / IFNULL(NULLIF(slp.single_quantity, 0), 1) as outboundAmount,
        s.shipping_no,
        sl.sales_contract_no
        FROM stock_out_record sor