Commit 5064e315 authored by zhangfeng's avatar zhangfeng

feat(wealth): 新汇率财务相关修改

parent cab8e1e8
...@@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.ecw.api.bank.BankApi; ...@@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.ecw.api.bank.BankApi;
import cn.iocoder.yudao.module.ecw.api.bank.dto.BankAccountDTO; import cn.iocoder.yudao.module.ecw.api.bank.dto.BankAccountDTO;
import cn.iocoder.yudao.module.ecw.api.currency.CurrencyApi; import cn.iocoder.yudao.module.ecw.api.currency.CurrencyApi;
import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO; import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.ecw.api.currency.dto.ExchangeRateRespDTO;
import cn.iocoder.yudao.module.ecw.api.region.RegionApi; import cn.iocoder.yudao.module.ecw.api.region.RegionApi;
import cn.iocoder.yudao.module.ecw.api.region.dto.RegionDTO; import cn.iocoder.yudao.module.ecw.api.region.dto.RegionDTO;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
...@@ -929,7 +930,8 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO ...@@ -929,7 +930,8 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
RegionDTO region = regionApi.getRegionById(Long.parseLong(orderVO.getCountry())); RegionDTO region = regionApi.getRegionById(Long.parseLong(orderVO.getCountry()));
Long importCurrency3 = Long.parseLong(region.getImportCurrency3()); Long importCurrency3 = Long.parseLong(region.getImportCurrency3());
if (!currencyId.equals(importCurrency3)) { if (!currencyId.equals(importCurrency3)) {
diff = diff.multiply(currencyApi.getCurrencyRate(currencyId, importCurrency3).getCurrencyRate()); ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(currencyId, importCurrency3);
diff = diff.multiply(currencyRate.getTargetCurrencyAmount()).divide(currencyRate.getSourceCurrencyAmount(), 2, RoundingMode.HALF_UP);
} }
update.setWriteOffDiffMainCurrency(diff.setScale(2, RoundingMode.HALF_UP) + " " + currencyApi.getAllCurrency().get(importCurrency3.intValue()).getFuhao()); update.setWriteOffDiffMainCurrency(diff.setScale(2, RoundingMode.HALF_UP) + " " + currencyApi.getAllCurrency().get(importCurrency3.intValue()).getFuhao());
} }
......
...@@ -236,9 +236,10 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap ...@@ -236,9 +236,10 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptInvoiceDetail.setReceivableTotalAmountUsd(BigDecimal.ZERO); receiptInvoiceDetail.setReceivableTotalAmountUsd(BigDecimal.ZERO);
receiptInvoiceDetail.setWriteOffAmountUsd(BigDecimal.ZERO); receiptInvoiceDetail.setWriteOffAmountUsd(BigDecimal.ZERO);
for (WealthMoneyAmountVO wealthMoneyAmountVO : receiptAmountList) { for (WealthMoneyAmountVO wealthMoneyAmountVO : receiptAmountList) {
ExchangeRateRespDTO rate = currencyApi.getCurrencyRateByCode(wealthMoneyAmountVO.getCurrencySymbol(), currencyMap.get(receiptInvoiceDetail.getBaseCurrencyId().intValue()).getFuhao()); ExchangeRateRespDTO rateDTO = currencyApi.getCurrencyRateByCode(wealthMoneyAmountVO.getCurrencySymbol(), currencyMap.get(receiptInvoiceDetail.getBaseCurrencyId().intValue()).getFuhao());
receiptInvoiceDetail.setReceivableTotalAmountUsd(receiptInvoiceDetail.getReceivableTotalAmountUsd().add(wealthMoneyAmountVO.getReceivableTotalAmount().multiply(rate.getCurrencyRate()))); BigDecimal rate = rateDTO.getTargetCurrencyAmount().divide(rateDTO.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP);
receiptInvoiceDetail.setWriteOffAmountUsd(receiptInvoiceDetail.getWriteOffAmountUsd().add(wealthMoneyAmountVO.getWriteOffAmount().multiply(rate.getCurrencyRate()))); receiptInvoiceDetail.setReceivableTotalAmountUsd(receiptInvoiceDetail.getReceivableTotalAmountUsd().add(wealthMoneyAmountVO.getReceivableTotalAmount().multiply(rate)));
receiptInvoiceDetail.setWriteOffAmountUsd(receiptInvoiceDetail.getWriteOffAmountUsd().add(wealthMoneyAmountVO.getWriteOffAmount().multiply(rate)));
} }
BigDecimal writeOffProportion = receiptInvoiceDetail.getWriteOffAmountUsd().divide(receiptInvoiceDetail.getReceivableTotalAmountUsd(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); BigDecimal writeOffProportion = receiptInvoiceDetail.getWriteOffAmountUsd().divide(receiptInvoiceDetail.getReceivableTotalAmountUsd(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
receiptInvoiceDetail.setWriteOffProportion(writeOffProportion + "%"); receiptInvoiceDetail.setWriteOffProportion(writeOffProportion + "%");
......
...@@ -120,25 +120,30 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -120,25 +120,30 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
RegionDTO regionInfo = regionApi.getRegionById(countryId); RegionDTO regionInfo = regionApi.getRegionById(countryId);
if (regionInfo != null) { if (regionInfo != null) {
receivable.setBaseCurrencyId(Long.parseLong(regionInfo.getImportCurrency5())); receivable.setBaseCurrencyId(Long.parseLong(regionInfo.getImportCurrency5()));
BigDecimal baseAmount = currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getBaseCurrencyId()).getCurrencyRate().multiply(receivable.getTotalAmount()); ExchangeRateRespDTO baseCurrencyRate = currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getBaseCurrencyId());
BigDecimal baseAmount = receivable.getTotalAmount().multiply(baseCurrencyRate.getTargetCurrencyAmount()).divide(baseCurrencyRate.getSourceCurrencyAmount(), 2, RoundingMode.HALF_UP);
receivable.setBaseAmount(baseAmount); receivable.setBaseAmount(baseAmount);
int feeType = getFeeType(receivable.getFeeType()); int feeType = getFeeType(receivable.getFeeType());
// 运费 // 运费
if (feeType == 0) { if (feeType == 0) {
receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency1())); receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency1()));
receivable.setDestCountryRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId()).getCurrencyRate()); ExchangeRateRespDTO destCurrencyRate = currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId());
receivable.setDestCountryRate(destCurrencyRate.getTargetCurrencyAmount().divide(destCurrencyRate.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP));
} }
// 清关费 // 清关费
if (feeType == 1) { if (feeType == 1) {
receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency2())); receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency2()));
receivable.setDestCountryRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId()).getCurrencyRate()); ExchangeRateRespDTO destCurrencyRate = currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId());
receivable.setDestCountryRate(destCurrencyRate.getTargetCurrencyAmount().divide(destCurrencyRate.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP));
} }
// 额外费用 // 额外费用
if (feeType == 2) { if (feeType == 2) {
receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency3())); receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency3()));
receivable.setDestCountryRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId()).getCurrencyRate()); ExchangeRateRespDTO destCurrencyRate = currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId());
receivable.setDestCountryRate(destCurrencyRate.getTargetCurrencyAmount().divide(destCurrencyRate.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP));
} }
receivable.setDestCountrySubRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), Long.parseLong(regionInfo.getImportCurrency4())).getCurrencyRate()); ExchangeRateRespDTO destCurrencySubRate = currencyApi.getCurrencyRate(receivable.getCurrencyId(), Long.parseLong(regionInfo.getImportCurrency4()));
receivable.setDestCountrySubRate(destCurrencySubRate.getTargetCurrencyAmount().divide(destCurrencySubRate.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP));
} }
this.save(receivable); this.save(receivable);
// 返回 // 返回
...@@ -290,7 +295,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -290,7 +295,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
receivableBackVO.setNotIncludedTaxAmount(receivableBackVO.getTotalAmount()); receivableBackVO.setNotIncludedTaxAmount(receivableBackVO.getTotalAmount());
receivableBackVO.setActualAmount(receivableBackVO.getNotIncludedTaxAmount().subtract(receivableBackVO.getDiscountTotal())); receivableBackVO.setActualAmount(receivableBackVO.getNotIncludedTaxAmount().subtract(receivableBackVO.getDiscountTotal()));
ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(receivableBackVO.getCurrencyId(), receivableBackVO.getBaseCurrencyId()); ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(receivableBackVO.getCurrencyId(), receivableBackVO.getBaseCurrencyId());
receivableBackVO.setExchangeRate(currencyRate.getCurrencyRate()); receivableBackVO.setExchangeRate(currencyRate.getTargetCurrencyAmount().divide(currencyRate.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP));
receivableBackVO.setBaseAmount(receivableBackVO.getActualAmount().multiply(currencyRate.getCurrencyRate())); receivableBackVO.setBaseAmount(receivableBackVO.getActualAmount().multiply(currencyRate.getCurrencyRate()));
}); });
return PageResult.of(mpPage); return PageResult.of(mpPage);
...@@ -317,7 +322,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -317,7 +322,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
receivableBackVO.setNotIncludedTaxAmount(receivableBackVO.getTotalAmount()); receivableBackVO.setNotIncludedTaxAmount(receivableBackVO.getTotalAmount());
receivableBackVO.setActualAmount(receivableBackVO.getTaxAmount().subtract(receivableBackVO.getDiscountTotal())); receivableBackVO.setActualAmount(receivableBackVO.getTaxAmount().subtract(receivableBackVO.getDiscountTotal()));
ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(receivableBackVO.getCurrencyId(), receivableBackVO.getBaseCurrencyId()); ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(receivableBackVO.getCurrencyId(), receivableBackVO.getBaseCurrencyId());
receivableBackVO.setExchangeRate(currencyRate.getCurrencyRate()); receivableBackVO.setExchangeRate(currencyRate.getTargetCurrencyAmount().divide(currencyRate.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP));
receivableBackVO.setBaseAmount(receivableBackVO.getActualAmount().multiply(currencyRate.getCurrencyRate())); receivableBackVO.setBaseAmount(receivableBackVO.getActualAmount().multiply(currencyRate.getCurrencyRate()));
}); });
return receivableBackVOList; return receivableBackVOList;
...@@ -652,7 +657,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -652,7 +657,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
if (currencyRate == null) { if (currencyRate == null) {
receivableWriteOffAmount = receivableWriteOffReqVO.getWriteOffAmount(); receivableWriteOffAmount = receivableWriteOffReqVO.getWriteOffAmount();
} else { } else {
receivableWriteOffAmount = receivableWriteOffReqVO.getWriteOffAmount().multiply(currencyRate.getCurrencyRate()); receivableWriteOffAmount = receivableWriteOffReqVO.getWriteOffAmount().multiply(currencyRate.getTargetCurrencyAmount().divide(currencyRate.getSourceCurrencyAmount(), 2, RoundingMode.HALF_UP));
} }
ReceivableWriteOffRecordDO writeOffRecord = ReceivableWriteOffRecordDO.builder() ReceivableWriteOffRecordDO writeOffRecord = ReceivableWriteOffRecordDO.builder()
.receivableId(receivableWriteOffReqVO.getReceivableId()) .receivableId(receivableWriteOffReqVO.getReceivableId())
...@@ -800,7 +805,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -800,7 +805,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
List<ExchangeRateRespDTO> allCurrencyRate = currencyApi.getAllCurrencyRate(); List<ExchangeRateRespDTO> allCurrencyRate = currencyApi.getAllCurrencyRate();
ReceivableBoxReportVO.Amount pageAmount = new ReceivableBoxReportVO.Amount(); ReceivableBoxReportVO.Amount pageAmount = new ReceivableBoxReportVO.Amount();
ReceivableBoxReportVO.Amount queryAmount = new ReceivableBoxReportVO.Amount(); ReceivableBoxReportVO.Amount queryAmount = new ReceivableBoxReportVO.Amount();
assembleReportAmount(query.getForceUpdateCache(),records, relationOrderMap, allCurrencyRate, allCurrency, queryAmount, pageVOList, pageAmount); assembleReportAmount(query.getForceUpdateCache(), records, relationOrderMap, allCurrencyRate, allCurrency, queryAmount, pageVOList, pageAmount);
ReceivableBoxReportVO reportVO = voBuilder ReceivableBoxReportVO reportVO = voBuilder
.pageAmount(pageAmount) .pageAmount(pageAmount)
.queryAmount(queryAmount) .queryAmount(queryAmount)
...@@ -1236,7 +1241,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -1236,7 +1241,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
} }
for (ExchangeRateRespDTO exchangeRateRespDTO : allCurrencyRate) { for (ExchangeRateRespDTO exchangeRateRespDTO : allCurrencyRate) {
if (exchangeRateRespDTO.getSourceCurrencyId().equals(sourceId) && exchangeRateRespDTO.getTargetCurrencyId().equals(targetId)) { if (exchangeRateRespDTO.getSourceCurrencyId().equals(sourceId) && exchangeRateRespDTO.getTargetCurrencyId().equals(targetId)) {
return exchangeRateRespDTO.getCurrencyRate(); return exchangeRateRespDTO.getTargetCurrencyAmount().divide(exchangeRateRespDTO.getSourceCurrencyAmount(), 6, RoundingMode.HALF_UP);
} }
} }
return BigDecimal.ONE; return BigDecimal.ONE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment