|
|
@@ -11,6 +11,7 @@ import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
|
import com.dk.mdm.mapper.ivt.OutboundMapper;
|
|
|
import com.dk.mdm.mapper.mac.AccountItemMapper;
|
|
|
+import com.dk.mdm.mapper.mac.OtherReceivableMapper;
|
|
|
import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
|
|
|
import com.dk.mdm.model.pojo.ivt.Inbound;
|
|
|
import com.dk.mdm.model.pojo.ivt.Outbound;
|
|
|
@@ -19,12 +20,11 @@ import com.dk.mdm.mapper.mac.AccountMapper;
|
|
|
import com.dk.common.service.BaseService;
|
|
|
import com.dk.common.mapper.BaseMapper;
|
|
|
import com.dk.mdm.model.pojo.mac.AccountItem;
|
|
|
+import com.dk.mdm.model.pojo.mac.OtherReceivable;
|
|
|
import com.dk.mdm.model.pojo.mst.MoneyAccount;
|
|
|
import com.dk.mdm.model.query.mac.AccountItemQuery;
|
|
|
import com.dk.mdm.model.response.mac.AccountItemResponse;
|
|
|
import com.dk.mdm.model.response.mac.AccountResponse;
|
|
|
-import com.dk.mdm.service.ivt.inbound.InboundService;
|
|
|
-import com.dk.mdm.service.ivt.outbound.OutboundService;
|
|
|
import com.dk.mdm.service.mst.MoneyAccountService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -67,6 +67,9 @@ public class AccountService extends BaseService<Account> {
|
|
|
@Autowired
|
|
|
private InboundMapper inboundMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OtherReceivableMapper otherReceivableMapper;
|
|
|
+
|
|
|
/**
|
|
|
* @desc : 查看来源单据,总单加明细
|
|
|
* @author : 姜永辉
|
|
|
@@ -224,8 +227,34 @@ public class AccountService extends BaseService<Account> {
|
|
|
LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(Outbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Outbound::getOutId, UUID.fromString(invoiceId));
|
|
|
outboundMapper.update(null, updateWrapper);
|
|
|
- } else if ("t_mac_income".equals(biznisType)) {
|
|
|
- // 其它收入单 todo
|
|
|
+ }
|
|
|
+ // 其它收入单
|
|
|
+ else if ("t_mac_other_receivable".equals(biznisType)) {
|
|
|
+ OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
|
|
|
+ objectId = otherReceivable.getObjectId();
|
|
|
+
|
|
|
+ // 当前单据已经记账
|
|
|
+ if (otherReceivable.getAccItemId() != null) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISACC.getMessage());
|
|
|
+ }
|
|
|
+ // 账务日期不能为空
|
|
|
+ if (otherReceivable.getAccDate() == null) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ACC_DATE_ISNULL.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 插入账款明细
|
|
|
+ accountItemInsert.setAccItemType(Constant.accItemType.YING_SHOU.getName())
|
|
|
+ .setObjectId(objectId).setOrgId(otherReceivable.getOrgId()).setStaffId(otherReceivable.getStaffId())
|
|
|
+ .setAccDate(otherReceivable.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName())
|
|
|
+ .setAmtShould(otherReceivable.getSumAmtReceivable()).setAmtResidue(otherReceivable.getSumAmtReceivable())
|
|
|
+ .setBiznisType(biznisType).setBiznisId(otherReceivable.getReceivableId()).setBiznisNo(otherReceivable.getReceivableNo())
|
|
|
+ .setMakeStaff(otherReceivable.getMakeStaff()).setCpId(otherReceivable.getCpId());
|
|
|
+ accountItemMapper.insert(accountItemInsert);
|
|
|
+
|
|
|
+ // 更新出库单上的账款明细Id
|
|
|
+ LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(OtherReceivable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
|
|
|
+ otherReceivableMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
|
|
|
// 更新账款总表上的总应收账款和总剩余应收
|
|
|
@@ -267,8 +296,27 @@ public class AccountService extends BaseService<Account> {
|
|
|
LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(Outbound::getReceivableId, null).eq(Outbound::getOutId, UUID.fromString(invoiceId));
|
|
|
outboundMapper.update(null, updateWrapper);
|
|
|
- } else if ("t_mac_income".equals(biznisType)) {
|
|
|
- // 其它支出单 todo
|
|
|
+ }
|
|
|
+ // 其它收入单
|
|
|
+ else if ("t_mac_other_receivable".equals(biznisType)) {
|
|
|
+ OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
|
|
|
+ objectId = otherReceivable.getObjectId();
|
|
|
+
|
|
|
+ // 当前单据已经记账
|
|
|
+ if (otherReceivable.getAccItemId() == null) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISREVERSE.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ accountItemForUpdate = accountItemMapper.selectByIdForUpdate(otherReceivable.getAccItemId());
|
|
|
+ // 如果核销金额不为0,说明当前单据已核销
|
|
|
+ if (accountItemForUpdate.getAmtHandle().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新出库单上的账款明细Id
|
|
|
+ LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(OtherReceivable::getAccItemId, null).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
|
|
|
+ otherReceivableMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
|
|
|
// 删除账款明细
|