Просмотр исходного кода

成本分配表、结算单调整

huxy 3 дней назад
Родитель
Сommit
f810e8e1eb

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/entity/SyCostAllocation.java

@@ -266,4 +266,20 @@ public class SyCostAllocation implements Serializable {
     //标记(B)数量
     private java.math.BigDecimal signNumB;
 
+    //记录销售订单汇率
+    @TableField(exist = false)
+    private BigDecimal exchangeRate2;
+
+    //标记有不含税美元
+    @TableField(exist = false)
+    private String signNumUS;
+
+    //标识
+    @TableField(exist = false)
+    private String usType;
+
+    //面料不含税成本人民币差值
+    private java.math.BigDecimal rmbDifference;
+    //面料不含税美元差值
+    private java.math.BigDecimal usDifference;
 }

+ 5 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationMapper.xml

@@ -585,9 +585,9 @@
 
     <select id="queryPurBillVouchByFabric" resultType="org.jeecg.modules.cost.entity.SyCostAllocation">
 
-        select t.cInvName,
+         select  t.cInvName,exchangeRate,hl2 exchangeRate2,
         sum(t.iOriSum) as fabriccostIncludestax,sum(t.iNotOriMoney) as fabriccostNotincludestax, sum(t.cExchRate) as fabriccostIncludestaxUsd,sum(t.invoiceQuantity) as invoiceQuantity from (
-        select omi.cInvName as cInvName,
+        select omi.cInvName as cInvName,max(pb.cExchRate) exchangeRate,max(pm.nflat)hl2,
         /*人民币含税金额取本币含税金额*/
         SUM(pbs.iSum) as iOriSum,
         /*人民币不含税金额 美元税率设置为0*/
@@ -608,7 +608,7 @@
         group by omi.cInvName
         UNION ALL
 
-        select omi.cInvName as cInvName,
+        select omi.cInvName as cInvName,max(pb.cExchRate) exchangeRate,max(pm.nflat)hl2,
         /*人民币含税金额*/
         SUM(pbs.iSum) as iOriSum,
         /*人民币不含税金额 美元税率设置为0*/
@@ -627,7 +627,7 @@
         and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
         group by omi.cInvName
         UNION ALL
-        select omi.cInvName as cInvName,
+        select omi.cInvName as cInvName,max(pb.cExchRate) exchangeRate,max(pm.nflat)hl2,
         /*人民币含税金额*/
         SUM(pbs.iSum) as iOriSum,
         /*人民币不含税金额 美元税率设置为0*/
@@ -645,7 +645,7 @@
         where pm.cPOID like CONCAT('%',#{code},'%') and (omi.cInvCcode like '03%' or omi.cInvCcode like '04%') and omi.cInvCCode != '0399' and omi.cInvCCode != '0499' and omi.cInvCCode != '0299'
         and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
         group by omi.cInvName
-        ) t where t.iOriSum is not null group by t.cInvName
+        ) t where t.iOriSum is not null group by t.cInvName,exchangeRate,hl2
     </select>
 
     <select id="querySalerIauantity" resultType="org.jeecg.modules.cost.entity.SyCostAllocation">

+ 14 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java

@@ -489,6 +489,10 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
         BigDecimal notincludestaxTotal = BigDecimal.ZERO;
         //合计面料成本美元
         BigDecimal includestaxTotal = BigDecimal.ZERO;
+        //汇率
+        BigDecimal exchangeRate = BigDecimal.ZERO;
+        //汇率
+        String signNumUS ="rmb";
         System.out.println("fabriccostIncludestaxUsd1\t"+syCostAllocation.getFabriccostIncludestaxUsd());
         syCostAllocation.setTaxrate2(new BigDecimal("13"));
         if(syCostAllocation.getFabriccostIncludestaxUsd()!=null){
@@ -501,9 +505,14 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
         System.out.println("国内加工单\t"+orderType+"\t面料含税成本美元\t"+syCostAllocation.getFabriccostIncludestaxUsd());
         System.out.println("fabriccostIncludestax集合\t"+fabriccostIncludestax);
+        System.out.println("人民币\t"+signNumUS);
         if(/*!orderType.equals("国外加工单")||*/ /*syCostAllocation.getFabriccostIncludestaxUsd()==null*/ fabriccostIncludestax!=null){
             if(fabriccostIncludestax.size()!=0){
                 for(SyCostAllocation str : fabriccostIncludestax){
+                    if (str.getExchangeRate().compareTo(str.getExchangeRate2())!=0){
+                        signNumUS="us";
+                    }
+                    System.out.println("美元\t"+signNumUS);
                     for(SyCostAllocationFabric li:list3){
                         String goodsName=li.getGoodsName();
                         if (goodsName.indexOf("--")!=-1){
@@ -518,6 +527,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 //                        System.out.println("getFabriccostIncludestax "+str.getFabriccostIncludestax()+" getFabriccostNotincludestax "+str.getFabriccostNotincludestax()
 //                                +"getFabriccostIncludestaxUsd"+str.getFabriccostIncludestaxUsd()+" getInvoiceQuantity "+str.getInvoiceQuantity()+" quantity "+quantity);
                             if (str.getInvoiceQuantity().compareTo(quantity)!=0){
+                                exchangeRate=str.getExchangeRate();//汇率
                                 BigDecimal money = str.getFabriccostIncludestax().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
                                 BigDecimal num = money.multiply(quantity);
                                 usageQuantityTotal = usageQuantityTotal.add(num);
@@ -550,17 +560,19 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                 }
 //                System.out.println("面料含税人民币2\t"+usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
 //                System.out.println("实际总金额2\t"+usageQuantityTotal);
-
+                System.out.println("人民币面料成本notincludestaxTotal\t"+notincludestaxTotal);
                 if (syCostAllocation.getFabriccostIncludestax()!=null){
                     syCostAllocation.setFabriccostIncludestax(syCostAllocation.getFabriccostIncludestax().add(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP)));
                 }else{
                     syCostAllocation.setFabriccostIncludestax(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
                 }
+                System.out.println("人民币面料成本1\t"+syCostAllocation.getFabriccostNotincludestax());
                 if (syCostAllocation.getFabriccostNotincludestax()!=null){
                     syCostAllocation.setFabriccostNotincludestax(syCostAllocation.getFabriccostNotincludestax().add(notincludestaxTotal));
                 }else{
                     syCostAllocation.setFabriccostNotincludestax(notincludestaxTotal);
                 }
+                System.out.println("人民币面料成本2\t"+syCostAllocation.getFabriccostNotincludestax());
                 System.out.println("includestaxTotal\t"+includestaxTotal+"  getFabriccostIncludestaxUsd  "+syCostAllocation.getFabriccostIncludestaxUsd());
                 if (syCostAllocation.getFabriccostIncludestaxUsd()!=null){
                     syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().add(includestaxTotal));
@@ -579,6 +591,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                 }
             }
         }
+        syCostAllocation.setSignNumUS(signNumUS);//标识
 //        }
 
         long startTime3 = System.currentTimeMillis();

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/controller/SyShippingDetailsController.java

@@ -1671,7 +1671,7 @@ public class SyShippingDetailsController extends JeecgController<SyShippingDetai
 				 }
 
 				 li.setIsTcName("否");
-				 if (li.getIsTc().equals("0")){
+				 if (li.getIsTc().equals("1")){
 					 li.setIsTcName("是");
 				 }
 

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/SyPackingListTailoringMapper.java

@@ -101,4 +101,6 @@ public interface SyPackingListTailoringMapper extends BaseMapper<SyPackingListTa
     void updateTimeStatus();
 
     Map<String, Object> getAccount2(@Param("params1")String params1,@Param("params2") String params2);
+
+    public String getCvenCode(@Param("account")String account,@Param("documentNo")String documentNo);
 }

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/xml/syPackingListTailoringMapper.xml

@@ -280,6 +280,12 @@
         where  ${orderName}
     </select>
 
+    <select id="getCvenCode" parameterType="java.lang.String" resultType="java.lang.String">
+        select cVenCode
+        from UFDATA_${account}_2021.dbo.PurBillVouch
+        where cpbvcode=#{documentNo}
+    </select>
+
     <select id="getOmOrPoItem" parameterType="java.lang.String" resultType="java.util.HashMap">
         select  iMoney,iNatUnitPrice, iTaxPrice ,iPerTaxRate ,iNatMoney,iorderdid as iSOsID,${id} as id,inum,iUnitPrice   from ${tableName} where  ${orderName}
     </select>

+ 23 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringServiceImpl.java

@@ -2177,7 +2177,7 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 		List<String> codes=getList(listTailorings,account,maps.get("isAhaa").toString());//获取出库单号
 //		System.out.println("account   "+account+"   入库单codes  "+codes);
 		if(codes.size()==0){
-			getList4(listTailorings);//获取入库单号
+			getList4(account,listTailorings);//获取入库单号
 			return "无可推送数据!";
 		}
 		Map<String,List<String>> customers=getSuppliers(listTailorings);//key:供应商编码,value:出库单单据号
@@ -2469,17 +2469,36 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 		}
 	}
 
-	public List<String> getList4(List<SyPackingListTailoring> listFabrics){
+	public List<String> getList4(String account,List<SyPackingListTailoring> listFabrics){
 		List<String> ids=new ArrayList<>();//获取出库单号
 		JSONArray jsonArrays2=new JSONArray();
+//		if (account.equals("103")){
+//			return new ArrayList<>();
+//		}
 		Map<String,List<SyPackingListTailoring>> codeMaps=new HashMap<>();//key:传入销售发票单id,value:主表数据
 		for (SyPackingListTailoring packingListTailoring : listFabrics){
 			String code=packingListTailoring.getSaleInvoiceCode();
 			String error=packingListTailoring.getSaleInvoiceError2();
 			System.out.println("code\t"+code);
 			System.out.println("error\t"+error);
-			if(code!=null&&code.indexOf("101采购发票")>-1&&code.indexOf("101结算单")==-1&&error!=null &&error.indexOf("结算单")>-1){
-				String documentNo=code.substring(code.indexOf("101采购发票单号")+9,code.indexOf("101采购发票单号")+20);
+			String cvenCode="";//供应商编码
+
+			if(code.indexOf(account+"采购")>-1){
+				String documentNo="";
+				documentNo=code.substring(code.indexOf(account+"采购发票单号")+9,code.indexOf(account+"采购发票单号")+20);
+				cvenCode =syPackingListTailoringMapper.getCvenCode(account,documentNo);
+			}
+
+			if(code!=null&& (code.indexOf("101采购发票")>-1&&account.equals("101")&&(cvenCode.equals("T010001")||cvenCode.equals("T030001"))
+					||code.indexOf("102采购发票")>-1&&account.equals("102")&&cvenCode.equals("T020001")
+					||code.indexOf("101委外发票")>-1)&&account.equals("101")
+					&&code.indexOf(account+"结算单")==-1){
+				String documentNo="";
+				if (code.indexOf(account+"委外发票")>-1){
+					documentNo=code.substring(code.indexOf(account+"委外发票单号")+9,code.indexOf(account+"委外发票单号")+20);
+				}else{
+					documentNo=code.substring(code.indexOf(account+"采购发票单号")+9,code.indexOf(account+"采购发票单号")+20);
+				}
 				if (!ids.contains(documentNo)){
 					List<SyPackingListTailoring> fabricList=new ArrayList<>();
 					fabricList.add(packingListTailoring);