|
@@ -18,6 +18,7 @@ import com.fjhx.account.entity.account.vo.AccountRequestFundsDetailVo;
|
|
|
import com.fjhx.account.entity.account.vo.AccountRunningWaterVo;
|
|
|
import com.fjhx.account.entity.tax.po.TaxRefundDetails;
|
|
|
import com.fjhx.account.service.account.AccountManagementService;
|
|
|
+import com.fjhx.account.service.account.AccountPaymentService;
|
|
|
import com.fjhx.account.service.account.AccountRequestFundsDetailService;
|
|
|
import com.fjhx.account.service.tax.TaxRefundDetailsService;
|
|
|
import com.fjhx.area.service.SetCustomizeAreaId;
|
|
@@ -48,6 +49,8 @@ import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
|
|
|
import com.fjhx.purchase.entity.purchase.vo.PurchaseDetailVo;
|
|
|
import com.fjhx.purchase.entity.quality.po.QualityDetail;
|
|
|
import com.fjhx.purchase.service.arrival.ArrivalDetailService;
|
|
|
+import com.fjhx.purchase.service.pay.PayDetailService;
|
|
|
+import com.fjhx.purchase.service.pay.PayService;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseDetailService;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
|
import com.fjhx.purchase.service.quality.QualityDetailService;
|
|
@@ -63,6 +66,7 @@ import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractProject;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractShipment;
|
|
|
import com.fjhx.sale.entity.contract.vo.*;
|
|
|
+import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
|
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductVo;
|
|
|
import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
|
|
|
import com.fjhx.sale.mapper.contract.ContractMapper;
|
|
@@ -72,6 +76,7 @@ import com.fjhx.sale.service.contract.ContractProjectService;
|
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
|
import com.fjhx.sale.service.contract.ContractShipmentService;
|
|
|
import com.fjhx.sale.service.purchase.EhsdPurchaseProductService;
|
|
|
+import com.fjhx.sale.service.purchase.EhsdPurchaseService;
|
|
|
import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
|
import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
@@ -139,6 +144,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
private EhsdPurchaseProductService ehsdPurchaseProductService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private EhsdPurchaseService ehsdPurchaseService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private PurchaseDetailService purchaseDetailService;
|
|
|
|
|
|
@Autowired
|
|
@@ -180,6 +188,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Autowired
|
|
|
private TaxRefundDetailsService taxRefundDetailsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PayDetailService payDetailService;
|
|
|
+
|
|
|
/**
|
|
|
* 合同和样品单 下拉分页
|
|
|
*/
|
|
@@ -364,9 +375,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
Map<Long, String> ehsdAmountMap = ehsdAmountList.stream().collect(Collectors.toMap(EhsdPurchaseProductVo::getContractId, EhsdPurchaseProductVo::getCurrencyAmount));
|
|
|
List<PurchaseDetailVo> otherAmountList = purchaseDetailService.getSumCountInDataResourceIds(contractIds);
|
|
|
Map<Long, String> otherAmountMap = otherAmountList.stream().collect(Collectors.toMap(PurchaseDetailVo::getDataResourceId, PurchaseDetailVo::getSumAmountCurrency));
|
|
|
- //通过合同ID查询到退税数据
|
|
|
- List<TaxRefundDetails> refundDetails = taxRefundDetailsService.getSumMoneyByContractIds(contractIds);
|
|
|
- Map<Long,List<TaxRefundDetails>> refundDetailsMap = refundDetails.stream().collect(Collectors.groupingBy(TaxRefundDetails::getContractId));
|
|
|
+// //通过合同ID查询到退税数据
|
|
|
+// List<TaxRefundDetails> refundDetails = taxRefundDetailsService.getSumMoneyByContractIds(contractIds);
|
|
|
+// Map<Long,List<TaxRefundDetails>> refundDetailsMap = refundDetails.stream().collect(Collectors.groupingBy(TaxRefundDetails::getContractId));
|
|
|
|
|
|
//取出默认汇率
|
|
|
// List<CurrencyRate> currencyRateList = currencyRateService.getList();
|
|
@@ -394,23 +405,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
(v.getInspectionRedPack() == null ? BigDecimal.ZERO : v.getInspectionRedPack().multiply(new BigDecimal(map.getOrDefault(v.getInspectionRedPackCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
(v.getCommission() == null ? BigDecimal.ZERO : v.getCommission().multiply(new BigDecimal(map.getOrDefault(v.getCommissionCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
(v.getOther() == null ? BigDecimal.ZERO : v.getOther().multiply(new BigDecimal(map.getOrDefault(v.getOtherCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
- (v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount()).add
|
|
|
- (v.getOtherSumAmount() == null ? BigDecimal.ZERO : v.getOtherSumAmount()));
|
|
|
- /**
|
|
|
- * 处理退税金额
|
|
|
- */
|
|
|
- List<TaxRefundDetails> rList = refundDetailsMap.getOrDefault(v.getContractId(),null);
|
|
|
- if(CollectionUtils.isNotEmpty(rList)){
|
|
|
- BigDecimal taxReturnMoney = rList.stream().map(taxRefundDetails -> {
|
|
|
- //获取汇率
|
|
|
- BigDecimal rate = map.getOrDefault(taxRefundDetails.getCurrency(), BigDecimal.ONE);
|
|
|
- // 获取认领金额
|
|
|
- BigDecimal money = taxRefundDetails.getAmount();
|
|
|
- // 返回兑人民币后金额
|
|
|
- return rate.multiply(money);
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- v.setRefundableAmount(taxReturnMoney);
|
|
|
- }
|
|
|
+ (v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount())
|
|
|
+ );
|
|
|
+ //处理退税金额
|
|
|
+ handleRefundTax(v);
|
|
|
v.setRmbContractAmount(v.getAmount().multiply(new BigDecimal(map.getOrDefault(v.getCurrency(), BigDecimal.ONE).toString())));
|
|
|
//计算收入总计=合同金额(转人民币)+应退税金额(转人民币)
|
|
|
v.setIncomeAmount(v.getAmount().multiply(new BigDecimal(map.getOrDefault(v.getCurrency(), BigDecimal.ONE).toString())).add(v.getRefundableAmount()));
|
|
@@ -430,30 +428,17 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
//计算支出总计 除合同金额(转人民币)+应退税金额(转人民币) 其他金额相加
|
|
|
v.setExpenditureAmount(
|
|
|
- v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().multiply(rate).add
|
|
|
- (v.getCustomsFee() == null ? BigDecimal.ZERO : v.getCustomsFee().multiply(rate)).add
|
|
|
- (v.getAgencyFee() == null ? BigDecimal.ZERO : v.getAgencyFee().multiply(rate)).add
|
|
|
- (v.getPortMixedFee() == null ? BigDecimal.ZERO : v.getPortMixedFee().multiply(rate)).add
|
|
|
- (v.getInspectionRedPack() == null ? BigDecimal.ZERO : v.getInspectionRedPack().multiply(rate)).add
|
|
|
- (v.getCommission() == null ? BigDecimal.ZERO : v.getCommission().multiply(rate)).add
|
|
|
- (v.getOther() == null ? BigDecimal.ZERO : v.getOther().multiply(rate)).add
|
|
|
- (v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount()).add
|
|
|
- (v.getOtherSumAmount() == null ? BigDecimal.ZERO : v.getOtherSumAmount()));
|
|
|
- /**
|
|
|
- * 处理退税金额
|
|
|
- */
|
|
|
- List<TaxRefundDetails> rList = refundDetailsMap.getOrDefault(v.getContractId(),null);
|
|
|
- if(CollectionUtils.isNotEmpty(rList)){
|
|
|
- BigDecimal taxReturnMoney = rList.stream().map(taxRefundDetails -> {
|
|
|
- //获取汇率
|
|
|
- BigDecimal reRate = taxRefundDetails.getRate();
|
|
|
- // 获取认领金额
|
|
|
- BigDecimal money = taxRefundDetails.getAmount();
|
|
|
- // 返回兑人民币后金额
|
|
|
- return reRate.multiply(money);
|
|
|
- }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- v.setRefundableAmount(taxReturnMoney);
|
|
|
- }
|
|
|
+ v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().add
|
|
|
+ (v.getCustomsFee() == null ? BigDecimal.ZERO : v.getCustomsFee()).add
|
|
|
+ (v.getAgencyFee() == null ? BigDecimal.ZERO : v.getAgencyFee()).add
|
|
|
+ (v.getPortMixedFee() == null ? BigDecimal.ZERO : v.getPortMixedFee()).add
|
|
|
+ (v.getInspectionRedPack() == null ? BigDecimal.ZERO : v.getInspectionRedPack()).add
|
|
|
+ (v.getCommission() == null ? BigDecimal.ZERO : v.getCommission()).add
|
|
|
+ (v.getOther() == null ? BigDecimal.ZERO : v.getOther()).add
|
|
|
+ (v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount())
|
|
|
+ );
|
|
|
+ //处理退税金额
|
|
|
+ handleRefundTax(v);
|
|
|
v.setRmbContractAmount(v.getAmount().multiply(rate));
|
|
|
//计算收入总计=合同金额(转人民币)+应退税金额(转人民币)
|
|
|
v.setIncomeAmount(v.getAmount().multiply(rate).add(v.getRefundableAmount()));
|
|
@@ -489,40 +474,75 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
}
|
|
|
Page<ContractBudgetVo> page = this.baseMapper.getProfitClearingPage(dto.getPage(), wrapper);
|
|
|
List<ContractBudgetVo> list = page.getRecords();
|
|
|
- //取出默认汇率
|
|
|
- List<CurrencyRate> defaultCurrencyRateList = currencyRateService.getList();
|
|
|
- Map<String, BigDecimal> defaultCurrencyRateMap = defaultCurrencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
|
|
|
-
|
|
|
+ // 赋值客户名称
|
|
|
+ customerService.attributeAssign(list, Contract::getBuyCorporationId, (item, customer) -> {
|
|
|
+ item.setCustomerName(customer.getName());
|
|
|
+ });
|
|
|
+ List<Long> contractIds = list.stream().map(ContractBudgetVo::getContractId).collect(Collectors.toList());
|
|
|
+ //通过合同ID查询到退税数据
|
|
|
+ List<TaxRefundDetails> refundDetails = taxRefundDetailsService.getSumMoneyByContractIds(contractIds);
|
|
|
+ Map<Long,List<TaxRefundDetails>> refundDetailsMap = refundDetails.stream().collect(Collectors.groupingBy(TaxRefundDetails::getContractId));
|
|
|
+ //通过合同ID查询到到账认领数据
|
|
|
+ List<ClaimContract> claimContractList = claimContractService.list(Wrappers.<ClaimContract>query().lambda().in(ClaimContract::getContractId,contractIds));
|
|
|
+ Map<Long,List<ClaimContract>> claimMap = claimContractList.stream().collect(Collectors.groupingBy(ClaimContract::getContractId));
|
|
|
+ //通过合同ID查询到采购合同
|
|
|
+ List<EhsdPurchase> purchaseList = ehsdPurchaseService.list(Wrappers.<EhsdPurchase>query().lambda().in(EhsdPurchase::getDataResourceId,contractIds));
|
|
|
+ Map<Long,List<EhsdPurchase>> purchaseMap = purchaseList.stream().collect(Collectors.groupingBy(EhsdPurchase::getDataResourceId));
|
|
|
for (ContractBudgetVo v : list) {
|
|
|
- v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
|
|
|
v.setOtherIncomeAmount(BigDecimal.ZERO);//暂时先设置其他收入为0
|
|
|
- v.setAccountPaid(BigDecimal.ZERO);//暂时先设置已付货款为0
|
|
|
- // 赋值客户名称
|
|
|
- customerService.attributeAssign(list, Contract::getBuyCorporationId, (item, customer) -> {
|
|
|
- item.setCustomerName(customer.getName());
|
|
|
- });
|
|
|
if (StringUtils.isNotEmpty(v.getCurrencyRateJson())) {//如果此条合同有汇率了
|
|
|
//取出汇率
|
|
|
List<CurrencyRate> assignCurrencyRatesList = JSON.parseArray(v.getCurrencyRateJson(), CurrencyRate.class);
|
|
|
Map<String, BigDecimal> assignCurrencyRatesMap = assignCurrencyRatesList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
|
|
|
- v.setRmbContractAmount(v.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(v.getCurrency(), BigDecimal.ONE)));//计算汇算人民币
|
|
|
- //到账金额
|
|
|
- v.setSumClaimMoney(this.getSumClaimMoney(v, assignCurrencyRatesMap));
|
|
|
+ //计算合同人民币总额
|
|
|
+ v.setRmbContractAmount(v.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(v.getCurrency(), BigDecimal.ONE)));
|
|
|
+ /**
|
|
|
+ * 处理退税金额
|
|
|
+ */
|
|
|
+ List<TaxRefundDetails> rList = refundDetailsMap.getOrDefault(v.getContractId(),null);
|
|
|
+ if(CollectionUtils.isNotEmpty(rList)){
|
|
|
+ BigDecimal taxReturnMoney = rList.stream().map(taxRefundDetails -> {
|
|
|
+ //获取汇率
|
|
|
+ BigDecimal rate = assignCurrencyRatesMap.getOrDefault(taxRefundDetails.getCurrency(),BigDecimal.ONE);
|
|
|
+ // 获取认领金额
|
|
|
+ BigDecimal money = taxRefundDetails.getAmount();
|
|
|
+ // 返回兑人民币后金额
|
|
|
+ return rate.multiply(money);
|
|
|
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ v.setRefundableAmount(taxReturnMoney);
|
|
|
+ }
|
|
|
+ //处理到账总金额
|
|
|
+ v.setSumClaimMoney(getSumClaimMoney(claimMap.getOrDefault(v.getContractId(),null),assignCurrencyRatesMap));
|
|
|
//采购合同总金额
|
|
|
- v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, assignCurrencyRatesMap,1));
|
|
|
+ getSumPurchaseContractMoney(v,purchaseMap.getOrDefault(v.getContractId(),null),assignCurrencyRatesMap);
|
|
|
//支出费用
|
|
|
this.getGroupTypeMoney(v, assignCurrencyRatesMap);
|
|
|
- } else {//没有取默认的汇率
|
|
|
- v.setRmbContractAmount(v.getAmount().multiply(defaultCurrencyRateMap.getOrDefault(v.getCurrency(), BigDecimal.ONE)));//计算汇算人民币
|
|
|
- //到账金额
|
|
|
- v.setSumClaimMoney(this.getSumClaimMoney(v, defaultCurrencyRateMap));
|
|
|
+ } else {
|
|
|
+ v.setRmbContractAmount(v.getAmount().multiply(v.getRate()));//计算汇算人民币
|
|
|
+ /**
|
|
|
+ * 处理退税金额
|
|
|
+ */
|
|
|
+ List<TaxRefundDetails> rList = refundDetailsMap.getOrDefault(v.getContractId(),null);
|
|
|
+ if(CollectionUtils.isNotEmpty(rList)){
|
|
|
+ BigDecimal taxReturnMoney = rList.stream().map(taxRefundDetails -> {
|
|
|
+ //获取汇率
|
|
|
+ BigDecimal rate = taxRefundDetails.getRate();
|
|
|
+ // 获取认领金额
|
|
|
+ BigDecimal money = taxRefundDetails.getAmount();
|
|
|
+ // 返回兑人民币后金额
|
|
|
+ return rate.multiply(money);
|
|
|
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ v.setRefundableAmount(taxReturnMoney);
|
|
|
+ }
|
|
|
+ //处理到账总金额
|
|
|
+ v.setSumClaimMoney(getSumClaimMoney(claimMap.getOrDefault(v.getContractId(),null),null));
|
|
|
//采购合同总金额
|
|
|
- v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, defaultCurrencyRateMap,2));
|
|
|
+ getSumPurchaseContractMoney(v,purchaseMap.getOrDefault(v.getContractId(),null),null);
|
|
|
//支出费用
|
|
|
- this.getGroupTypeMoney(v, defaultCurrencyRateMap);
|
|
|
+ this.getGroupTypeMoney(v, null);
|
|
|
}
|
|
|
//计算收入总计=合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币)
|
|
|
- v.setIncomeAmount(v.getRmbContractAmount() == null ? BigDecimal.ZERO : v.getRmbContractAmount().add(v.getRefundableAmount()).add(v.getOtherIncomeAmount()));
|
|
|
+ v.setIncomeAmount(v.getSumClaimMoney() == null ? BigDecimal.ZERO : v.getSumClaimMoney().add(v.getRefundableAmount()).add(v.getOtherIncomeAmount()));
|
|
|
//计算支出总计 除合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币) 其他金额相加
|
|
|
v.setExpenditureAmount(v.getTrailerFee().add
|
|
|
(v.getCustomsFee()).add
|
|
@@ -1497,46 +1517,52 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
/**
|
|
|
* 统计到账认领总金额
|
|
|
*
|
|
|
- * @param v
|
|
|
- * @param currencyRatesMap 汇率JSON
|
|
|
+ * @param claimContractList
|
|
|
+ * @param assignCurrencyRatesMap 汇率JSON
|
|
|
* @return
|
|
|
*/
|
|
|
- private BigDecimal getSumClaimMoney(ContractBudgetVo v, Map<String, BigDecimal> currencyRatesMap) {
|
|
|
- List<ClaimContract> claimContractList = claimContractService.list(Wrappers.<ClaimContract>query().lambda().eq(ClaimContract::getContractId, v.getContractId()));
|
|
|
- BigDecimal sumClaimMOney = BigDecimal.ZERO;
|
|
|
- if (CollectionUtils.isNotEmpty(claimContractList)) {
|
|
|
+ private BigDecimal getSumClaimMoney(List<ClaimContract> claimContractList,Map<String, BigDecimal> assignCurrencyRatesMap) {
|
|
|
+ BigDecimal sumClaimMoney = BigDecimal.ZERO;
|
|
|
+ if(CollectionUtils.isEmpty(claimContractList)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ if(MapUtils.isNotEmpty(assignCurrencyRatesMap)){
|
|
|
for (ClaimContract c : claimContractList) {
|
|
|
- sumClaimMOney = sumClaimMOney.add(c.getMoney().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
+ sumClaimMoney = sumClaimMoney.add(c.getMoney().multiply(assignCurrencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for (ClaimContract c : claimContractList) {
|
|
|
+ sumClaimMoney = sumClaimMoney.add(c.getMoney().multiply(c.getRate()));
|
|
|
}
|
|
|
- return sumClaimMOney;
|
|
|
- } else {
|
|
|
- return BigDecimal.ZERO;
|
|
|
}
|
|
|
+ return sumClaimMoney;
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 统采购合同总金额
|
|
|
- *
|
|
|
* @param v
|
|
|
- * @param currencyRatesMap 汇率JSON
|
|
|
+ * @param purchaseList
|
|
|
+ * @param assignCurrencyRatesMap 汇率JSON
|
|
|
* @return
|
|
|
*/
|
|
|
- private BigDecimal getSumPurchaseContractMoney(ContractBudgetVo v, Map<String, BigDecimal> currencyRatesMap,int type) {
|
|
|
- List<EhsdPurchaseProductVo> list = ehsdPurchaseProductService.getListByContractId(v.getContractId());
|
|
|
- BigDecimal sumPurchaseContractMoney = BigDecimal.ZERO;
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- for (EhsdPurchaseProductVo c : list) {
|
|
|
- if(type==1){
|
|
|
- sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- }else{
|
|
|
- sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(c.getRate()));
|
|
|
- }
|
|
|
-
|
|
|
+ private void getSumPurchaseContractMoney(ContractBudgetVo v,List<EhsdPurchase> purchaseList,Map<String, BigDecimal> assignCurrencyRatesMap) {
|
|
|
+ BigDecimal purchaseSumMoney = BigDecimal.ZERO;
|
|
|
+ if(CollectionUtils.isEmpty(purchaseList)){
|
|
|
+ v.setSumPurchaseContractMoney(BigDecimal.ZERO);
|
|
|
+ v.setAccountPaid(BigDecimal.ZERO);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(MapUtils.isNotEmpty(assignCurrencyRatesMap)){
|
|
|
+ for (EhsdPurchase c : purchaseList) {
|
|
|
+ purchaseSumMoney = purchaseSumMoney.add(c.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for (EhsdPurchase c : purchaseList) {
|
|
|
+ purchaseSumMoney = purchaseSumMoney.add(c.getAmount().multiply(c.getRate()));
|
|
|
}
|
|
|
- return sumPurchaseContractMoney;
|
|
|
- } else {
|
|
|
- return BigDecimal.ZERO;
|
|
|
}
|
|
|
+ v.setSumPurchaseContractMoney(purchaseSumMoney);
|
|
|
+ List<Long> purchaseIds = purchaseList.stream().map(EhsdPurchase::getId).collect(Collectors.toList());
|
|
|
+ v.setAccountPaid(payDetailService.getSumMoney(purchaseIds));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1598,42 +1624,52 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
*/
|
|
|
BigDecimal other = BigDecimal.ZERO;
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- for (AccountRequestFundsDetailVo c : list) {
|
|
|
- String costType = c.getCostType() == null ? "" : c.getCostType();
|
|
|
- switch (costType) {
|
|
|
- case "1"://拖车费
|
|
|
- trailerFee = trailerFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "2"://报关费
|
|
|
- customsFee = customsFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "3"://港杂费
|
|
|
- portMixedFee = portMixedFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "4"://验收红包
|
|
|
- inspectionRedPack = inspectionRedPack.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "5"://佣金
|
|
|
- commission = commission.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "6"://检测费
|
|
|
- checkout = checkout.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "7"://验货费
|
|
|
- inspectionCharge = inspectionCharge.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "8"://运费
|
|
|
- freight = freight.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- case "9"://产地证费
|
|
|
- certificateOfOrigin = certificateOfOrigin.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- default:
|
|
|
- other = other.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
- break;
|
|
|
- }
|
|
|
+ for (AccountRequestFundsDetailVo c : list) {
|
|
|
+ String costType = c.getCostType() == null ? "" : c.getCostType();
|
|
|
+ BigDecimal rate ;
|
|
|
+ if(MapUtils.isNotEmpty(currencyRatesMap)){
|
|
|
+ rate = currencyRatesMap.getOrDefault(c.getCurrency(),null);
|
|
|
+ }else{
|
|
|
+ rate = c.getRate();
|
|
|
+ }
|
|
|
+ switch (costType) {
|
|
|
+ case "0"://拖车费
|
|
|
+ trailerFee = trailerFee.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "1"://报关费
|
|
|
+ customsFee = customsFee.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "2"://代理费
|
|
|
+ customsFee = customsFee.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "3"://港杂费
|
|
|
+ portMixedFee = portMixedFee.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "4"://验收红包
|
|
|
+ inspectionRedPack = inspectionRedPack.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "5"://佣金
|
|
|
+ commission = commission.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "6"://检测费
|
|
|
+ other = other.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "7"://检测费
|
|
|
+ checkout = checkout.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "8"://验货费
|
|
|
+ inspectionCharge = inspectionCharge.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "9"://运费
|
|
|
+ freight = freight.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ case "10"://产地证费
|
|
|
+ certificateOfOrigin = certificateOfOrigin.add(c.getAmount().multiply(rate));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
v.setTrailerFee(trailerFee);
|
|
|
v.setCustomsFee(customsFee);
|
|
@@ -1685,4 +1721,25 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
return baseMapper.getAccountRunningWaterByContractId(contractId);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取应退税金额,应退税金额=付货款 * (税额/100) / (1 + (税额/100))
|
|
|
+ *
|
|
|
+ * @param v
|
|
|
+ */
|
|
|
+ private void handleRefundTax(ContractBudgetVo v) {
|
|
|
+ // 税额/100
|
|
|
+ double d = 0.13;
|
|
|
+ //付货款 * 税额
|
|
|
+ double d1 = v.getEhsdSumAmount().doubleValue() * d;
|
|
|
+ //1 + 税额
|
|
|
+ d1 = d1 / (1 + d);
|
|
|
+
|
|
|
+ BigDecimal rt = new BigDecimal(String.valueOf(d1));
|
|
|
+ //四舍五入,保留2为
|
|
|
+ d1 = rt.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ String s1 = new BigDecimal(String.valueOf(d1)).toPlainString();
|
|
|
+ v.setRefundableAmount(new BigDecimal(s1));
|
|
|
+ }
|
|
|
+
|
|
|
}
|