|
|
@@ -31,6 +31,7 @@ import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.los.Util.CurrencyUtils;
|
|
|
import org.springblade.los.Util.StringTools;
|
|
|
import org.springblade.los.Util.ZrUtil;
|
|
|
import org.springblade.los.basic.business.entity.BusinessType;
|
|
|
@@ -39,7 +40,7 @@ import org.springblade.los.basic.corps.entity.BCorps;
|
|
|
import org.springblade.los.basic.corps.entity.BCorpsAttn;
|
|
|
import org.springblade.los.basic.corps.mapper.CorpsAttnMapper;
|
|
|
import org.springblade.los.basic.corps.mapper.CorpsMapper;
|
|
|
-import org.springblade.los.basic.cur.entity.BCurrency;
|
|
|
+import org.springblade.los.basic.cur.entity.BCurExrate;
|
|
|
import org.springblade.los.basic.cur.service.IBCurrencyService;
|
|
|
import org.springblade.los.basic.vessels.entity.BVessels;
|
|
|
import org.springblade.los.basic.vessels.mapper.VesselsMapper;
|
|
|
@@ -117,8 +118,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
|
|
|
private final IBusinessBillNoService businessBillNoService;
|
|
|
|
|
|
- private final IBCurrencyService bCurrencyService;
|
|
|
-
|
|
|
private final IBusinessTypeService bBusinessTypeService;
|
|
|
|
|
|
private final IAuditPathsActsService auditPathsActsService;
|
|
|
@@ -149,6 +148,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
|
|
|
private final IUserClient userClient;
|
|
|
|
|
|
+ private final CurrencyUtils currencyUtils;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<BillsVO> selectBillsPage(IPage<BillsVO> page, BillsVO bills) {
|
|
|
return page.setRecords(baseMapper.selectBillsPage(page, bills));
|
|
|
@@ -419,8 +420,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
} else {
|
|
|
date = bills.getEta();
|
|
|
}
|
|
|
- BigDecimal exrateD = bCurrencyService.getCnyExrate(date, "USD", "D", "1");
|
|
|
- BigDecimal exrateC = bCurrencyService.getCnyExrate(date, "USD", "C", "1");
|
|
|
+ String exrateType = currencyUtils.standardCurrency();
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1");
|
|
|
//应付
|
|
|
int statusC = 0;
|
|
|
if (ObjectUtils.isNotNull(bills.getFeeCenterListC())) {
|
|
|
@@ -463,13 +464,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
item.setRefno(bills.getRefno());
|
|
|
item.setBookingNo(bills.getBookingNo());
|
|
|
item.setCntrNo(bills.getQuantityCntrTypesDescr());
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- amountCrUsd = amountCrUsd.add(item.getAmount());
|
|
|
- } else if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
amountCr = amountCr.add(item.getAmount());
|
|
|
+ amountCrLoc = amountCrLoc.add(item.getAmount());
|
|
|
} else {
|
|
|
- BigDecimal usd = item.getAmount().multiply(exrateC);
|
|
|
- amountCrUsd = amountCrUsd.add(usd);
|
|
|
+ amountCrUsd = amountCrUsd.add(item.getAmount());
|
|
|
+ amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
|
|
|
}
|
|
|
feeCenterListAll.add(item);
|
|
|
}
|
|
|
@@ -516,13 +516,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
item.setRefno(bills.getRefno());
|
|
|
item.setBookingNo(bills.getBookingNo());
|
|
|
item.setCntrNo(bills.getQuantityCntrTypesDescr());
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- amountDrUsd = amountDrUsd.add(item.getAmount());
|
|
|
- } else if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
amountDr = amountDr.add(item.getAmount());
|
|
|
+ amountDrLoc = amountDrLoc.add(item.getAmount());
|
|
|
} else {
|
|
|
- BigDecimal usd = item.getAmount().multiply(exrateD);
|
|
|
- amountDrUsd = amountDrUsd.add(usd);
|
|
|
+ amountDrUsd = amountDrUsd.add(item.getAmount());
|
|
|
+ amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
|
|
|
}
|
|
|
feeCenterListAll.add(item);
|
|
|
}
|
|
|
@@ -564,13 +563,13 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
if (details != null) {
|
|
|
BigDecimal amountDrM = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrM = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitM = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitM;
|
|
|
BigDecimal amountDrUsdM = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrUsdM = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitUsdM = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitUsdM;
|
|
|
BigDecimal amountDrLocM = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrLocM = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitLocM = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitLocM;
|
|
|
List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
.select(FeeCenter::getCurCode, FeeCenter::getAmount, FeeCenter::getDc)
|
|
|
.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -578,22 +577,20 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
.eq(FeeCenter::getPid, details.getId()));
|
|
|
for (FeeCenter item : feeCenterList) {
|
|
|
if ("C".equals(item.getDc())) {
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- amountCrUsdM = amountCrUsdM.add(item.getAmount());
|
|
|
- } else if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
amountCrM = amountCrM.add(item.getAmount());
|
|
|
+ amountCrLocM = amountCrLocM.add(item.getAmount());
|
|
|
} else {
|
|
|
- BigDecimal usd = item.getAmount().multiply(exrateC);
|
|
|
- amountCrUsdM = amountCrUsdM.add(usd);
|
|
|
+ amountCrUsdM = amountCrUsdM.add(item.getAmount());
|
|
|
+ amountCrLocM = amountCrLocM.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
|
|
|
}
|
|
|
} else {
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- amountDrUsdM = amountDrUsdM.add(item.getAmount());
|
|
|
- } else if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
amountDrM = amountDrM.add(item.getAmount());
|
|
|
+ amountDrLocM = amountDrLocM.add(item.getAmount());
|
|
|
} else {
|
|
|
- BigDecimal usd = item.getAmount().multiply(exrateD);
|
|
|
- amountDrUsdM = amountDrUsdM.add(usd);
|
|
|
+ amountDrUsdM = amountDrUsdM.add(item.getAmount());
|
|
|
+ amountDrLocM = amountDrLocM.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -618,8 +615,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
//利润 = 收 - 付
|
|
|
amountProfitM = amountDrM.subtract(amountCrM);
|
|
|
amountProfitUsdM = amountDrUsdM.subtract(amountCrUsdM);
|
|
|
- amountDrLocM = amountDrLocM.add(amountDrUsdM.multiply(exrateD)).add(amountDrM);
|
|
|
- amountCrLocM = amountCrLocM.add(amountCrUsdM.multiply(exrateC)).add(amountCrM);
|
|
|
amountProfitLocM = amountDrLocM.subtract(amountCrLocM);
|
|
|
details.setAmountDr(amountDrM);
|
|
|
details.setAmountCr(amountCrM);
|
|
|
@@ -636,16 +631,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
//利润 = 收 - 付
|
|
|
amountProfit = amountDr.subtract(amountCr);
|
|
|
amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
|
|
|
- if (amountDrUsd.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- amountDrLoc = amountDrLoc.add(amountDrUsd.multiply(exrateD)).add(amountDr);
|
|
|
- } else {
|
|
|
- amountDrLoc = amountDrLoc.add(amountDr);
|
|
|
- }
|
|
|
- if (amountCrUsd.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- amountCrLoc = amountCrLoc.add(amountCrUsd.multiply(exrateC)).add(amountCr);
|
|
|
- } else {
|
|
|
- amountCrLoc = amountCrLoc.add(amountCr);
|
|
|
- }
|
|
|
amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
|
|
|
bills.setAmountDr(amountDr);
|
|
|
bills.setAmountCr(amountCr);
|
|
|
@@ -1031,6 +1016,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
BigDecimal amountDrLoc = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrLoc = new BigDecimal("0.00");
|
|
|
BigDecimal amountProfitLoc;
|
|
|
+ String exrateType = currencyUtils.standardCurrency();
|
|
|
if (!amendsList.isEmpty()) {
|
|
|
List<Long> ids = amendsList.stream().map(Amends::getId).distinct().collect(Collectors.toList());
|
|
|
List<FeeCenter> feeCenterAmendList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
@@ -1040,7 +1026,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
detail.setFeeCenterAmendList(feeCenterAmendList.isEmpty() ? new ArrayList<>() : feeCenterAmendList);
|
|
|
for (FeeCenter item : feeCenterAmendList) {
|
|
|
if ("D".equals(item.getDc())) {
|
|
|
- if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
amountDr = amountDr.add(item.getAmount());
|
|
|
amountDrLoc = amountDrLoc.add(item.getAmount());
|
|
|
} else {
|
|
|
@@ -1048,7 +1034,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
amountDrLoc = amountDrLoc.add(item.getAmount().multiply(item.getExrate()));
|
|
|
}
|
|
|
} else {
|
|
|
- if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
amountCr = amountCr.add(item.getAmount());
|
|
|
amountCrLoc = amountCrLoc.add(item.getAmount());
|
|
|
} else {
|
|
|
@@ -2067,93 +2053,51 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
}
|
|
|
if ("1".equals(type)) {
|
|
|
List<FeeCenter> feeCenterListSum = new ArrayList<>();
|
|
|
- BigDecimal exrateDUsd = null;
|
|
|
- BigDecimal exrateCUsd = null;
|
|
|
- BCurrency bCurrency = new BCurrency();
|
|
|
- bCurrency.setType("1");
|
|
|
- bCurrency.setDc("D");
|
|
|
- bCurrency.setDate(date1);
|
|
|
- List<BCurrency> bCurrencyListD = bCurrencyService.getExrate(bCurrency);
|
|
|
- if (!bCurrencyListD.isEmpty()) {
|
|
|
- BCurrency bCurrency1 = bCurrencyListD.stream().filter(e -> e.getCode().equals("USD"))
|
|
|
- .findFirst().orElse(null);
|
|
|
- if (bCurrency1 != null) {
|
|
|
- exrateDUsd = bCurrency1.getExrate();
|
|
|
- }
|
|
|
- }
|
|
|
- bCurrency.setDc("C");
|
|
|
- List<BCurrency> bCurrencyListC = bCurrencyService.getExrate(bCurrency);
|
|
|
- if (!bCurrencyListD.isEmpty()) {
|
|
|
- BCurrency bCurrency1 = bCurrencyListC.stream().filter(e -> e.getCode().equals("USD"))
|
|
|
- .findFirst().orElse(null);
|
|
|
- if (bCurrency1 != null) {
|
|
|
- exrateCUsd = bCurrency1.getExrate();
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNull(exrateDUsd) || ObjectUtils.isNull(exrateCUsd)) {
|
|
|
- throw new RuntimeException("请先维护汇率信息");
|
|
|
- }
|
|
|
-
|
|
|
+ String exrateType = currencyUtils.standardCurrency();
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(date1, "1");
|
|
|
BigDecimal amountDr = new BigDecimal("0.00");
|
|
|
BigDecimal amountCr = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfit = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfit;
|
|
|
BigDecimal amountDrUsd = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrUsd = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitUsd = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitUsd;
|
|
|
BigDecimal amountDrLoc = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrLoc = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitLoc = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitLoc;
|
|
|
|
|
|
List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(FeeCenter::getIsDeleted, 0)
|
|
|
.eq(FeeCenter::getPid, billId));
|
|
|
if (!feeCenterList.isEmpty()) {
|
|
|
- List<FeeCenter> feeCenterListD = feeCenterList.stream().filter(e -> e.getDc().equals("D")).collect(Collectors.toList());
|
|
|
- if (!feeCenterListD.isEmpty()) {
|
|
|
- for (FeeCenter item : feeCenterListD) {
|
|
|
- item.setEtd(bills.getEtd());
|
|
|
- item.setEta(bills.getEta());
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- amountCrUsd = amountCrUsd.add(item.getAmount());
|
|
|
- } else if ("CNY".equals(item.getCurCode())) {
|
|
|
- amountCr = amountCr.add(item.getAmount());
|
|
|
- } else {
|
|
|
- BigDecimal usd = item.getAmount().multiply(exrateDUsd);
|
|
|
- amountCrUsd = amountCrUsd.add(usd);
|
|
|
- }
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- item.setExrate(exrateDUsd);
|
|
|
- item.setAmountNetLoc(item.getAmountNet().multiply(exrateDUsd));
|
|
|
- item.setAmountTaxLoc(item.getAmountTax().multiply(exrateDUsd));
|
|
|
- item.setAmountLoc(item.getAmount().multiply(exrateDUsd));
|
|
|
- item.setAmountDiscountLoc(item.getAmount().multiply(exrateDUsd));
|
|
|
- }
|
|
|
- feeCenterListSum.add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- List<FeeCenter> feeCenterListC = feeCenterList.stream().filter(e -> e.getDc().equals("C")).collect(Collectors.toList());
|
|
|
- if (!feeCenterListC.isEmpty()) {
|
|
|
- for (FeeCenter item : feeCenterListC) {
|
|
|
- item.setEtd(bills.getEtd());
|
|
|
- item.setEta(bills.getEta());
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- amountDrUsd = amountDrUsd.add(item.getAmount());
|
|
|
- } else if ("CNY".equals(item.getCurCode())) {
|
|
|
+ for (FeeCenter item : feeCenterList) {
|
|
|
+ item.setEtd(bills.getEtd());
|
|
|
+ item.setEta(bills.getEta());
|
|
|
+ if ("D".equals(item.getDc())){
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
amountDr = amountDr.add(item.getAmount());
|
|
|
+ amountDrLoc = amountDrLoc.add(item.getAmount());
|
|
|
} else {
|
|
|
- BigDecimal usd = item.getAmount().multiply(exrateCUsd);
|
|
|
- amountDrUsd = amountDrUsd.add(usd);
|
|
|
+ amountDrUsd = amountDrUsd.add(item.getAmount());
|
|
|
+ amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
|
|
|
}
|
|
|
- if ("USD".equals(item.getCurCode())) {
|
|
|
- item.setExrate(exrateCUsd);
|
|
|
- item.setAmountNetLoc(item.getAmountNet().multiply(exrateCUsd));
|
|
|
- item.setAmountTaxLoc(item.getAmountTax().multiply(exrateCUsd));
|
|
|
- item.setAmountLoc(item.getAmount().multiply(exrateCUsd));
|
|
|
- item.setAmountDiscountLoc(item.getAmount().multiply(exrateCUsd));
|
|
|
+ }else{
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
+ amountCr = amountCr.add(item.getAmount());
|
|
|
+ amountCrLoc = amountCrLoc.add(item.getAmount());
|
|
|
+ } else {
|
|
|
+ amountCrUsd = amountCrUsd.add(item.getAmount());
|
|
|
+ amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
|
|
|
}
|
|
|
- feeCenterListSum.add(item);
|
|
|
}
|
|
|
+ if (!exrateType.equals(item.getCurCode())) {
|
|
|
+ item.setExrate(currencyUtils.obtainExrate(item.getDc(), curExrateList, item.getCurCode(), "1"));
|
|
|
+ item.setAmountNetLoc(currencyUtils.converter(item.getDc(), curExrateList, item.getAmountNet(), item.getCurCode(), "1"));
|
|
|
+ item.setAmountTaxLoc(currencyUtils.converter(item.getDc(), curExrateList, item.getAmountTax(), item.getCurCode(), "1"));
|
|
|
+ item.setAmountLoc(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
|
|
|
+ item.setAmountDiscountLoc(item.getAmountLoc());
|
|
|
+ }
|
|
|
+ feeCenterListSum.add(item);
|
|
|
}
|
|
|
//主单应加上分单费用
|
|
|
if ("MM".equals(bills.getBillType())) {
|
|
|
@@ -2170,17 +2114,15 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
.eq(FeeCenter::getIsDeleted, 0)
|
|
|
.in(FeeCenter::getPid, billIds));
|
|
|
for (Bills item : details) {
|
|
|
-
|
|
|
BigDecimal amountDrMH = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrMH = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitMH = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitMH;
|
|
|
BigDecimal amountDrUsdMH = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrUsdMH = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitUsdMH = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitUsdMH;
|
|
|
BigDecimal amountDrLocMH = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrLocMH = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitLocMH = new BigDecimal("0.00");
|
|
|
-
|
|
|
+ BigDecimal amountProfitLocMH;
|
|
|
item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
item.setUpdateTime(new Date());
|
|
|
item.setUpdateUser(AuthUtil.getUserId());
|
|
|
@@ -2191,74 +2133,47 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
}
|
|
|
item.setBillDate(date1);
|
|
|
if (!feeCenterListMH.isEmpty()) {
|
|
|
- List<FeeCenter> feeCenterListDMH = feeCenterListMH.stream().filter(e -> e.getDc().equals("D")
|
|
|
- && item.getId().equals(e.getPid())).collect(Collectors.toList());
|
|
|
- if (!feeCenterListDMH.isEmpty()) {
|
|
|
- for (FeeCenter itemMH : feeCenterListDMH) {
|
|
|
- itemMH.setEtd(bills.getEtd());
|
|
|
- itemMH.setEta(bills.getEta());
|
|
|
- if ("USD".equals(itemMH.getCurCode())) {
|
|
|
- amountCrUsd = amountCrUsd.add(itemMH.getAmount());
|
|
|
- amountCrUsdMH = amountCrUsdMH.add(itemMH.getAmount());
|
|
|
- } else if ("CNY".equals(itemMH.getCurCode())) {
|
|
|
- amountCr = amountCr.add(itemMH.getAmount());
|
|
|
- amountCrMH = amountCrMH.add(itemMH.getAmount());
|
|
|
- } else {
|
|
|
- BigDecimal usd = itemMH.getAmount().multiply(exrateDUsd);
|
|
|
- amountCrUsd = amountCrUsd.add(usd);
|
|
|
- amountCrUsdMH = amountCrUsdMH.add(usd);
|
|
|
- }
|
|
|
- if ("USD".equals(itemMH.getCurCode())) {
|
|
|
- itemMH.setExrate(exrateDUsd);
|
|
|
- itemMH.setAmountNetLoc(itemMH.getAmountNet().multiply(exrateDUsd));
|
|
|
- itemMH.setAmountTaxLoc(itemMH.getAmountTax().multiply(exrateDUsd));
|
|
|
- itemMH.setAmountLoc(itemMH.getAmount().multiply(exrateDUsd));
|
|
|
- itemMH.setAmountDiscountLoc(itemMH.getAmount().multiply(exrateDUsd));
|
|
|
- }
|
|
|
- feeCenterListSum.add(itemMH);
|
|
|
- }
|
|
|
- }
|
|
|
- List<FeeCenter> feeCenterListCMH = feeCenterListMH.stream().filter(e -> e.getDc().equals("C")
|
|
|
- && item.getId().equals(e.getPid())).collect(Collectors.toList());
|
|
|
- if (!feeCenterListCMH.isEmpty()) {
|
|
|
- for (FeeCenter itemMH : feeCenterListCMH) {
|
|
|
- itemMH.setEtd(bills.getEtd());
|
|
|
- itemMH.setEta(bills.getEta());
|
|
|
- if ("USD".equals(itemMH.getCurCode())) {
|
|
|
- amountDrUsd = amountDrUsd.add(itemMH.getAmount());
|
|
|
- amountDrUsdMH = amountDrUsdMH.add(itemMH.getAmount());
|
|
|
- } else if ("CNY".equals(itemMH.getCurCode())) {
|
|
|
+ for (FeeCenter itemMH : feeCenterListMH) {
|
|
|
+ itemMH.setEtd(bills.getEtd());
|
|
|
+ itemMH.setEta(bills.getEta());
|
|
|
+ if ("D".equals(itemMH.getDc())){
|
|
|
+ if (exrateType.equals(itemMH.getCurCode())) {
|
|
|
amountDr = amountDr.add(itemMH.getAmount());
|
|
|
amountDrMH = amountDrMH.add(itemMH.getAmount());
|
|
|
+ amountDrLoc = amountDrLoc.add(itemMH.getAmount());
|
|
|
+ amountDrLocMH = amountDrLocMH.add(itemMH.getAmount());
|
|
|
} else {
|
|
|
- BigDecimal usd = itemMH.getAmount().multiply(exrateCUsd);
|
|
|
- amountDrUsd = amountDrUsd.add(usd);
|
|
|
- amountDrUsdMH = amountDrUsdMH.add(usd);
|
|
|
+ amountDrUsd = amountDrUsd.add(itemMH.getAmount());
|
|
|
+ amountDrUsdMH = amountDrUsdMH.add(itemMH.getAmount());
|
|
|
+ amountDrLoc = amountDrLoc.add(currencyUtils.converter(itemMH.getDc(), curExrateList, itemMH.getAmount(), itemMH.getCurCode(), "1"));
|
|
|
+ amountDrLocMH = amountDrLocMH.add(currencyUtils.converter(itemMH.getDc(), curExrateList, itemMH.getAmount(), itemMH.getCurCode(), "1"));
|
|
|
}
|
|
|
- if ("USD".equals(itemMH.getCurCode())) {
|
|
|
- itemMH.setExrate(exrateCUsd);
|
|
|
- itemMH.setAmountNetLoc(itemMH.getAmountNet().multiply(exrateCUsd));
|
|
|
- itemMH.setAmountTaxLoc(itemMH.getAmountTax().multiply(exrateCUsd));
|
|
|
- itemMH.setAmountLoc(itemMH.getAmount().multiply(exrateCUsd));
|
|
|
- itemMH.setAmountDiscountLoc(itemMH.getAmount().multiply(exrateCUsd));
|
|
|
+ }else{
|
|
|
+ if (exrateType.equals(itemMH.getCurCode())) {
|
|
|
+ amountCr = amountCr.add(itemMH.getAmount());
|
|
|
+ amountCrMH = amountCrMH.add(itemMH.getAmount());
|
|
|
+ amountCrLoc = amountCrLoc.add(itemMH.getAmount());
|
|
|
+ amountCrLocMH = amountCrLocMH.add(itemMH.getAmount());
|
|
|
+ } else {
|
|
|
+ amountCrUsd = amountCrUsd.add(itemMH.getAmount());
|
|
|
+ amountCrUsdMH = amountCrUsdMH.add(itemMH.getAmount());
|
|
|
+ amountCrLoc = amountCrLoc.add(currencyUtils.converter(itemMH.getDc(), curExrateList, itemMH.getAmount(), itemMH.getCurCode(), "1"));
|
|
|
+ amountCrLocMH = amountCrLocMH.add(currencyUtils.converter(itemMH.getDc(), curExrateList, itemMH.getAmount(), itemMH.getCurCode(), "1"));
|
|
|
}
|
|
|
- feeCenterListSum.add(itemMH);
|
|
|
}
|
|
|
+ if (!exrateType.equals(itemMH.getCurCode())) {
|
|
|
+ itemMH.setExrate(currencyUtils.obtainExrate(itemMH.getDc(), curExrateList, itemMH.getCurCode(), "1"));
|
|
|
+ itemMH.setAmountNetLoc(currencyUtils.converter(itemMH.getDc(), curExrateList, itemMH.getAmountNet(), itemMH.getCurCode(), "1"));
|
|
|
+ itemMH.setAmountTaxLoc(currencyUtils.converter(itemMH.getDc(), curExrateList, itemMH.getAmountTax(), itemMH.getCurCode(), "1"));
|
|
|
+ itemMH.setAmountLoc(currencyUtils.converter(itemMH.getDc(), curExrateList, itemMH.getAmount(), itemMH.getCurCode(), "1"));
|
|
|
+ itemMH.setAmountDiscountLoc(itemMH.getAmountLoc());
|
|
|
+ }
|
|
|
+ feeCenterListSum.add(itemMH);
|
|
|
}
|
|
|
}
|
|
|
//利润 = 收 - 付
|
|
|
amountProfitMH = amountDrMH.subtract(amountCrMH);
|
|
|
amountProfitUsdMH = amountDrUsdMH.subtract(amountCrUsdMH);
|
|
|
- if (amountDrUsdMH.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- amountDrLocMH = amountDrLocMH.add(amountDrUsdMH.multiply(exrateDUsd).add(amountDrMH));
|
|
|
- } else {
|
|
|
- amountDrLocMH = amountDrLocMH.add(amountDrMH);
|
|
|
- }
|
|
|
- if (amountCrUsdMH.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- amountCrLocMH = amountCrLocMH.add(amountCrUsdMH.multiply(exrateCUsd).add(amountCrMH));
|
|
|
- } else {
|
|
|
- amountCrLocMH = amountCrLocMH.add(amountCrMH);
|
|
|
- }
|
|
|
amountProfitLocMH = amountDrLocMH.subtract(amountCrLocMH);
|
|
|
item.setAmountDr(amountDrMH);
|
|
|
item.setAmountCr(amountCrMH);
|
|
|
@@ -2282,13 +2197,13 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
if (details != null) {
|
|
|
BigDecimal amountDrM = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrM = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitM = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitM;
|
|
|
BigDecimal amountDrUsdM = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrUsdM = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitUsdM = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitUsdM;
|
|
|
BigDecimal amountDrLocM = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrLocM = new BigDecimal("0.00");
|
|
|
- BigDecimal amountProfitLocM = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitLocM;
|
|
|
amountDrM = amountDrM.add(details.getAmountDr());
|
|
|
amountCrM = amountCrM.add(details.getAmountCr());
|
|
|
amountDrUsdM = amountDrUsdM.add(details.getAmountDrUsd());
|
|
|
@@ -2302,7 +2217,9 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
List<Bills> billsLists = billsList.stream().filter(e -> !e.getId().equals(bills.getId())).collect(Collectors.toList());
|
|
|
if (!billsLists.isEmpty()) {
|
|
|
amountDrM = amountDrM.add(billsLists.stream().map(Bills::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountDrLocM = amountDrLocM.add(billsLists.stream().map(Bills::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
amountCrM = amountCrM.add(billsLists.stream().map(Bills::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountCrLocM = amountCrLocM.add(billsLists.stream().map(Bills::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
amountDrUsdM = amountDrUsdM.add(billsLists.stream().map(Bills::getAmountDrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
amountCrUsdM = amountCrUsdM.add(billsLists.stream().map(Bills::getAmountCrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
}
|
|
|
@@ -2313,8 +2230,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
//利润 = 收 - 付
|
|
|
amountProfitM = amountDrM.subtract(amountCrM);
|
|
|
amountProfitUsdM = amountDrUsdM.subtract(amountCrUsdM);
|
|
|
- amountDrLocM = amountDrLocM.add(bCurrencyService.converterCny("USD", amountDrUsdM, "D", "1")).add(amountDrM);
|
|
|
- amountCrLocM = amountCrLocM.add(bCurrencyService.converterCny("USD", amountCrUsdM, "C", "1")).add(amountCrM);
|
|
|
amountProfitLocM = amountDrLocM.subtract(amountCrLocM);
|
|
|
details.setAmountDr(amountDrM);
|
|
|
details.setAmountCr(amountCrM);
|
|
|
@@ -2331,16 +2246,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
//利润 = 收 - 付
|
|
|
amountProfit = amountDr.subtract(amountCr);
|
|
|
amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
|
|
|
- if (amountDrUsd.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- amountDrLoc = amountDrLoc.add(amountDrUsd.multiply(exrateDUsd).add(amountDr));
|
|
|
- } else {
|
|
|
- amountDrLoc = amountDrLoc.add(amountDr);
|
|
|
- }
|
|
|
- if (amountCrUsd.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- amountCrLoc = amountCrLoc.add(amountCrUsd.multiply(exrateDUsd).add(amountCr));
|
|
|
- } else {
|
|
|
- amountCrLoc = amountCrLoc.add(amountCr);
|
|
|
- }
|
|
|
amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
|
|
|
bills.setAmountDr(amountDr);
|
|
|
bills.setAmountCr(amountCr);
|
|
|
@@ -2585,8 +2490,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
BigDecimal amountProfitLoc;
|
|
|
|
|
|
Date date = new Date();
|
|
|
- BigDecimal exrateC = bCurrencyService.getCnyExrate(date, "USD", "C", "1");
|
|
|
-
|
|
|
//主单应加上分单费用
|
|
|
if ("MM".equals(billsJkNew.getBillType()) && ObjectUtils.isNotNull(billsJkNew.getId())) {
|
|
|
List<Bills> details = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
@@ -2656,11 +2559,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
//利润 = 收 - 付
|
|
|
amountProfit = new BigDecimal("0.00").subtract(amountCr);
|
|
|
amountProfitUsd = new BigDecimal("0.00").subtract(amountCrUsd);
|
|
|
- if (amountCrUsd.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- amountCrLoc = amountCrLoc.add(amountCrUsd.multiply(exrateC)).add(amountCr);
|
|
|
- } else {
|
|
|
- amountCrLoc = amountCrLoc.add(amountCr);
|
|
|
- }
|
|
|
amountProfitLoc = new BigDecimal("0.00").subtract(amountCrLoc);
|
|
|
billsJkNew.setAmountCr(billsJkNew.getAmountCr().add(amountCr));
|
|
|
billsJkNew.setAmountProfit(billsJkNew.getAmountProfit().add(amountProfit));
|
|
|
@@ -2838,8 +2736,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
BigDecimal amountProfitUsd = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrLoc = new BigDecimal("0.00");
|
|
|
BigDecimal amountProfitLoc = new BigDecimal("0.00");
|
|
|
- Date date = new Date();
|
|
|
- BigDecimal exrateC = bCurrencyService.getCnyExrate(date, "USD", "C", "1");
|
|
|
//应收
|
|
|
int statusD = 0;
|
|
|
List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
@@ -2849,6 +2745,9 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
.eq(FeeCenter::getCorpId, billsJk.getForeignAgencyId())
|
|
|
.eq(FeeCenter::getDc, "D")
|
|
|
);
|
|
|
+ Date date = new Date();
|
|
|
+ String exrateType = currencyUtils.standardCurrency();
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1");
|
|
|
if (!feeCenterList.isEmpty()) {
|
|
|
statusD += 1;
|
|
|
for (FeeCenter item : feeCenterList) {
|
|
|
@@ -2874,11 +2773,11 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
// 金额
|
|
|
BigDecimal amount = item.getAmount();
|
|
|
//判断是否是本位币
|
|
|
- if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if (exrateType.equals(item.getCurCode())) {
|
|
|
item.setAmountLoc(amount);
|
|
|
amountCr = amountCr.add(item.getAmount());
|
|
|
} else {
|
|
|
- item.setAmountLoc(amount.multiply(exrateC));
|
|
|
+ item.setAmountLoc(currencyUtils.converter(item.getDc(), curExrateList, amount, item.getCurCode(), "1"));
|
|
|
amountCrUsd = amountCrUsd.add(item.getAmount());
|
|
|
}
|
|
|
item.setAmount(amount);
|