|
|
@@ -567,17 +567,15 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
baseDTO = this.saveFormData(formData);
|
|
|
Long id = baseDTO.getId();
|
|
|
|
|
|
- VerificationDTO verificationDTO = formData.getMain();
|
|
|
-
|
|
|
- Subledger subledger = changSubledgerUntil(verificationDTO, 1);
|
|
|
- subledgerMapper.insertSelective(subledger);
|
|
|
+ VerificationDTO verificationDTO = formData.getMain();
|
|
|
|
|
|
+ Subledger subledger = changSubledgerUntil(verificationDTO, 1);
|
|
|
+ subledgerMapper.insertSelective(subledger);
|
|
|
if ("receivable_to_receivable".equals(verificationDTO.getVc_kind()) ||
|
|
|
"receivable_offset_payable".equals(verificationDTO.getVc_kind())
|
|
|
|| "payable_to_payable".equals(verificationDTO.getVc_kind())){
|
|
|
Subledger subledger1 = changSubledgerUntil(verificationDTO,2);
|
|
|
subledgerMapper.insertSelective(subledger1);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//更新客户或者供应商的金额
|
|
|
@@ -620,81 +618,118 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
*/
|
|
|
private void updateAuditCustomer(VerificationDTO verificationDTO){
|
|
|
String kind = verificationDTO.getVc_kind();
|
|
|
- if(kind.equals("receipts_offset_receivable")){
|
|
|
- Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
- Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
- Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
- Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
- Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
-
|
|
|
- Customer customer = new Customer();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
- customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- customer.setUpdateTime(new Date());
|
|
|
- customer.setCu_preamount(preamount-amount1);
|
|
|
- customer.setCu_recamount(recamount-amount2);
|
|
|
- customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amount2-(preamount-amount1));
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
- }else if(kind.equals("receivable_offset_payable")){
|
|
|
- Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
- Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
- Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
- Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
- Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
-
|
|
|
- Customer customer = new Customer();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
- customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- customer.setUpdateTime(new Date());
|
|
|
- customer.setCu_recamount(recamount-amount1);
|
|
|
- customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amount1-preamount);
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
- }else if(kind.equals("receivable_to_receivable")){
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ if(kind.equals("receipts_offset_receivable")){//预收冲应收
|
|
|
+ String con="ca_custid="+verificationDTO.getVc_custid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount custar=recbalanceMapper.selectCustArByCondition(con,companyId);
|
|
|
+ if (custar == null){
|
|
|
+ custar=new CustAramount();
|
|
|
+ custar.setCa_custid(verificationDTO.getVc_custid());
|
|
|
+ custar.setCa_custcode(verificationDTO.getVc_custcode());
|
|
|
+ custar.setCa_custname(verificationDTO.getVc_custname());
|
|
|
+ custar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ custar.setCa_begindate(null);
|
|
|
+ custar.setCa_beginprerecamount(new Double(0));
|
|
|
+ custar.setCa_beginaramount(new Double(0));
|
|
|
+ custar.setCa_preamount(new Double(0)-amount1);
|
|
|
+ custar.setCa_recamount(new Double(0)-amount2);
|
|
|
+ custar.setCa_leftamount(new Double(0)-amount2+amount1);
|
|
|
+ custar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(custar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = custar.getCa_preamount()==null?new Double(0):custar.getCa_preamount();
|
|
|
+ Double carecamount = custar.getCa_recamount()==null?new Double(0):custar.getCa_recamount();
|
|
|
+ Double caleftamount = custar.getCa_leftamount()==null?new Double(0):custar.getCa_leftamount();
|
|
|
+ custar.setCa_preamount(capreamount-amount1);
|
|
|
+ custar.setCa_recamount(carecamount-amount2);
|
|
|
+ custar.setCa_leftamount(caleftamount-amount2+amount1);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(custar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+ }else if(kind.equals("receivable_offset_payable")){//应收冲应付
|
|
|
+ String con="ca_custid="+verificationDTO.getVc_custid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount custar=recbalanceMapper.selectCustArByCondition(con,companyId);
|
|
|
+ if (custar == null){
|
|
|
+ custar=new CustAramount();
|
|
|
+ custar.setCa_custid(verificationDTO.getVc_custid());
|
|
|
+ custar.setCa_custcode(verificationDTO.getVc_custcode());
|
|
|
+ custar.setCa_custname(verificationDTO.getVc_custname());
|
|
|
+ custar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ custar.setCa_begindate(null);
|
|
|
+ custar.setCa_beginprerecamount(new Double(0));
|
|
|
+ custar.setCa_beginaramount(new Double(0));
|
|
|
+ custar.setCa_preamount(new Double(0));
|
|
|
+ custar.setCa_recamount(new Double(0)-amount1);
|
|
|
+ custar.setCa_leftamount(new Double(0)-amount1);
|
|
|
+ custar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(custar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = custar.getCa_preamount()==null?new Double(0):custar.getCa_preamount();
|
|
|
+ Double carecamount = custar.getCa_recamount()==null?new Double(0):custar.getCa_recamount();
|
|
|
+ Double caleftamount = custar.getCa_leftamount()==null?new Double(0):custar.getCa_leftamount();
|
|
|
+ custar.setCa_preamount(capreamount);
|
|
|
+ custar.setCa_recamount(carecamount-amount1);
|
|
|
+ custar.setCa_leftamount(caleftamount-amount1);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(custar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
+ }else if(kind.equals("receivable_to_receivable")){//应收转应收
|
|
|
//转入客户
|
|
|
- Customer customerIn = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_turncustid());
|
|
|
+ String inCon="ca_custid="+verificationDTO.getVc_turncustid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount inCustar=recbalanceMapper.selectCustArByCondition(inCon,companyId);
|
|
|
+ if (inCustar == null){
|
|
|
+ inCustar=new CustAramount();
|
|
|
+ inCustar.setCa_custid(verificationDTO.getVc_turncustid());
|
|
|
+ inCustar.setCa_custcode(verificationDTO.getVc_turncustcode());
|
|
|
+ inCustar.setCa_custname(verificationDTO.getVc_turncustname());
|
|
|
+ inCustar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ inCustar.setCa_begindate(null);
|
|
|
+ inCustar.setCa_beginprerecamount(new Double(0));
|
|
|
+ inCustar.setCa_beginaramount(new Double(0));
|
|
|
+ inCustar.setCa_preamount(new Double(0));
|
|
|
+ inCustar.setCa_recamount(new Double(0)+amount1);
|
|
|
+ inCustar.setCa_leftamount(new Double(0)+amount1);
|
|
|
+ inCustar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(inCustar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = inCustar.getCa_preamount()==null?new Double(0):inCustar.getCa_preamount();
|
|
|
+ Double carecamount = inCustar.getCa_recamount()==null?new Double(0):inCustar.getCa_recamount();
|
|
|
+ Double caleftamount = inCustar.getCa_leftamount()==null?new Double(0):inCustar.getCa_leftamount();
|
|
|
+ inCustar.setCa_preamount(capreamount);
|
|
|
+ inCustar.setCa_recamount(carecamount+amount1);
|
|
|
+ inCustar.setCa_leftamount(caleftamount+amount1);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(inCustar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_turncustid());
|
|
|
//转出客户
|
|
|
- Customer customerOut = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
-
|
|
|
- Double preamountIn = customerIn.getCu_preamount()==null?new Double(0):customerIn.getCu_preamount();
|
|
|
- Double beginapamountIn = customerIn.getCu_beginaramount()==null?new Double(0):customerIn.getCu_beginaramount();
|
|
|
- Double beginprepayamountIn = customerIn.getCu_beginprerecamount()==null?new Double(0):customerIn.getCu_beginprerecamount();
|
|
|
- Double recamountIn = customerIn.getCu_recamount()==null?new Double(0):customerIn.getCu_recamount();
|
|
|
-
|
|
|
- Double preamountOut = customerOut.getCu_preamount()==null?new Double(0):customerOut.getCu_preamount();
|
|
|
- Double beginapamountOut = customerOut.getCu_beginaramount()==null?new Double(0):customerOut.getCu_beginaramount();
|
|
|
- Double beginprepayamountOut = customerOut.getCu_beginprerecamount()==null?new Double(0):customerOut.getCu_beginprerecamount();
|
|
|
- Double recamountOut = customerOut.getCu_recamount()==null?new Double(0):customerOut.getCu_recamount();
|
|
|
-
|
|
|
-
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- Customer newCustomerIn = new Customer();
|
|
|
- newCustomerIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turncustid())));
|
|
|
- newCustomerIn.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- newCustomerIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newCustomerIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newCustomerIn.setUpdateTime(new Date());
|
|
|
- newCustomerIn.setCu_recamount(recamountIn+amount1);
|
|
|
- newCustomerIn.setCu_leftamount(beginapamountIn-beginprepayamountIn+recamountIn+amount1-preamountIn);
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerIn);
|
|
|
-
|
|
|
- Customer newCustomerOut = new Customer();
|
|
|
- newCustomerOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
- newCustomerOut.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- newCustomerOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newCustomerOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newCustomerOut.setUpdateTime(new Date());
|
|
|
- newCustomerOut.setCu_recamount(recamountOut-amount1);
|
|
|
- newCustomerOut.setCu_leftamount(beginapamountOut-beginprepayamountOut+recamountOut-amount1-preamountOut);
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerOut);
|
|
|
+ String outCon="ca_custid="+verificationDTO.getVc_custid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount outCustar=recbalanceMapper.selectCustArByCondition(outCon,companyId);
|
|
|
+ if (outCustar == null){
|
|
|
+ outCustar=new CustAramount();
|
|
|
+ outCustar.setCa_custid(verificationDTO.getVc_custid());
|
|
|
+ outCustar.setCa_custcode(verificationDTO.getVc_custcode());
|
|
|
+ outCustar.setCa_custname(verificationDTO.getVc_custname());
|
|
|
+ outCustar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ outCustar.setCa_begindate(null);
|
|
|
+ outCustar.setCa_beginprerecamount(new Double(0));
|
|
|
+ outCustar.setCa_beginaramount(new Double(0));
|
|
|
+ outCustar.setCa_preamount(new Double(0));
|
|
|
+ outCustar.setCa_recamount(new Double(0)-amount1);
|
|
|
+ outCustar.setCa_leftamount(new Double(0)-amount1);
|
|
|
+ outCustar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(outCustar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = outCustar.getCa_preamount()==null?new Double(0):outCustar.getCa_preamount();
|
|
|
+ Double carecamount = outCustar.getCa_recamount()==null?new Double(0):outCustar.getCa_recamount();
|
|
|
+ Double caleftamount = outCustar.getCa_leftamount()==null?new Double(0):outCustar.getCa_leftamount();
|
|
|
+ outCustar.setCa_preamount(capreamount);
|
|
|
+ outCustar.setCa_recamount(carecamount-amount1);
|
|
|
+ outCustar.setCa_leftamount(caleftamount-amount1);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(outCustar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -704,81 +739,119 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
* @return
|
|
|
*/
|
|
|
private void updateAuditVendor(VerificationDTO verificationDTO){
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
String kind = verificationDTO.getVc_kind();
|
|
|
- if(kind.equals("prepaid_offset_payable")){
|
|
|
- Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
- Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
- Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
- Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
- Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
-
|
|
|
- Vendor vendor = new Vendor();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
- vendor.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- vendor.setUpdateTime(new Date());
|
|
|
- vendor.setVe_preamount(preamount-amount1);
|
|
|
- vendor.setVe_payamount(payamount-amount2);
|
|
|
- vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-amount2-(preamount-amount1));
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
- }else if(kind.equals("receivable_offset_payable")){
|
|
|
- Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
- Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
- Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
- Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
- Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
-
|
|
|
- Vendor vendor = new Vendor();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
- vendor.setVe_payamount(payamount-amount2);
|
|
|
- vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- vendor.setUpdateTime(new Date());
|
|
|
- vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-amount2-preamount);
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
- }else if(kind.equals("payable_to_payable")){
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ if(kind.equals("prepaid_offset_payable")){//预付冲应付
|
|
|
+ String con="va_vendid="+verificationDTO.getVc_vendid()+" and va_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ VendApamount vendap=paybalanceMapper.selectVendApByCondition(con,companyId);
|
|
|
+ if(vendap == null){
|
|
|
+ vendap=new VendApamount();
|
|
|
+ vendap.setVa_vendid(verificationDTO.getVc_vendid());
|
|
|
+ vendap.setVa_vendcode(verificationDTO.getVc_vendcode());
|
|
|
+ vendap.setVa_vendname(verificationDTO.getVc_vendname());
|
|
|
+ vendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ vendap.setVa_begindate(null);
|
|
|
+ vendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ vendap.setVa_beginapamount(new Double(0));
|
|
|
+ vendap.setVa_preamount(new Double(0)-amount1);
|
|
|
+ vendap.setVa_payamount(new Double(0)-amount2);
|
|
|
+ vendap.setVa_leftamount(new Double(0)+amount1-amount2);
|
|
|
+ vendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(vendap);
|
|
|
+ }else{
|
|
|
+ Double vapreamount = vendap.getVa_preamount()==null?new Double(0):vendap.getVa_preamount();
|
|
|
+ Double vapayamount = vendap.getVa_payamount()==null?new Double(0):vendap.getVa_payamount();
|
|
|
+ Double valeftamount = vendap.getVa_leftamount()==null?new Double(0):vendap.getVa_leftamount();
|
|
|
+ vendap.setVa_preamount(vapreamount-amount1);
|
|
|
+ vendap.setVa_payamount(vapayamount -amount2);
|
|
|
+ vendap.setVa_leftamount(valeftamount+amount1-amount2);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(vendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+ }else if(kind.equals("receivable_offset_payable")){//应收冲应付
|
|
|
+ String con="va_vendid="+verificationDTO.getVc_vendid()+" and va_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ VendApamount vendap=paybalanceMapper.selectVendApByCondition(con,companyId);
|
|
|
+ if(vendap == null){
|
|
|
+ vendap=new VendApamount();
|
|
|
+ vendap.setVa_vendid(verificationDTO.getVc_vendid());
|
|
|
+ vendap.setVa_vendcode(verificationDTO.getVc_vendcode());
|
|
|
+ vendap.setVa_vendname(verificationDTO.getVc_vendname());
|
|
|
+ vendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ vendap.setVa_begindate(null);
|
|
|
+ vendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ vendap.setVa_beginapamount(new Double(0));
|
|
|
+ vendap.setVa_preamount(new Double(0));
|
|
|
+ vendap.setVa_payamount(new Double(0)-amount2);
|
|
|
+ vendap.setVa_leftamount(new Double(0)-amount2);
|
|
|
+ vendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(vendap);
|
|
|
+ }else{
|
|
|
+ Double vapreamount = vendap.getVa_preamount()==null?new Double(0):vendap.getVa_preamount();
|
|
|
+ Double vapayamount = vendap.getVa_payamount()==null?new Double(0):vendap.getVa_payamount();
|
|
|
+ Double valeftamount = vendap.getVa_leftamount()==null?new Double(0):vendap.getVa_leftamount();
|
|
|
+ vendap.setVa_preamount(vapreamount);
|
|
|
+ vendap.setVa_payamount(vapayamount -amount2);
|
|
|
+ vendap.setVa_leftamount(valeftamount-amount2);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(vendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+ }else if(kind.equals("payable_to_payable")){//应付转应付
|
|
|
//转入供应商
|
|
|
- Vendor vendorIn = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_turnvendid());
|
|
|
+ String inCon="va_vendid="+verificationDTO.getVc_turnvendid()+" and va_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ VendApamount inVendap=paybalanceMapper.selectVendApByCondition(inCon,companyId);
|
|
|
+ if(inVendap == null){
|
|
|
+ inVendap=new VendApamount();
|
|
|
+ inVendap.setVa_vendid(verificationDTO.getVc_turnvendid());
|
|
|
+ inVendap.setVa_vendcode(verificationDTO.getVc_turnvendcode());
|
|
|
+ inVendap.setVa_vendname(verificationDTO.getVc_turnvendname());
|
|
|
+ inVendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ inVendap.setVa_begindate(null);
|
|
|
+ inVendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ inVendap.setVa_beginapamount(new Double(0));
|
|
|
+ inVendap.setVa_preamount(new Double(0));
|
|
|
+ inVendap.setVa_payamount(new Double(0)+amount1);
|
|
|
+ inVendap.setVa_leftamount(new Double(0)+amount1);
|
|
|
+ inVendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(inVendap);
|
|
|
+ }else{
|
|
|
+ Double vapreamount = inVendap.getVa_preamount()==null?new Double(0):inVendap.getVa_preamount();
|
|
|
+ Double vapayamount = inVendap.getVa_payamount()==null?new Double(0):inVendap.getVa_payamount();
|
|
|
+ Double valeftamount = inVendap.getVa_leftamount()==null?new Double(0):inVendap.getVa_leftamount();
|
|
|
+ inVendap.setVa_preamount(vapreamount);
|
|
|
+ inVendap.setVa_payamount(vapayamount +amount1);
|
|
|
+ inVendap.setVa_leftamount(valeftamount+amount1);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(inVendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_turnvendid());
|
|
|
//转出供应商
|
|
|
- Vendor vendorOut = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
-
|
|
|
- Double preamountIn = vendorIn.getVe_preamount()==null?new Double(0):vendorIn.getVe_preamount();
|
|
|
- Double beginapamountIn = vendorIn.getVe_beginapamount()==null?new Double(0):vendorIn.getVe_beginapamount();
|
|
|
- Double beginprepayamountIn = vendorIn.getVe_beginprepayamount()==null?new Double(0):vendorIn.getVe_beginprepayamount();
|
|
|
- Double payamountIn = vendorIn.getVe_payamount()==null?new Double(0):vendorIn.getVe_payamount();
|
|
|
-
|
|
|
- Double preamountOut = vendorOut.getVe_preamount()==null?new Double(0):vendorOut.getVe_preamount();
|
|
|
- Double beginapamountOut = vendorOut.getVe_beginapamount()==null?new Double(0):vendorOut.getVe_beginapamount();
|
|
|
- Double beginprepayamountOut = vendorOut.getVe_beginprepayamount()==null?new Double(0):vendorOut.getVe_beginprepayamount();
|
|
|
- Double payamountOut = vendorOut.getVe_payamount()==null?new Double(0):vendorOut.getVe_payamount();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- Vendor newVendorIn = new Vendor();
|
|
|
- newVendorIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turnvendid())));
|
|
|
- newVendorIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newVendorIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newVendorIn.setUpdateTime(new Date());
|
|
|
- newVendorIn.setVe_payamount(payamountIn+amount1);
|
|
|
- newVendorIn.setVe_leftamount(beginapamountIn-beginprepayamountIn+payamountIn+amount1-preamountIn);
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorIn);
|
|
|
-
|
|
|
- Vendor newVendorOut = new Vendor();
|
|
|
- newVendorOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
- newVendorOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newVendorOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newVendorOut.setUpdateTime(new Date());
|
|
|
- newVendorOut.setVe_payamount(payamountOut-amount1);
|
|
|
- newVendorOut.setVe_leftamount(beginapamountOut-beginprepayamountOut+payamountOut-amount1-preamountOut);
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorOut);
|
|
|
-
|
|
|
+ String outCon="va_vendid="+verificationDTO.getVc_vendid()+" and va_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ VendApamount outVendap=paybalanceMapper.selectVendApByCondition(outCon,companyId);
|
|
|
+ if(outVendap == null){
|
|
|
+ outVendap=new VendApamount();
|
|
|
+ outVendap.setVa_vendid(verificationDTO.getVc_vendid());
|
|
|
+ outVendap.setVa_vendcode(verificationDTO.getVc_vendcode());
|
|
|
+ outVendap.setVa_vendname(verificationDTO.getVc_vendname());
|
|
|
+ outVendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ outVendap.setVa_begindate(null);
|
|
|
+ outVendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ outVendap.setVa_beginapamount(new Double(0));
|
|
|
+ outVendap.setVa_preamount(new Double(0));
|
|
|
+ outVendap.setVa_payamount(new Double(0)-amount1);
|
|
|
+ outVendap.setVa_leftamount(new Double(0)-amount1);
|
|
|
+ outVendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(outVendap);
|
|
|
+ }else{
|
|
|
+ Double vapreamount = outVendap.getVa_preamount()==null?new Double(0):outVendap.getVa_preamount();
|
|
|
+ Double vapayamount = outVendap.getVa_payamount()==null?new Double(0):outVendap.getVa_payamount();
|
|
|
+ Double valeftamount = outVendap.getVa_leftamount()==null?new Double(0):outVendap.getVa_leftamount();
|
|
|
+ outVendap.setVa_preamount(vapreamount);
|
|
|
+ outVendap.setVa_payamount(vapayamount -amount1);
|
|
|
+ outVendap.setVa_leftamount(valeftamount-amount1);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(outVendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
@@ -844,83 +917,120 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
* @return
|
|
|
*/
|
|
|
private void updateResAuditCustomer(VerificationDTO verificationDTO){
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
String kind = verificationDTO.getVc_kind();
|
|
|
kind = transferKind(kind);
|
|
|
- if(kind.equals("receipts_offset_receivable")){
|
|
|
- Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
- Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
- Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
- Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
- Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
-
|
|
|
- Customer customer = new Customer();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
- customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- customer.setUpdateTime(new Date());
|
|
|
- customer.setCu_preamount(preamount+amount1);
|
|
|
- customer.setCu_recamount(recamount+amount2);
|
|
|
- customer.setCu_leftamount(beginapamount-beginprepayamount+recamount+amount2-preamount-amount1);
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ if(kind.equals("receipts_offset_receivable")){//预收冲应收
|
|
|
+ String con="ca_custid="+verificationDTO.getVc_custid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount custar=recbalanceMapper.selectCustArByCondition(con,companyId);
|
|
|
+ if (custar == null){
|
|
|
+ custar=new CustAramount();
|
|
|
+ custar.setCa_custid(verificationDTO.getVc_custid());
|
|
|
+ custar.setCa_custcode(verificationDTO.getVc_custcode());
|
|
|
+ custar.setCa_custname(verificationDTO.getVc_custname());
|
|
|
+ custar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ custar.setCa_begindate(null);
|
|
|
+ custar.setCa_beginprerecamount(new Double(0));
|
|
|
+ custar.setCa_beginaramount(new Double(0));
|
|
|
+ custar.setCa_preamount(new Double(0)+amount1);
|
|
|
+ custar.setCa_recamount(new Double(0)+amount2);
|
|
|
+ custar.setCa_leftamount(new Double(0)+amount2-amount1);
|
|
|
+ custar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(custar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = custar.getCa_preamount()==null?new Double(0):custar.getCa_preamount();
|
|
|
+ Double carecamount = custar.getCa_recamount()==null?new Double(0):custar.getCa_recamount();
|
|
|
+ Double caleftamount = custar.getCa_leftamount()==null?new Double(0):custar.getCa_leftamount();
|
|
|
+ custar.setCa_preamount(capreamount+amount1);
|
|
|
+ custar.setCa_recamount(carecamount+amount2);
|
|
|
+ custar.setCa_leftamount(caleftamount-amount1+amount2);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(custar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
}else if(kind.equals("receivable_offset_payable")){
|
|
|
- Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
- Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
|
|
|
- Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
|
|
|
- Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
|
|
|
- Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
|
|
|
-
|
|
|
- Customer customer = new Customer();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- customer.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
- customer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- customer.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- customer.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- customer.setUpdateTime(new Date());
|
|
|
- customer.setCu_recamount(recamount+amount1);
|
|
|
- customer.setCu_leftamount(beginapamount-beginprepayamount+recamount+amount1-preamount);
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
|
|
|
+ String con="ca_custid="+verificationDTO.getVc_custid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount custar=recbalanceMapper.selectCustArByCondition(con,companyId);
|
|
|
+ if (custar == null){
|
|
|
+ custar=new CustAramount();
|
|
|
+ custar.setCa_custid(verificationDTO.getVc_custid());
|
|
|
+ custar.setCa_custcode(verificationDTO.getVc_custcode());
|
|
|
+ custar.setCa_custname(verificationDTO.getVc_custname());
|
|
|
+ custar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ custar.setCa_begindate(null);
|
|
|
+ custar.setCa_beginprerecamount(new Double(0));
|
|
|
+ custar.setCa_beginaramount(new Double(0));
|
|
|
+ custar.setCa_preamount(new Double(0));
|
|
|
+ custar.setCa_recamount(new Double(0)+amount1);
|
|
|
+ custar.setCa_leftamount(new Double(0)+amount1);
|
|
|
+ custar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(custar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = custar.getCa_preamount()==null?new Double(0):custar.getCa_preamount();
|
|
|
+ Double carecamount = custar.getCa_recamount()==null?new Double(0):custar.getCa_recamount();
|
|
|
+ Double caleftamount = custar.getCa_leftamount()==null?new Double(0):custar.getCa_leftamount();
|
|
|
+ custar.setCa_preamount(capreamount);
|
|
|
+ custar.setCa_recamount(carecamount+amount1);
|
|
|
+ custar.setCa_leftamount(caleftamount+amount1);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(custar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
}else if(kind.equals("receivable_to_receivable")){
|
|
|
//转入客户
|
|
|
- Customer customerIn = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_turncustid());
|
|
|
+ String inCon="ca_custid="+verificationDTO.getVc_turncustid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount inCustar=recbalanceMapper.selectCustArByCondition(inCon,companyId);
|
|
|
+ if (inCustar == null){
|
|
|
+ inCustar=new CustAramount();
|
|
|
+ inCustar.setCa_custid(verificationDTO.getVc_turncustid());
|
|
|
+ inCustar.setCa_custcode(verificationDTO.getVc_turncustcode());
|
|
|
+ inCustar.setCa_custname(verificationDTO.getVc_turncustname());
|
|
|
+ inCustar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ inCustar.setCa_begindate(null);
|
|
|
+ inCustar.setCa_beginprerecamount(new Double(0));
|
|
|
+ inCustar.setCa_beginaramount(new Double(0));
|
|
|
+ inCustar.setCa_preamount(new Double(0));
|
|
|
+ inCustar.setCa_recamount(new Double(0)-amount1);
|
|
|
+ inCustar.setCa_leftamount(new Double(0)-amount1);
|
|
|
+ inCustar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(inCustar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = inCustar.getCa_preamount()==null?new Double(0):inCustar.getCa_preamount();
|
|
|
+ Double carecamount = inCustar.getCa_recamount()==null?new Double(0):inCustar.getCa_recamount();
|
|
|
+ Double caleftamount = inCustar.getCa_leftamount()==null?new Double(0):inCustar.getCa_leftamount();
|
|
|
+ inCustar.setCa_preamount(capreamount);
|
|
|
+ inCustar.setCa_recamount(carecamount-amount1);
|
|
|
+ inCustar.setCa_leftamount(caleftamount-amount1);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(inCustar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_turncustid());
|
|
|
//转出客户
|
|
|
- Customer customerOut = recbalanceMapper.selectCustomerByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
-
|
|
|
- Double preamountIn = customerIn.getCu_preamount()==null?new Double(0):customerIn.getCu_preamount();
|
|
|
- Double beginapamountIn = customerIn.getCu_beginaramount()==null?new Double(0):customerIn.getCu_beginaramount();
|
|
|
- Double beginprepayamountIn = customerIn.getCu_beginprerecamount()==null?new Double(0):customerIn.getCu_beginprerecamount();
|
|
|
- Double recamountIn = customerIn.getCu_recamount()==null?new Double(0):customerIn.getCu_recamount();
|
|
|
-
|
|
|
- Double preamountOut = customerOut.getCu_preamount()==null?new Double(0):customerOut.getCu_preamount();
|
|
|
- Double beginapamountOut = customerOut.getCu_beginaramount()==null?new Double(0):customerOut.getCu_beginaramount();
|
|
|
- Double beginprepayamountOut = customerOut.getCu_beginprerecamount()==null?new Double(0):customerOut.getCu_beginprerecamount();
|
|
|
- Double recamountOut = customerOut.getCu_recamount()==null?new Double(0):customerOut.getCu_recamount();
|
|
|
-
|
|
|
-
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- Customer newCustomerIn = new Customer();
|
|
|
- newCustomerIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turncustid())));
|
|
|
- newCustomerIn.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- newCustomerIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newCustomerIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newCustomerIn.setUpdateTime(new Date());
|
|
|
- newCustomerIn.setCu_recamount(recamountIn-amount1);
|
|
|
- newCustomerIn.setCu_leftamount(beginapamountIn-beginprepayamountIn+recamountIn+amount1-preamountIn);
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerIn);
|
|
|
-
|
|
|
- Customer newCustomerOut = new Customer();
|
|
|
- newCustomerOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_custid())));
|
|
|
- newCustomerOut.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- newCustomerOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newCustomerOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newCustomerOut.setUpdateTime(new Date());
|
|
|
- newCustomerOut.setCu_recamount(recamountOut+amount1);
|
|
|
- newCustomerOut.setCu_leftamount(beginapamountOut-beginprepayamountOut+recamountOut+amount1-preamountOut);
|
|
|
- recbalanceMapper.updateCustomerByPrimaryKeySelective(newCustomerOut);
|
|
|
+ String outCon="ca_custid="+verificationDTO.getVc_custid()+" and ca_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ CustAramount outCustar=recbalanceMapper.selectCustArByCondition(outCon,companyId);
|
|
|
+ if (outCustar == null){
|
|
|
+ outCustar=new CustAramount();
|
|
|
+ outCustar.setCa_custid(verificationDTO.getVc_custid());
|
|
|
+ outCustar.setCa_custcode(verificationDTO.getVc_custcode());
|
|
|
+ outCustar.setCa_custname(verificationDTO.getVc_custname());
|
|
|
+ outCustar.setCa_currency(verificationDTO.getVc_currency());
|
|
|
+ outCustar.setCa_begindate(null);
|
|
|
+ outCustar.setCa_beginprerecamount(new Double(0));
|
|
|
+ outCustar.setCa_beginaramount(new Double(0));
|
|
|
+ outCustar.setCa_preamount(new Double(0));
|
|
|
+ outCustar.setCa_recamount(new Double(0)+amount1);
|
|
|
+ outCustar.setCa_leftamount(new Double(0)+amount1);
|
|
|
+ outCustar.setCompanyId(companyId);
|
|
|
+ recbalanceMapper.insertCustAramount(outCustar);
|
|
|
+ }else {
|
|
|
+ Double capreamount = outCustar.getCa_preamount()==null?new Double(0):outCustar.getCa_preamount();
|
|
|
+ Double carecamount = outCustar.getCa_recamount()==null?new Double(0):outCustar.getCa_recamount();
|
|
|
+ Double caleftamount = outCustar.getCa_leftamount()==null?new Double(0):outCustar.getCa_leftamount();
|
|
|
+ outCustar.setCa_preamount(capreamount);
|
|
|
+ outCustar.setCa_recamount(carecamount+amount1);
|
|
|
+ outCustar.setCa_leftamount(caleftamount+amount1);
|
|
|
+ recbalanceMapper.updateCustAramountByPrimaryKeySelective(outCustar);
|
|
|
+ }
|
|
|
+ recbalanceMapper.updateCustleftamountByPrimaryKey(verificationDTO.getVc_custid());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -930,82 +1040,120 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
* @return
|
|
|
*/
|
|
|
private void updateResAuditVendor(VerificationDTO verificationDTO){
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
String kind = verificationDTO.getVc_kind();
|
|
|
kind = transferKind(kind);
|
|
|
- if(kind.equals("prepaid_offset_payable")){
|
|
|
- Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
- Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
- Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
- Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
- Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
-
|
|
|
- Vendor vendor = new Vendor();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
- vendor.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- vendor.setUpdateTime(new Date());
|
|
|
- vendor.setVe_preamount(preamount+amount1);
|
|
|
- vendor.setVe_payamount(payamount+amount2);
|
|
|
- vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount+amount2-preamount-amount1);
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
+ Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
+ Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
+ if(kind.equals("prepaid_offset_payable")) {
|
|
|
+ String con = "va_vendid=" + verificationDTO.getVc_vendid() + " and va_currency='" + verificationDTO.getVc_currency() + "'";
|
|
|
+ VendApamount vendap = paybalanceMapper.selectVendApByCondition(con, companyId);
|
|
|
+ if (vendap == null) {
|
|
|
+ vendap = new VendApamount();
|
|
|
+ vendap.setVa_vendid(verificationDTO.getVc_vendid());
|
|
|
+ vendap.setVa_vendcode(verificationDTO.getVc_vendcode());
|
|
|
+ vendap.setVa_vendname(verificationDTO.getVc_vendname());
|
|
|
+ vendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ vendap.setVa_begindate(null);
|
|
|
+ vendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ vendap.setVa_beginapamount(new Double(0));
|
|
|
+ vendap.setVa_preamount(new Double(0) + amount1);
|
|
|
+ vendap.setVa_payamount(new Double(0) + amount2);
|
|
|
+ vendap.setVa_leftamount(new Double(0) - amount1 + amount2);
|
|
|
+ vendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(vendap);
|
|
|
+ } else {
|
|
|
+ Double vapreamount = vendap.getVa_preamount() == null ? new Double(0) : vendap.getVa_preamount();
|
|
|
+ Double vapayamount = vendap.getVa_payamount() == null ? new Double(0) : vendap.getVa_payamount();
|
|
|
+ Double valeftamount = vendap.getVa_leftamount() == null ? new Double(0) : vendap.getVa_leftamount();
|
|
|
+ vendap.setVa_preamount(vapreamount + amount1);
|
|
|
+ vendap.setVa_payamount(vapayamount + amount2);
|
|
|
+ vendap.setVa_leftamount(valeftamount - amount1 + amount2);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(vendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
}else if(kind.equals("receivable_offset_payable")){
|
|
|
- Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
- Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
- Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
- Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
- Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
-
|
|
|
- Vendor vendor = new Vendor();
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- vendor.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
- vendor.setVe_payamount(payamount+amount2);
|
|
|
- vendor.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- vendor.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- vendor.setUpdateTime(new Date());
|
|
|
- vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount+amount2-preamount);
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
- }else if(kind.equals("payable_to_payable")){
|
|
|
+ String con="va_vendid="+verificationDTO.getVc_vendid()+" and va_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ VendApamount vendap=paybalanceMapper.selectVendApByCondition(con,companyId);
|
|
|
+ if(vendap == null){
|
|
|
+ vendap=new VendApamount();
|
|
|
+ vendap.setVa_vendid(verificationDTO.getVc_vendid());
|
|
|
+ vendap.setVa_vendcode(verificationDTO.getVc_vendcode());
|
|
|
+ vendap.setVa_vendname(verificationDTO.getVc_vendname());
|
|
|
+ vendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ vendap.setVa_begindate(null);
|
|
|
+ vendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ vendap.setVa_beginapamount(new Double(0));
|
|
|
+ vendap.setVa_preamount(new Double(0));
|
|
|
+ vendap.setVa_payamount(new Double(0)+amount2);
|
|
|
+ vendap.setVa_leftamount(new Double(0)+amount2);
|
|
|
+ vendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(vendap);
|
|
|
+ }else{
|
|
|
+ Double vapreamount = vendap.getVa_preamount()==null?new Double(0):vendap.getVa_preamount();
|
|
|
+ Double vapayamount = vendap.getVa_payamount()==null?new Double(0):vendap.getVa_payamount();
|
|
|
+ Double valeftamount = vendap.getVa_leftamount()==null?new Double(0):vendap.getVa_leftamount();
|
|
|
+ vendap.setVa_preamount(vapreamount);
|
|
|
+ vendap.setVa_payamount(vapayamount +amount2);
|
|
|
+ vendap.setVa_leftamount(valeftamount+amount2);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(vendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
+ }else if(kind.equals("payable_to_payable")){//应付转应付
|
|
|
//转入供应商
|
|
|
- Vendor vendorIn = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_turnvendid());
|
|
|
+ String inCon="va_vendid="+verificationDTO.getVc_turnvendid()+" and va_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ VendApamount inVendap=paybalanceMapper.selectVendApByCondition(inCon,companyId);
|
|
|
+ if(inVendap == null){
|
|
|
+ inVendap=new VendApamount();
|
|
|
+ inVendap.setVa_vendid(verificationDTO.getVc_turnvendid());
|
|
|
+ inVendap.setVa_vendcode(verificationDTO.getVc_turnvendcode());
|
|
|
+ inVendap.setVa_vendname(verificationDTO.getVc_turnvendname());
|
|
|
+ inVendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ inVendap.setVa_begindate(null);
|
|
|
+ inVendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ inVendap.setVa_beginapamount(new Double(0));
|
|
|
+ inVendap.setVa_preamount(new Double(0));
|
|
|
+ inVendap.setVa_payamount(new Double(0)-amount1);
|
|
|
+ inVendap.setVa_leftamount(new Double(0)-amount1);
|
|
|
+ inVendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(inVendap);
|
|
|
+ }else{
|
|
|
+ Double vapreamount = inVendap.getVa_preamount()==null?new Double(0):inVendap.getVa_preamount();
|
|
|
+ Double vapayamount = inVendap.getVa_payamount()==null?new Double(0):inVendap.getVa_payamount();
|
|
|
+ Double valeftamount = inVendap.getVa_leftamount()==null?new Double(0):inVendap.getVa_leftamount();
|
|
|
+ inVendap.setVa_preamount(vapreamount);
|
|
|
+ inVendap.setVa_payamount(vapayamount -amount1);
|
|
|
+ inVendap.setVa_leftamount(valeftamount-amount1);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(inVendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_turnvendid());
|
|
|
//转出供应商
|
|
|
- Vendor vendorOut = paybalanceMapper.selectVendorByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
-
|
|
|
- Double preamountIn = vendorIn.getVe_preamount()==null?new Double(0):vendorIn.getVe_preamount();
|
|
|
- Double beginapamountIn = vendorIn.getVe_beginapamount()==null?new Double(0):vendorIn.getVe_beginapamount();
|
|
|
- Double beginprepayamountIn = vendorIn.getVe_beginprepayamount()==null?new Double(0):vendorIn.getVe_beginprepayamount();
|
|
|
- Double payamountIn = vendorIn.getVe_payamount()==null?new Double(0):vendorIn.getVe_payamount();
|
|
|
-
|
|
|
- Double preamountOut = vendorOut.getVe_preamount()==null?new Double(0):vendorOut.getVe_preamount();
|
|
|
- Double beginapamountOut = vendorOut.getVe_beginapamount()==null?new Double(0):vendorOut.getVe_beginapamount();
|
|
|
- Double beginprepayamountOut = vendorOut.getVe_beginprepayamount()==null?new Double(0):vendorOut.getVe_beginprepayamount();
|
|
|
- Double payamountOut = vendorOut.getVe_payamount()==null?new Double(0):vendorOut.getVe_payamount();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Double amount1 = verificationDTO.getVc_amount1()==null?new Double(0):verificationDTO.getVc_amount1();
|
|
|
- Double amount2 = verificationDTO.getVc_amount2()==null?new Double(0):verificationDTO.getVc_amount2();
|
|
|
- Vendor newVendorIn = new Vendor();
|
|
|
- newVendorIn.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_turnvendid())));
|
|
|
- newVendorIn.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newVendorIn.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newVendorIn.setUpdateTime(new Date());
|
|
|
- newVendorIn.setVe_payamount(payamountIn-amount1);
|
|
|
- newVendorIn.setVe_leftamount(beginapamountIn-beginprepayamountIn+payamountIn-amount1-preamountIn);
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorIn);
|
|
|
-
|
|
|
- Vendor newVendorOut = new Vendor();
|
|
|
- newVendorOut.setId(Long.valueOf(String.valueOf(verificationDTO.getVc_vendid())));
|
|
|
- newVendorOut.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
- newVendorOut.setUpdaterName(BaseContextHolder.getUserName());
|
|
|
- newVendorOut.setUpdateTime(new Date());
|
|
|
- newVendorOut.setVe_payamount(payamountOut+amount1);
|
|
|
- newVendorOut.setVe_leftamount(beginapamountOut-beginprepayamountOut+payamountOut+amount1-preamountOut);
|
|
|
- paybalanceMapper.updateVendorByPrimaryKeySelective(newVendorOut);
|
|
|
-
|
|
|
+ String outCon="va_vendid="+verificationDTO.getVc_vendid()+" and va_currency='"+verificationDTO.getVc_currency()+"'";
|
|
|
+ VendApamount outVendap=paybalanceMapper.selectVendApByCondition(outCon,companyId);
|
|
|
+ if(outVendap == null){
|
|
|
+ outVendap=new VendApamount();
|
|
|
+ outVendap.setVa_vendid(verificationDTO.getVc_vendid());
|
|
|
+ outVendap.setVa_vendcode(verificationDTO.getVc_vendcode());
|
|
|
+ outVendap.setVa_vendname(verificationDTO.getVc_vendname());
|
|
|
+ outVendap.setVa_currency(verificationDTO.getVc_currency());
|
|
|
+ outVendap.setVa_begindate(null);
|
|
|
+ outVendap.setVa_beginprepayamount(new Double(0));
|
|
|
+ outVendap.setVa_beginapamount(new Double(0));
|
|
|
+ outVendap.setVa_preamount(new Double(0));
|
|
|
+ outVendap.setVa_payamount(new Double(0)+amount1);
|
|
|
+ outVendap.setVa_leftamount(new Double(0)+amount1);
|
|
|
+ outVendap.setCompanyId(companyId);
|
|
|
+ paybalanceMapper.insertVendApamount(outVendap);
|
|
|
+ }else{
|
|
|
+ Double vapreamount = outVendap.getVa_preamount()==null?new Double(0):outVendap.getVa_preamount();
|
|
|
+ Double vapayamount = outVendap.getVa_payamount()==null?new Double(0):outVendap.getVa_payamount();
|
|
|
+ Double valeftamount = outVendap.getVa_leftamount()==null?new Double(0):outVendap.getVa_leftamount();
|
|
|
+ outVendap.setVa_preamount(vapreamount);
|
|
|
+ outVendap.setVa_payamount(vapayamount +amount1);
|
|
|
+ outVendap.setVa_leftamount(valeftamount+amount1);
|
|
|
+ paybalanceMapper.updateVendApamountByPrimaryKeySelective(outVendap);
|
|
|
+ }
|
|
|
+ paybalanceMapper.updateVendleftamountByPrimaryKey(verificationDTO.getVc_vendid());
|
|
|
}
|
|
|
}
|
|
|
@Override
|