|
|
@@ -181,6 +181,9 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
|
|
|
throw new RuntimeException("未找到到进口单据信息");
|
|
|
}
|
|
|
for (InOutStorage inOutStorage : inOutStorageList) {
|
|
|
+ if ("CK".equals(inOutStorage.getBillType()) && inOutStorage.getOutStorageDate().compareTo(inOutStorage.getChargingDate()) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
PayableStorageFeesItems storageFeesItems = new PayableStorageFeesItemsVO();
|
|
|
Bills bills = billsList.stream().filter(e -> e.getId().equals(inOutStorage.getPid())).findFirst().orElse(null);
|
|
|
if (bills == null) {
|
|
|
@@ -191,10 +194,17 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
|
|
|
storageFeesItems.setBillType(inOutStorage.getBillType());
|
|
|
storageFeesItems.setContractNumber(bills.getBookingNo());
|
|
|
storageFeesItems.setBillNo(bills.getMblno());
|
|
|
- storageFeesItems.setStorageDate(inOutStorage.getStorageDate());
|
|
|
- storageFeesItems.setSurplusQuantity(inOutStorage.getSurplusQuantity());
|
|
|
- storageFeesItems.setSurplusNetWeight(inOutStorage.getSurplusNetWeight());
|
|
|
- storageFeesItems.setSurplusWeight(inOutStorage.getSurplusWeight());
|
|
|
+ if ("CK".equals(inOutStorage.getBillType())) {
|
|
|
+ storageFeesItems.setStorageDate(inOutStorage.getOutStorageDate());
|
|
|
+ storageFeesItems.setSurplusQuantity(inOutStorage.getOutQuantity());
|
|
|
+ storageFeesItems.setSurplusNetWeight(inOutStorage.getOutNetWeight());
|
|
|
+ storageFeesItems.setSurplusWeight(inOutStorage.getOutWeight());
|
|
|
+ } else {
|
|
|
+ storageFeesItems.setStorageDate(inOutStorage.getStorageDate());
|
|
|
+ storageFeesItems.setSurplusQuantity(inOutStorage.getSurplusQuantity());
|
|
|
+ storageFeesItems.setSurplusNetWeight(inOutStorage.getSurplusNetWeight());
|
|
|
+ storageFeesItems.setSurplusWeight(inOutStorage.getSurplusWeight());
|
|
|
+ }
|
|
|
storageFeesItems.setFeeId(fees.getId());
|
|
|
storageFeesItems.setFeeCode(fees.getCode());
|
|
|
storageFeesItems.setFeeCnName(fees.getCnName());
|
|
|
@@ -210,9 +220,9 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
|
|
|
} else {
|
|
|
dateEnd = payableStorageFees.getChargingEndDate();
|
|
|
}
|
|
|
- if (inOutStorage.getChargingDate().compareTo(inOutStorage.getOutStorageDate()) != 0) {
|
|
|
+ /* if (inOutStorage.getChargingDate().compareTo(inOutStorage.getOutStorageDate()) != 0) {
|
|
|
inOutStorage.setChargingDate(calendar.getTime());
|
|
|
- }
|
|
|
+ }*/
|
|
|
diff = dateEnd.getTime() - inOutStorage.getChargingDate().getTime();
|
|
|
} else {
|
|
|
if (new BigDecimal("0.00").compareTo(inOutStorage.getSurplusQuantity()) == 0) {
|
|
|
@@ -236,9 +246,17 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
|
|
|
BigDecimal weight;
|
|
|
BigDecimal amountSum;
|
|
|
if (billingRules) {
|
|
|
- weight = inOutStorage.getSurplusNetWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ if ("CK".equals(inOutStorage.getBillType())) {
|
|
|
+ weight = inOutStorage.getOutNetWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ } else {
|
|
|
+ weight = inOutStorage.getSurplusNetWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
} else {
|
|
|
- weight = inOutStorage.getSurplusWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ if ("CK".equals(inOutStorage.getBillType())) {
|
|
|
+ weight = inOutStorage.getOutWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ } else {
|
|
|
+ weight = inOutStorage.getSurplusWeight().divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
}
|
|
|
BigDecimal dayDecimal = new BigDecimal(day);
|
|
|
amountSum = dayDecimal.multiply(storageFeeItems.getPriceC()).multiply(weight);
|
|
|
@@ -254,6 +272,15 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R confirmSettlement(PayableStorageFees payableStorageFees) {
|
|
|
+ List<PayableStorageFees> lastFeesList = baseMapper.selectList(new LambdaQueryWrapper<PayableStorageFees>()
|
|
|
+ .eq(PayableStorageFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PayableStorageFees::getIsDeleted, 0)
|
|
|
+ .eq(PayableStorageFees::getWarehouseId, payableStorageFees.getWarehouseId())
|
|
|
+ .eq(PayableStorageFees::getStatus, "录入")
|
|
|
+ .ne(PayableStorageFees::getId, payableStorageFees.getId()));
|
|
|
+ if (!lastFeesList.isEmpty()) {
|
|
|
+ throw new RuntimeException("操作失败,为了仓储费计算精准,每个仓库只允许存在一个录入单据。");
|
|
|
+ }
|
|
|
if (payableStorageFees.getStorageFeesItemsList().isEmpty()) {
|
|
|
throw new RuntimeException("明细不能为空");
|
|
|
}
|
|
|
@@ -550,6 +577,18 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R revokeSettlement(PayableStorageFees payableStorageFees) {
|
|
|
+ List<PayableStorageFees> lastFeesList = baseMapper.selectList(new LambdaQueryWrapper<PayableStorageFees>()
|
|
|
+ .eq(PayableStorageFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PayableStorageFees::getIsDeleted, 0)
|
|
|
+ .eq(PayableStorageFees::getWarehouseId, payableStorageFees.getWarehouseId())
|
|
|
+ .ne(PayableStorageFees::getId, payableStorageFees.getId()));
|
|
|
+ if (!lastFeesList.isEmpty()) {
|
|
|
+ for (PayableStorageFees item : lastFeesList) {
|
|
|
+ if (payableStorageFees.getChargingEndDate().compareTo(item.getChargingEndDate()) < 0) {
|
|
|
+ throw new RuntimeException("撤销失败,请按仓储费计费截止时间操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (payableStorageFees.getStorageFeesItemsList().isEmpty()) {
|
|
|
throw new RuntimeException("明细不能为空");
|
|
|
}
|