|
@@ -11,6 +11,7 @@ import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
|
import com.dk.mdm.mapper.ivt.OutboundMapper;
|
|
import com.dk.mdm.mapper.ivt.OutboundMapper;
|
|
|
import com.dk.mdm.mapper.mac.AccountItemMapper;
|
|
import com.dk.mdm.mapper.mac.AccountItemMapper;
|
|
|
|
|
+import com.dk.mdm.mapper.mac.OtherPayableMapper;
|
|
|
import com.dk.mdm.mapper.mac.OtherReceivableMapper;
|
|
import com.dk.mdm.mapper.mac.OtherReceivableMapper;
|
|
|
import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
|
|
import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
|
|
|
import com.dk.mdm.model.pojo.ivt.Inbound;
|
|
import com.dk.mdm.model.pojo.ivt.Inbound;
|
|
@@ -20,6 +21,7 @@ import com.dk.mdm.mapper.mac.AccountMapper;
|
|
|
import com.dk.common.service.BaseService;
|
|
import com.dk.common.service.BaseService;
|
|
|
import com.dk.common.mapper.BaseMapper;
|
|
import com.dk.common.mapper.BaseMapper;
|
|
|
import com.dk.mdm.model.pojo.mac.AccountItem;
|
|
import com.dk.mdm.model.pojo.mac.AccountItem;
|
|
|
|
|
+import com.dk.mdm.model.pojo.mac.OtherPayable;
|
|
|
import com.dk.mdm.model.pojo.mac.OtherReceivable;
|
|
import com.dk.mdm.model.pojo.mac.OtherReceivable;
|
|
|
import com.dk.mdm.model.pojo.mst.MoneyAccount;
|
|
import com.dk.mdm.model.pojo.mst.MoneyAccount;
|
|
|
import com.dk.mdm.model.query.mac.AccountItemQuery;
|
|
import com.dk.mdm.model.query.mac.AccountItemQuery;
|
|
@@ -70,6 +72,9 @@ public class AccountService extends BaseService<Account> {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OtherReceivableMapper otherReceivableMapper;
|
|
private OtherReceivableMapper otherReceivableMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OtherPayableMapper otherPayableMapper;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @desc : 查看来源单据,总单加明细
|
|
* @desc : 查看来源单据,总单加明细
|
|
|
* @author : 姜永辉
|
|
* @author : 姜永辉
|
|
@@ -223,12 +228,12 @@ public class AccountService extends BaseService<Account> {
|
|
|
.setMakeStaff(outbound.getMakeStaff()).setCpId(outbound.getCpId());
|
|
.setMakeStaff(outbound.getMakeStaff()).setCpId(outbound.getCpId());
|
|
|
accountItemMapper.insert(accountItemInsert);
|
|
accountItemMapper.insert(accountItemInsert);
|
|
|
|
|
|
|
|
- // 更新出库单上的账款明细Id
|
|
|
|
|
|
|
+ // 更新源单上的账款明细Id
|
|
|
LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(Outbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Outbound::getOutId, UUID.fromString(invoiceId));
|
|
updateWrapper.set(Outbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Outbound::getOutId, UUID.fromString(invoiceId));
|
|
|
outboundMapper.update(null, updateWrapper);
|
|
outboundMapper.update(null, updateWrapper);
|
|
|
}
|
|
}
|
|
|
- // 其它收入单
|
|
|
|
|
|
|
+ // 其他收入单
|
|
|
else if ("t_mac_other_receivable".equals(biznisType)) {
|
|
else if ("t_mac_other_receivable".equals(biznisType)) {
|
|
|
OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
|
|
OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
|
|
|
objectId = otherReceivable.getObjectId();
|
|
objectId = otherReceivable.getObjectId();
|
|
@@ -251,7 +256,7 @@ public class AccountService extends BaseService<Account> {
|
|
|
.setMakeStaff(otherReceivable.getMakeStaff()).setCpId(otherReceivable.getCpId());
|
|
.setMakeStaff(otherReceivable.getMakeStaff()).setCpId(otherReceivable.getCpId());
|
|
|
accountItemMapper.insert(accountItemInsert);
|
|
accountItemMapper.insert(accountItemInsert);
|
|
|
|
|
|
|
|
- // 更新出库单上的账款明细Id
|
|
|
|
|
|
|
+ // 更新源单上的账款明细Id
|
|
|
LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(OtherReceivable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
|
|
updateWrapper.set(OtherReceivable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
|
|
|
otherReceivableMapper.update(null, updateWrapper);
|
|
otherReceivableMapper.update(null, updateWrapper);
|
|
@@ -292,12 +297,12 @@ public class AccountService extends BaseService<Account> {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 将出库单上的账款明细Id更为null
|
|
|
|
|
|
|
+ // 将源单上的账款明细Id更为null
|
|
|
LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(Outbound::getReceivableId, null).eq(Outbound::getOutId, UUID.fromString(invoiceId));
|
|
updateWrapper.set(Outbound::getReceivableId, null).eq(Outbound::getOutId, UUID.fromString(invoiceId));
|
|
|
outboundMapper.update(null, updateWrapper);
|
|
outboundMapper.update(null, updateWrapper);
|
|
|
}
|
|
}
|
|
|
- // 其它收入单
|
|
|
|
|
|
|
+ // 其他收入单
|
|
|
else if ("t_mac_other_receivable".equals(biznisType)) {
|
|
else if ("t_mac_other_receivable".equals(biznisType)) {
|
|
|
OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
|
|
OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
|
|
|
objectId = otherReceivable.getObjectId();
|
|
objectId = otherReceivable.getObjectId();
|
|
@@ -313,7 +318,7 @@ public class AccountService extends BaseService<Account> {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 更新出库单上的账款明细Id
|
|
|
|
|
|
|
+ // 更新源单上的账款明细Id
|
|
|
LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(OtherReceivable::getAccItemId, null).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
|
|
updateWrapper.set(OtherReceivable::getAccItemId, null).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
|
|
|
otherReceivableMapper.update(null, updateWrapper);
|
|
otherReceivableMapper.update(null, updateWrapper);
|
|
@@ -363,12 +368,38 @@ public class AccountService extends BaseService<Account> {
|
|
|
.setMakeStaff(inbound.getMakeStaff()).setCpId(inbound.getCpId());
|
|
.setMakeStaff(inbound.getMakeStaff()).setCpId(inbound.getCpId());
|
|
|
accountItemMapper.insert(accountItemInsert);
|
|
accountItemMapper.insert(accountItemInsert);
|
|
|
|
|
|
|
|
- // 更新出库单上的账款明细Id
|
|
|
|
|
|
|
+ // 更新源单上的账款明细Id
|
|
|
LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(Inbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
|
|
updateWrapper.set(Inbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
|
|
|
inboundMapper.update(null, updateWrapper);
|
|
inboundMapper.update(null, updateWrapper);
|
|
|
- } else if ("t_mac_outlay".equals(biznisType)) {
|
|
|
|
|
- // 其它支出单 todo
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 其他支出单
|
|
|
|
|
+ else if ("t_mac_other_payable".equals(biznisType)) {
|
|
|
|
|
+ OtherPayable otherPayable = otherPayableMapper.selectByIdForUpdate(invoiceId);
|
|
|
|
|
+ objectId = otherPayable.getObjectId();
|
|
|
|
|
+
|
|
|
|
|
+ // 当前单据已经记账
|
|
|
|
|
+ if (otherPayable.getAccItemId() != null) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISACC.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 账务日期不能为空
|
|
|
|
|
+ if (otherPayable.getAccDate() == null) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ACC_DATE_ISNULL.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 插入账款明细
|
|
|
|
|
+ accountItemInsert.setAccItemType(Constant.accItemType.YING_SHOU.getName())
|
|
|
|
|
+ .setObjectId(objectId).setOrgId(otherPayable.getOrgId()).setStaffId(otherPayable.getStaffId())
|
|
|
|
|
+ .setAccDate(otherPayable.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName())
|
|
|
|
|
+ .setAmtShould(otherPayable.getSumAmtPayable()).setAmtResidue(otherPayable.getSumAmtPayable())
|
|
|
|
|
+ .setBiznisType(biznisType).setBiznisId(otherPayable.getPayableId()).setBiznisNo(otherPayable.getPayableNo())
|
|
|
|
|
+ .setMakeStaff(otherPayable.getMakeStaff()).setCpId(otherPayable.getCpId());
|
|
|
|
|
+ accountItemMapper.insert(accountItemInsert);
|
|
|
|
|
+
|
|
|
|
|
+ // 更新源单上的账款明细Id
|
|
|
|
|
+ LambdaUpdateWrapper<OtherPayable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.set(OtherPayable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherPayable::getPayableId, UUID.fromString(invoiceId));
|
|
|
|
|
+ otherPayableMapper.update(null, updateWrapper);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新账款总表上的总应收账款和总剩余应收
|
|
// 更新账款总表上的总应收账款和总剩余应收
|
|
@@ -410,8 +441,27 @@ public class AccountService extends BaseService<Account> {
|
|
|
LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<Inbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(Inbound::getReceivableId, null).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
|
|
updateWrapper.set(Inbound::getReceivableId, null).eq(Inbound::getIntoId, UUID.fromString(invoiceId));
|
|
|
inboundMapper.update(null, updateWrapper);
|
|
inboundMapper.update(null, updateWrapper);
|
|
|
- } else if ("t_mac_outlay".equals(biznisType)) {
|
|
|
|
|
- // 其它支出单 todo
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 其他支出单
|
|
|
|
|
+ else if ("t_mac_other_payable".equals(biznisType)) {
|
|
|
|
|
+ OtherPayable otherPayable = otherPayableMapper.selectByIdForUpdate(invoiceId);
|
|
|
|
|
+ objectId = otherPayable.getObjectId();
|
|
|
|
|
+
|
|
|
|
|
+ // 当前单据已经记账
|
|
|
|
|
+ if (otherPayable.getAccItemId() == null) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISREVERSE.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ accountItemForUpdate = accountItemMapper.selectByIdForUpdate(otherPayable.getAccItemId());
|
|
|
|
|
+ // 如果核销金额不为0,说明当前单据已核销
|
|
|
|
|
+ if (accountItemForUpdate.getAmtHandle().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 更新源单上的账款明细Id
|
|
|
|
|
+ LambdaUpdateWrapper<OtherPayable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.set(OtherPayable::getAccItemId, null).eq(OtherPayable::getPayableId, UUID.fromString(invoiceId));
|
|
|
|
|
+ otherPayableMapper.update(null, updateWrapper);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 删除账款明细
|
|
// 删除账款明细
|