|
|
@@ -135,6 +135,10 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
if(id.longValue() > 0 ){
|
|
|
String kind = verification.getVc_kind();
|
|
|
verification.setVc_kind(transferKind(kind));
|
|
|
+ verification.setCompanyId(companyId);
|
|
|
+ verification.setUpdateTime(new Date());
|
|
|
+ verification.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
+ verification.setUpdaterId(userId);
|
|
|
verificationMapper.updateByPrimaryKey(verification);
|
|
|
baseDTO = new DocBaseDTO(id, code, BillCodeSeq.VERIFICATION.getCaller());
|
|
|
if (!("AUDITED".equals(verification.getVc_statuscode()))) {
|
|
|
@@ -166,6 +170,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
Verificationdet detail = BeanMapper.map(item,Verificationdet.class);
|
|
|
Long vd_id = detail.getId();
|
|
|
detail.setVd_vcid(id);
|
|
|
+ detail.setVd_id(Math.toIntExact(vd_id));
|
|
|
detail.setCompanyId(companyId);
|
|
|
detail.setVd_ym(numberYM);
|
|
|
if (vd_id>0){
|
|
|
@@ -176,46 +181,47 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
}
|
|
|
for (VerificationdetailDTO item : items2) {
|
|
|
Verificationdetail detail = BeanMapper.map(item,Verificationdetail.class);
|
|
|
+ Long vcd_id = detail.getId();
|
|
|
detail.setVcd_vcid(id);
|
|
|
+ detail.setVcd_id(Math.toIntExact(vcd_id));
|
|
|
detail.setVcd_ym(numberYM);
|
|
|
detail.setCompanyId(companyId);
|
|
|
- Long vcd_id = detail.getId();
|
|
|
if(vcd_id>0){
|
|
|
verificationdetailMapper.updateByPrimaryKey(detail);
|
|
|
}else{
|
|
|
verificationdetailMapper.insertSelective(detail);
|
|
|
}
|
|
|
}
|
|
|
- updateCorrespondingData(formdata);
|
|
|
+ updateCorrespondingData(id);
|
|
|
return baseDTO;
|
|
|
}
|
|
|
|
|
|
- private void updateCorrespondingData(VerificationFormDTO formdata) {
|
|
|
+ private void updateCorrespondingData(Long id) {
|
|
|
//获取主表信息
|
|
|
- VerificationDTO main = formdata.getMain();
|
|
|
+ Verification main = verificationMapper.selectByPrimaryKey(Math.toIntExact(id));
|
|
|
//获取从表1
|
|
|
- List<VerificationdetDTO> items1 = formdata.getItems1();
|
|
|
+ List<Verificationdet> items1 = verificationdetMapper.selectByFK(id);
|
|
|
//获取从表2
|
|
|
- List<VerificationdetailDTO> items2 = formdata.getItems2();
|
|
|
+ List<Verificationdetail> items2 = verificationdetailMapper.selectByFK(id);
|
|
|
|
|
|
String type = main.getVc_kind();
|
|
|
if(type.equals("receipts_offset_receivable") || type.equals("prepaid_offset_payable") ||
|
|
|
type.equals("receivable_offset_payable")){
|
|
|
Double total1 = new Double(0);
|
|
|
- for(VerificationdetDTO det : items1){
|
|
|
+ for(Verificationdet det : items1){
|
|
|
Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
total1 += nowbalanceDet;
|
|
|
|
|
|
//单据金额
|
|
|
Double amount = det.getVd_amount();
|
|
|
//核销金额
|
|
|
- if(amount>0 && nowbalanceDet<0){
|
|
|
+ if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
|
|
|
String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
String error = String.format(msg, det.getVd_slkind());
|
|
|
throw new BizException(code, error);
|
|
|
}
|
|
|
- if(amount<0 && nowbalanceDet>0){
|
|
|
+ if(amount.doubleValue()<0 && nowbalanceDet.doubleValue()>0){
|
|
|
String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
String error = String.format(msg, det.getVd_slkind());
|
|
|
@@ -223,20 +229,20 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
}
|
|
|
}
|
|
|
Double total2 = new Double(0);
|
|
|
- for(VerificationdetailDTO detail : items2){
|
|
|
+ for(Verificationdetail detail : items2){
|
|
|
Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
|
|
|
total2 += nowbalanceDet;
|
|
|
|
|
|
//单据金额
|
|
|
Double amount = detail.getVcd_amount();
|
|
|
//核销金额
|
|
|
- if(amount>0 && nowbalanceDet<0){
|
|
|
+ if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
|
|
|
String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
String error = String.format(msg, detail.getVcd_slkind());
|
|
|
throw new BizException(code, error);
|
|
|
}
|
|
|
- if(amount<0 && nowbalanceDet>0){
|
|
|
+ if(amount.doubleValue()<0 && nowbalanceDet.doubleValue()>0){
|
|
|
String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
|
|
|
int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
|
|
|
String error = String.format(msg, detail.getVcd_slkind());
|
|
|
@@ -247,10 +253,10 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
|
|
|
}
|
|
|
}else if(type.equals("receivable_to_receivable") || type.equals("payable_to_payable")){
|
|
|
- for(VerificationdetDTO det : items1){
|
|
|
+ for(Verificationdet det : items1){
|
|
|
Double namount = det.getSl_namount()==null?new Double(0):det.getSl_namount();
|
|
|
Double nowbalance = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
|
|
|
- if(namount<nowbalance){
|
|
|
+ if(namount.doubleValue()<nowbalance.doubleValue()){
|
|
|
throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -403,7 +409,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
public void deleteDetail1(Long id) {
|
|
|
if (null != id) {
|
|
|
Verificationdet verificationdet = verificationdetMapper.selectByPrimaryKey(Integer.valueOf(String.valueOf(id)));
|
|
|
- Verification verification = verificationMapper.selectByPrimaryKey(verificationdet.getVd_vcid());
|
|
|
+ Verification verification = verificationMapper.selectByPrimaryKey(Math.toIntExact(verificationdet.getVd_vcid()));
|
|
|
DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
baseDTO.setId(id);
|
|
|
baseDTO.setCode(verification.getVc_code());
|