|
@@ -16,8 +16,10 @@ import com.fjhx.account.controller.utils.DateUtils;
|
|
|
import com.fjhx.account.entity.account.po.AccountManagement;
|
|
|
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.AccountRequestFundsDetailService;
|
|
|
+import com.fjhx.account.service.tax.TaxRefundDetailsService;
|
|
|
import com.fjhx.area.service.SetCustomizeAreaId;
|
|
|
import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
@@ -175,6 +177,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Autowired
|
|
|
private ContractTemplateService contractTemplateService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TaxRefundDetailsService taxRefundDetailsService;
|
|
|
+
|
|
|
|
|
|
* 合同和样品单 下拉分页
|
|
|
*/
|
|
@@ -359,6 +364,10 @@ 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));
|
|
|
+
|
|
|
+ List<TaxRefundDetails> refundDetails = taxRefundDetailsService.getSumMoneyByContractIds(contractIds);
|
|
|
+ Map<Long,List<TaxRefundDetails>> refundDetailsMap = refundDetails.stream().collect(Collectors.groupingBy(TaxRefundDetails::getContractId));
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -377,8 +386,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
v.setEhsdSumAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- v.setIncomeAmount(v.getAmount().multiply(new BigDecimal(map.getOrDefault(v.getCurrency(), BigDecimal.ONE).toString())).add(v.getRefundableAmount()));
|
|
|
|
|
|
v.setExpenditureAmount(v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().multiply(new BigDecimal(map.getOrDefault(v.getTrailerFeeCurrency(), BigDecimal.ONE).toString())).add
|
|
|
(v.getCustomsFee() == null ? BigDecimal.ZERO : v.getCustomsFee().multiply(new BigDecimal(map.getOrDefault(v.getCustomsFeeCurrency(), BigDecimal.ONE).toString()))).add
|
|
@@ -389,23 +396,38 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
(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()));
|
|
|
- v.setRefundableAmount(BigDecimal.ZERO);
|
|
|
+
|
|
|
+ * 处理退税金额
|
|
|
+ */
|
|
|
+ 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.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()));
|
|
|
} else {
|
|
|
- BigDecimal rate = v.getRate();
|
|
|
if (MapUtils.isNotEmpty(ehsdAmountMap)) {
|
|
|
String concatAmountCurrency = ehsdAmountMap.getOrDefault(v.getContractId(), null);
|
|
|
if (StringUtils.isNotEmpty(concatAmountCurrency)) {
|
|
|
BigDecimal amount = new BigDecimal(concatAmountCurrency.split("-")[0]);
|
|
|
-
|
|
|
-
|
|
|
- v.setEhsdSumAmount(amount.multiply(rate));
|
|
|
+ String rate = concatAmountCurrency.split("-")[2];
|
|
|
+ BigDecimal DecimalRate = new BigDecimal(rate);
|
|
|
+ v.setEhsdSumAmount(amount.multiply(DecimalRate));
|
|
|
} else {
|
|
|
v.setEhsdSumAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- v.setIncomeAmount(v.getAmount().multiply(rate).add(v.getRefundableAmount()));
|
|
|
+ BigDecimal rate = v.getRate();
|
|
|
+
|
|
|
|
|
|
v.setExpenditureAmount(
|
|
|
v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().multiply(rate).add
|
|
@@ -417,13 +439,29 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
(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()));
|
|
|
- v.setRefundableAmount(BigDecimal.ZERO);
|
|
|
+
|
|
|
+ * 处理退税金额
|
|
|
+ */
|
|
|
+ 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.setRmbContractAmount(v.getAmount().multiply(rate));
|
|
|
+
|
|
|
+ v.setIncomeAmount(v.getAmount().multiply(rate).add(v.getRefundableAmount()));
|
|
|
}
|
|
|
|
|
|
v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
|
|
|
|
|
|
- v.setGrossRate(v.getGross().divide(v.getIncomeAmount(), RoundingMode.CEILING));
|
|
|
+ v.setGrossRate(v.getGross().divide(v.getIncomeAmount(), RoundingMode.CEILING).multiply(new BigDecimal("100")));
|
|
|
}
|
|
|
}
|
|
|
return page;
|
|
@@ -454,6 +492,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
List<CurrencyRate> defaultCurrencyRateList = currencyRateService.getList();
|
|
|
Map<String, BigDecimal> defaultCurrencyRateMap = defaultCurrencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
|
|
|
+
|
|
|
for (ContractBudgetVo v : list) {
|
|
|
v.setRefundableAmount(BigDecimal.ZERO);
|
|
|
v.setOtherIncomeAmount(BigDecimal.ZERO);
|
|
@@ -470,7 +509,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
v.setSumClaimMoney(this.getSumClaimMoney(v, assignCurrencyRatesMap));
|
|
|
|
|
|
- v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, assignCurrencyRatesMap));
|
|
|
+ v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, assignCurrencyRatesMap,1));
|
|
|
|
|
|
this.getGroupTypeMoney(v, assignCurrencyRatesMap);
|
|
|
} else {
|
|
@@ -478,7 +517,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
v.setSumClaimMoney(this.getSumClaimMoney(v, defaultCurrencyRateMap));
|
|
|
|
|
|
- v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, defaultCurrencyRateMap));
|
|
|
+ v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, defaultCurrencyRateMap,2));
|
|
|
|
|
|
this.getGroupTypeMoney(v, defaultCurrencyRateMap);
|
|
|
}
|
|
@@ -500,7 +539,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
|
|
|
|
|
|
- v.setGrossRate(v.getGross().divide(v.getIncomeAmount(), RoundingMode.CEILING));
|
|
|
+ v.setGrossRate(v.getGross().divide(v.getIncomeAmount(), RoundingMode.CEILING).multiply(new BigDecimal("100")));
|
|
|
|
|
|
}
|
|
|
return page;
|
|
@@ -1454,12 +1493,17 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
* @param currencyRatesMap 汇率JSON
|
|
|
* @return
|
|
|
*/
|
|
|
- private BigDecimal getSumPurchaseContractMoney(ContractBudgetVo v, Map<String, BigDecimal> currencyRatesMap) {
|
|
|
+ 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) {
|
|
|
- sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
+ if(type==1){
|
|
|
+ sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
|
|
|
+ }else{
|
|
|
+ sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(c.getRate()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return sumPurchaseContractMoney;
|
|
|
} else {
|