|
|
@@ -37,6 +37,7 @@ import lombok.Data;
|
|
|
import org.springblade.client.entity.*;
|
|
|
import org.springblade.client.feign.*;
|
|
|
import org.springblade.client.vo.GoodsDescVO;
|
|
|
+import org.springblade.common.config.MD5Util;
|
|
|
import org.springblade.common.dto.token2DTO;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
@@ -67,7 +68,6 @@ import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springblade.common.config.MD5Util;
|
|
|
|
|
|
import javax.net.ssl.*;
|
|
|
import java.io.*;
|
|
|
@@ -1517,6 +1517,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
StringBuilder purchaseOrderNo = new StringBuilder();
|
|
|
BigDecimal deliveryAmount = new BigDecimal("0.00");
|
|
|
BigDecimal purchaseTotalAmount = new BigDecimal("0.00");
|
|
|
+ BigDecimal costAmount = new BigDecimal("0.00");
|
|
|
String[] deliveryIds = ids.split(",");
|
|
|
List<Delivery> deliveryList = baseMapper.selectBatchIds(Arrays.asList(deliveryIds));
|
|
|
List<Long> corpIds = deliveryList.stream().map(Delivery::getCorpId).distinct().collect(Collectors.toList());
|
|
|
@@ -1557,9 +1558,26 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
.eq(DeliveryItems::getPid, delivery.getId())
|
|
|
.eq(DeliveryItems::getIsDeleted, 0);
|
|
|
List<DeliveryItems> deliveryItems = deliveryItemsMapper.selectList(deliveryItemsLambdaQueryWrapper);
|
|
|
- BigDecimal pricetotal1 = deliveryItems.stream().map(DeliveryItems::getDeliveryAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal pricetotal1 = new BigDecimal("0.00");
|
|
|
+ //逐条货物计算税
|
|
|
+ for (DeliveryItems item : deliveryItems) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getDeliveryAmount()) && !new BigDecimal("0.00").equals(item.getDeliveryAmount())) {
|
|
|
+ costAmount = costAmount.add(item.getDeliveryAmount().divide(new BigDecimal("1.13"), MathContext.DECIMAL32)
|
|
|
+ .multiply(new BigDecimal("0.13")).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ pricetotal1 = pricetotal1.add(item.getDeliveryAmount());
|
|
|
+ } else {
|
|
|
+ costAmount = costAmount.add(new BigDecimal("0.00"));
|
|
|
+ pricetotal1 = pricetotal1.add(new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+// BigDecimal pricetotal1 = deliveryItems.stream().map(DeliveryItems::getDeliveryAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//明细总采购价
|
|
|
purchaseTotalAmount = purchaseTotalAmount.add(CollectionUtils.isEmpty(deliveryItems) ? new BigDecimal("0.00") : pricetotal1);
|
|
|
+ //总货物税减去返利税
|
|
|
+ if (ObjectUtils.isNotNull(delivery.getThisUsedProfit()) && !new BigDecimal("0.00").equals(delivery.getThisUsedProfit())) {
|
|
|
+ costAmount = costAmount.subtract(delivery.getThisUsedProfit().divide(new BigDecimal("1.13"), MathContext.DECIMAL32)
|
|
|
+ .multiply(new BigDecimal("0.13")).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
purchaseTotalAmount = purchaseTotalAmount.subtract(delivery.getThisUsedProfit());
|
|
|
R<FeesDesc> r = feesDescClient.getFeesByName("包装费");
|
|
|
if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
@@ -1568,12 +1586,20 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
.eq(DeliveryFees::getPid, delivery.getId())
|
|
|
.eq(DeliveryFees::getIsDeleted, 0);
|
|
|
List<DeliveryFees> deliveryFeesList = deliveryFeesService.list(deliveryFeesLambdaQueryWrapper);
|
|
|
- BigDecimal amount = deliveryFeesList.stream().map(DeliveryFees::getAmount).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- purchaseTotalAmount = purchaseTotalAmount.add(amount);
|
|
|
- /*BigDecimal amount = deliveryFeesList.stream().filter(e -> e.getItemId().equals(r.getData().getId()) && ObjectUtils.isNotNull(e.getAmount())).map(DeliveryFees::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal amount = new BigDecimal("0.00");
|
|
|
+ //逐条计算费用税
|
|
|
+ for (DeliveryFees item : deliveryFeesList) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getAmount()) && !new BigDecimal("0.00").equals(item.getAmount())) {
|
|
|
+ costAmount = costAmount.add(item.getAmount().divide(new BigDecimal("1.13"), MathContext.DECIMAL32)
|
|
|
+ .multiply(new BigDecimal("0.13")).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ amount = amount.add(item.getAmount());
|
|
|
+ } else {
|
|
|
+ costAmount = costAmount.add(new BigDecimal("0.00"));
|
|
|
+ amount = amount.add(new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+// BigDecimal amount = deliveryFeesList.stream().map(DeliveryFees::getAmount).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
purchaseTotalAmount = purchaseTotalAmount.add(amount);
|
|
|
- BigDecimal amount1 = deliveryFeesList.stream().filter(e -> !e.getItemId().equals(r.getData().getId()) && ObjectUtils.isNotNull(e.getAmount())).map(DeliveryFees::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- purchaseTotalAmount = purchaseTotalAmount.subtract(amount1);*/
|
|
|
}
|
|
|
}
|
|
|
deliveryAmount = purchaseTotalAmount;
|
|
|
@@ -1607,7 +1633,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
}
|
|
|
//测试账套-收货生成凭证
|
|
|
Delivery delivery = this.testDeliverGoodsSaveVoucher(null, null, accountName, corpName, corpNumber, null, purchaseTotalAmount.toString(),
|
|
|
- deliveryAmount.toString(), saleOrderNoNew, purchaseOrderNoNew);
|
|
|
+ deliveryAmount.toString(), costAmount, saleOrderNoNew, purchaseOrderNoNew);
|
|
|
if (null != delivery) {
|
|
|
for (Delivery delivery1 : deliveryList) {
|
|
|
delivery1.setVoucherId(delivery.getVoucherId());
|
|
|
@@ -1671,7 +1697,9 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
}
|
|
|
|
|
|
//发货生成凭证
|
|
|
- public Delivery testDeliverGoodsSaveVoucher(String brand, Delivery delivery, String accountName, String copsName, String corpNumber, String warehouse, String purchaseTotalAmount, String deliveryAmount, String saleOrderNo, String purchaseOrder) throws Exception {
|
|
|
+ public Delivery testDeliverGoodsSaveVoucher(String brand, Delivery delivery, String accountName, String copsName,
|
|
|
+ String corpNumber, String warehouse, String purchaseTotalAmount, String deliveryAmount, BigDecimal costAmount,
|
|
|
+ String saleOrderNo, String purchaseOrder) throws Exception {
|
|
|
// TODO 临时屏蔽
|
|
|
// if (!"test".equals(AuthUtil.getTenantId())) {
|
|
|
// return;
|
|
|
@@ -1720,7 +1748,9 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
if (null == delivery) {
|
|
|
delivery = new Delivery();
|
|
|
}
|
|
|
- JdyTool.voucher voucher = toDeliverJinDie(brand, ObjectUtils.isNotNull(delivery.getBusinessDate()) ? delivery.getBusinessDate() : new Date(), saleOrderNo, purchaseOrder, purchaseTotalAmount, deliveryAmount, copsName, corpNumber, warehouse, jdTenant.getAccountId(), group.getGroupName(), jdTenant);
|
|
|
+ JdyTool.voucher voucher = toDeliverJinDie(brand, ObjectUtils.isNotNull(delivery.getBusinessDate()) ? delivery.getBusinessDate() : new Date(),
|
|
|
+ saleOrderNo, purchaseOrder, purchaseTotalAmount, deliveryAmount, costAmount, copsName, corpNumber, warehouse,
|
|
|
+ jdTenant.getAccountId(), group.getGroupName(), jdTenant);
|
|
|
if (voucher == null) {
|
|
|
throw new SecurityException("获取凭证信息失败");
|
|
|
}
|
|
|
@@ -1771,7 +1801,8 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
return;
|
|
|
}
|
|
|
//2.收货,组装model,保存凭证
|
|
|
- JdyTool.voucher voucher = toTakeJinDie(brand, delivery.getBusinessDate(), orderNo, acoount, copsName, corpNumber, warehouse, jdTenant.getAccountId(), group.getGroupName(), jdTenant);
|
|
|
+ JdyTool.voucher voucher = toTakeJinDie(brand, delivery.getBusinessDate(), orderNo, acoount,
|
|
|
+ copsName, corpNumber, warehouse, jdTenant.getAccountId(), group.getGroupName(), jdTenant);
|
|
|
if (voucher == null) {
|
|
|
throw new SecurityException("获取凭证信息失败");
|
|
|
}
|
|
|
@@ -1779,12 +1810,14 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
|
|
delivery.setVoucherId(voucher.getVoucherno());
|
|
|
}
|
|
|
|
|
|
- public JdyTool.voucher toDeliverJinDie(String brand, Date date, String saleOrderNo, String purchaseOrder, String purchaseTotalAmount, String deliveryAmount, String copsName, String corpNumber, String warehouse, String accountId, String groupName, JdTenant jdTenant) {
|
|
|
+ public JdyTool.voucher toDeliverJinDie(String brand, Date date, String saleOrderNo, String purchaseOrder,
|
|
|
+ String purchaseTotalAmount, String deliveryAmount, BigDecimal costAmount,
|
|
|
+ String copsName, String corpNumber, String warehouse, String accountId,
|
|
|
+ String groupName, JdTenant jdTenant) {
|
|
|
|
|
|
|
|
|
BigDecimal amount = new BigDecimal(deliveryAmount);
|
|
|
- BigDecimal costAmount = amount.divide(new BigDecimal("1.13"), MathContext.DECIMAL32).multiply(new BigDecimal("0.13")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal amount2 = amount.subtract(costAmount.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ BigDecimal amount2 = amount.subtract(costAmount.setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
List<JDYitems> jdYitems = new ArrayList<>();
|
|
|
//凭证1
|
|
|
JDYitems item1 = new JDYitems();
|