doc/20260608_add_freight_fields_to_sales_ledger_product.sql
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,7 @@ alter table sales_ledger_product add freight_unit_price decimal(16, 2) null comment 'è¿è´¹åä»·' after tax_inclusive_total_price, add total_freight decimal(16, 2) null comment 'æ»è¿è´¹' after freight_unit_price; alter table sales_ledger_product_template add freight_unit_price decimal(16, 2) null comment 'è¿è´¹åä»·' after tax_inclusive_total_price, add total_freight decimal(16, 2) null comment 'æ»è¿è´¹' after freight_unit_price; src/main/java/com/ruoyi/common/utils/FreightUtils.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,33 @@ package com.ruoyi.common.utils; import com.ruoyi.sales.pojo.SalesLedgerProduct; import java.math.BigDecimal; import java.math.RoundingMode; /** * è¿è´¹è®¡ç®å·¥å ·ç±» */ public class FreightUtils { private FreightUtils() { // ç§ææé 彿°ï¼é²æ¢å®ä¾å } /** * è®¡ç®æ»è¿è´¹ * æ»è¿è´¹ = æ°é à è¿è´¹åä»· * * @param product 产åä¿¡æ¯ */ public static void fillFreightAmount(SalesLedgerProduct product) { if (product == null) { return; } if (product.getQuantity() == null || product.getFreightUnitPrice() == null) { product.setTotalFreight(null); return; } product.setTotalFreight(product.getQuantity().multiply(product.getFreightUnitPrice()).setScale(2, RoundingMode.HALF_UP)); } } src/main/java/com/ruoyi/purchase/dto/PurchaseLedgerProductImportDto.java
@@ -69,6 +69,18 @@ private BigDecimal taxInclusiveTotalPrice; /** * è¿è´¹åä»· */ @Excel(name = "è¿è´¹åä»·") private BigDecimal freightUnitPrice; /** * æ»è¿è´¹ */ @Excel(name = "æ»è¿è´¹") private BigDecimal totalFreight; /** * å票类å */ @Excel(name = "å票类å") src/main/java/com/ruoyi/purchase/pojo/SalesLedgerProductTemplate.java
@@ -59,6 +59,12 @@ @Schema(description = "å«ç¨æ»ä»·") private BigDecimal taxInclusiveTotalPrice; @Schema(description = "è¿è´¹åä»·") private BigDecimal freightUnitPrice; @Schema(description = "æ»è¿è´¹") private BigDecimal totalFreight; @Schema(description = "ä¸å«ç¨æ»ä»·") private BigDecimal taxExclusiveTotalPrice; src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -27,6 +27,7 @@ import com.ruoyi.common.enums.ReviewStatusEnum; import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.FreightUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; @@ -678,6 +679,7 @@ // æ§è¡æ´æ°æä½ if (!updateList.isEmpty()) { for (SalesLedgerProduct product : updateList) { FreightUtils.fillFreightAmount(product); product.setType(ledgerType); salesLedgerProductMapper.updateById(product); } @@ -685,6 +687,7 @@ // æ§è¡æå ¥æä½ if (!insertList.isEmpty()) { for (SalesLedgerProduct salesLedgerProduct : insertList) { FreightUtils.fillFreightAmount(salesLedgerProduct); salesLedgerProduct.setType(ledgerType); Date entryDate = purchaseLedger.getEntryDate(); @@ -974,6 +977,7 @@ for (PurchaseLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) { SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct(); BeanUtils.copyProperties(salesLedgerProductImportDto, salesLedgerProduct); FreightUtils.fillFreightAmount(salesLedgerProduct); salesLedgerProduct.setSalesLedgerId(salesLedger.getId()); salesLedgerProduct.setType(2); // 计ç®ä¸å«ç¨æ»ä»· src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java
@@ -62,6 +62,18 @@ private BigDecimal taxInclusiveTotalPrice; /** * è¿è´¹åä»· */ @Excel(name = "è¿è´¹åä»·") private BigDecimal freightUnitPrice; /** * æ»è¿è´¹ */ @Excel(name = "æ»è¿è´¹") private BigDecimal totalFreight; /** * å票类å */ @Excel(name = "å票类å") src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
@@ -87,6 +87,18 @@ private BigDecimal taxInclusiveTotalPrice; /** * è¿è´¹åä»· */ @Excel(name = "è¿è´¹åä»·") private BigDecimal freightUnitPrice; /** * æ»è¿è´¹ */ @Excel(name = "æ»è¿è´¹") private BigDecimal totalFreight; /** * ä¸å«ç¨æ»ä»· */ @Excel(name = "ä¸å«ç¨æ»ä»·") src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.framework.web.domain.R; import com.ruoyi.common.utils.FreightUtils; import com.ruoyi.procurementrecord.utils.StockUtils; import com.ruoyi.production.mapper.*; import com.ruoyi.production.pojo.ProductionPlan; @@ -165,7 +166,7 @@ @Override @Transactional(rollbackFor = Exception.class) public int addOrUpdateSalesLedgerProduct(SalesLedgerProduct salesLedgerProduct) { FreightUtils.fillFreightAmount(salesLedgerProduct); int result; Long salesLedgerId = salesLedgerProduct.getSalesLedgerId(); if (salesLedgerProduct.getId() == null) { src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -22,10 +22,7 @@ import com.ruoyi.common.enums.FileNameType; import com.ruoyi.common.enums.SaleEnum; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.EnumUtil; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.*; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.security.LoginUser; import com.ruoyi.framework.web.domain.AjaxResult; @@ -402,6 +399,7 @@ for (SalesLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) { SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct(); BeanUtils.copyProperties(salesLedgerProductImportDto, salesLedgerProduct); FreightUtils.fillFreightAmount(salesLedgerProduct); salesLedgerProduct.setSalesLedgerId(salesLedger.getId()); salesLedgerProduct.setType(1); // 计ç®ä¸å«ç¨æ»ä»· @@ -616,6 +614,7 @@ // æ§è¡æ´æ°æä½ if (!updateList.isEmpty()) { for (SalesLedgerProduct product : updateList) { FreightUtils.fillFreightAmount(product); product.setType(type.getCode()); salesLedgerProductMapper.updateById(product); } @@ -623,6 +622,7 @@ // æ§è¡æå ¥æä½ if (!insertList.isEmpty()) { for (SalesLedgerProduct salesLedgerProduct : insertList) { FreightUtils.fillFreightAmount(salesLedgerProduct); salesLedgerProduct.setType(type.getCode()); salesLedgerProductMapper.insert(salesLedgerProduct); // æ·»å çäº§æ°æ® src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -14,6 +14,8 @@ T1.tax_rate, T1.tax_inclusive_unit_price, T1.tax_inclusive_total_price, T1.freight_unit_price, T1.total_freight, T1.tax_exclusive_total_price, T1.invoice_type, T1.type,