|
...
|
...
|
@@ -235,21 +235,42 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
|
235
|
235
|
if (receiptLedgerInfo == null) {
|
|
236
|
236
|
throw new DefaultClientException("应收款台账明细不存在!");
|
|
237
|
237
|
}
|
|
238
|
|
- // 判断拆分后总数量是否变化
|
|
239
|
|
- List<BigDecimal> splitQuantityList = vo.getSplitQuantityList();
|
|
240
|
|
- boolean match = CommonUtil.isQuantityMatchWithScale(splitQuantityList, receiptLedgerInfo.getStartAccountReceivable(), 4);
|
|
241
|
|
- if (!match) {
|
|
242
|
|
- throw new DefaultClientException("拆分金额总和必须等于原先期初应收账款金额!");
|
|
243
|
|
- }
|
|
244
|
|
- // 封装数据
|
|
245
|
|
- List<ReceiptLedgerInfo> detailList = new ArrayList<>();
|
|
246
|
|
- for (BigDecimal quantity : splitQuantityList) {
|
|
247
|
|
- ReceiptLedgerInfo data = getReceiptLedgerInfo(quantity, receiptLedgerInfo);
|
|
248
|
|
- detailList.add(data);
|
|
249
|
|
- }
|
|
250
|
|
- getBaseMapper().batchAdd(detailList);
|
|
251
|
|
- //删除应收款台账明细(逻辑删除)
|
|
252
|
|
- logicalDelete(id);
|
|
|
238
|
+ if ("DEBT".equals(vo.getType())) {
|
|
|
239
|
+ // 判断拆分后总数量是否变化
|
|
|
240
|
+ List<BigDecimal> splitQuantityList = vo.getSplitQuantityList();
|
|
|
241
|
+ boolean match = CommonUtil.isQuantityMatchWithScale(splitQuantityList, receiptLedgerInfo.getStartAccountReceivable(), 4);
|
|
|
242
|
+ if (!match) {
|
|
|
243
|
+ throw new DefaultClientException("拆分金额总和必须等于原先期初应收账款金额!");
|
|
|
244
|
+ }
|
|
|
245
|
+ // 封装数据
|
|
|
246
|
+ List<ReceiptLedgerInfo> detailList = new ArrayList<>();
|
|
|
247
|
+ for (BigDecimal quantity : splitQuantityList) {
|
|
|
248
|
+ ReceiptLedgerInfo data = getReceiptLedgerInfo(quantity, receiptLedgerInfo, vo.getType());
|
|
|
249
|
+ detailList.add(data);
|
|
|
250
|
+ }
|
|
|
251
|
+ getBaseMapper().batchAdd(detailList);
|
|
|
252
|
+ //删除应收款台账明细(逻辑删除)
|
|
|
253
|
+ logicalDelete(id);
|
|
|
254
|
+ } else if ("DEPOSIT".equals(vo.getType())) {
|
|
|
255
|
+ // 判断拆分后总数量是否变化
|
|
|
256
|
+ List<BigDecimal> returnedAmountList = vo.getReturnedAmountList();
|
|
|
257
|
+ boolean match = CommonUtil.isQuantityMatchWithScale(returnedAmountList, receiptLedgerInfo.getReturnedAmount(), 4);
|
|
|
258
|
+ if (!match) {
|
|
|
259
|
+ throw new DefaultClientException("拆分金额总和必须等于原先回笼资金!");
|
|
|
260
|
+ }
|
|
|
261
|
+ // 封装数据
|
|
|
262
|
+ List<ReceiptLedgerInfo> detailList = new ArrayList<>();
|
|
|
263
|
+ for (BigDecimal quantity : returnedAmountList) {
|
|
|
264
|
+ ReceiptLedgerInfo data = getReceiptLedgerInfo(quantity, receiptLedgerInfo, vo.getType());
|
|
|
265
|
+ detailList.add(data);
|
|
|
266
|
+ }
|
|
|
267
|
+ getBaseMapper().batchAdd(detailList);
|
|
|
268
|
+ //删除应收款台账明细(逻辑删除)
|
|
|
269
|
+ logicalDelete(id);
|
|
|
270
|
+ } else {
|
|
|
271
|
+ throw new DefaultClientException("拆分类型有误!");
|
|
|
272
|
+ }
|
|
|
273
|
+
|
|
253
|
274
|
}
|
|
254
|
275
|
|
|
255
|
276
|
|
|
...
|
...
|
@@ -258,9 +279,10 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
|
258
|
279
|
*
|
|
259
|
280
|
* @param quantity 数量
|
|
260
|
281
|
* @param vo 原数据
|
|
|
282
|
+ * @param type 拆分类型:存款:DEPOSIT 欠款:DEBT
|
|
261
|
283
|
* @return ReceiptLedgerInfo
|
|
262
|
284
|
*/
|
|
263
|
|
- private static ReceiptLedgerInfo getReceiptLedgerInfo(BigDecimal quantity, ReceiptLedgerInfo vo) {
|
|
|
285
|
+ private static ReceiptLedgerInfo getReceiptLedgerInfo(BigDecimal quantity, ReceiptLedgerInfo vo, String type) {
|
|
264
|
286
|
String userId = SecurityUtil.getCurrentUser().getId();
|
|
265
|
287
|
ReceiptLedgerInfo data = new ReceiptLedgerInfo();
|
|
266
|
288
|
data.setId(IdUtil.getId());
|
|
...
|
...
|
@@ -275,13 +297,26 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
|
275
|
297
|
data.setCustomerId(vo.getCustomerId());
|
|
276
|
298
|
data.setFactoryType(vo.getFactoryType());
|
|
277
|
299
|
data.setShipmentDate(vo.getShipmentDate());
|
|
278
|
|
- data.setStartAccountReceivable(quantity);
|
|
|
300
|
+ if ("DEBT".equals(type)) {
|
|
|
301
|
+ data.setStartAccountReceivable(quantity);
|
|
|
302
|
+ } else {
|
|
|
303
|
+ data.setStartAccountReceivable(vo.getStartAccountReceivable());
|
|
|
304
|
+ }
|
|
279
|
305
|
data.setArrivalDate(vo.getArrivalDate());
|
|
280
|
306
|
data.setProcessedDate(vo.getProcessedDate());
|
|
281
|
307
|
data.setActualReturnedDate(vo.getActualReturnedDate());
|
|
282
|
|
- data.setReturnedAmount(vo.getReturnedAmount());
|
|
283
|
|
- //拆分的时候期末应收账款=期初-回笼资金(这时候为0)
|
|
284
|
|
- data.setEndAccountReceivable(quantity);
|
|
|
308
|
+ if ("DEPOSIT".equals(type)) {
|
|
|
309
|
+ data.setReturnedAmount(quantity);
|
|
|
310
|
+ } else {
|
|
|
311
|
+ data.setReturnedAmount(vo.getReturnedAmount());
|
|
|
312
|
+ }
|
|
|
313
|
+ if ("DEBT".equals(type)) {
|
|
|
314
|
+ //欠款拆分的时候期末应收账款=期初-回笼资金(这时候为0)
|
|
|
315
|
+ data.setEndAccountReceivable(quantity);
|
|
|
316
|
+ } else {
|
|
|
317
|
+ //存款拆分的时候期末应收账款=回笼资金取负数
|
|
|
318
|
+ data.setEndAccountReceivable(quantity.negate());
|
|
|
319
|
+ }
|
|
285
|
320
|
data.setApplyStatus(vo.getApplyStatus());
|
|
286
|
321
|
data.setCoordinateDate(vo.getCoordinateDate());
|
|
287
|
322
|
data.setRemark(vo.getRemark());
|
...
|
...
|
|