Browse Source

资金模块-解决核销单问题

huangx 7 years ago
parent
commit
29f1497f03

+ 1 - 3
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java

@@ -510,13 +510,11 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
     //插入中间表
     public Subledger changSubledgerUntil(Paybalance paybalance){
         Subledger subledger = new Subledger();
-//        BeanUtils.copyProperties(subledger, paybalance);
         subledger.setCompanyId(BaseContextHolder.getCompanyId());
         subledger.setSl_code(paybalance.getPb_code());
         subledger.setSl_kind(paybalance.getPb_kind());
         subledger.setSl_custid(0);
-//        subledger.setSl_vendid(paybalance.getPb_vendid());
-        subledger.setSl_vendid(1);
+        subledger.setSl_vendid(paybalance.getPb_vendid());
         subledger.setSl_date(paybalance.getPb_date());
         subledger.setSl_ym(DateUtils.getYm(paybalance.getPb_date()));
         if (paybalance.getPb_pdamount() == null){

+ 21 - 15
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/VerificationServiceImpl.java

@@ -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());

+ 13 - 7
frontend/saas-web/app/view/money/verification/FormPanel.js

@@ -327,6 +327,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '客户名称',
                 xtype: 'customerDbfindTrigger',
                 name: 'vc_custname',
+                allowBlank : false
             }, {
                 fieldLabel: '日期',
                 xtype: 'datefield',
@@ -400,7 +401,8 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '客户名称',
                 xtype: 'customerDbfindTrigger',
-                name: 'vc_custname'
+                name: 'vc_custname',
+                allowBlank : false,
             }, {
                 xtype: 'hidden',
                 name: 'vc_vendid',
@@ -440,7 +442,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
             main: [{
                 fieldLabel: '转出客户',
                 xtype: 'textfield',
-                name: 'vc_outcustid',
+                name: 'vc_custid',
                 hidden: true,
                 listeners: {
                     change: 'clearDetail0'
@@ -448,12 +450,13 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '转出客户编号',
                 xtype: 'textfield',
-                name: 'vc_outcustcode',
+                name: 'vc_custcode',
                 hidden: true
             }, {
                 fieldLabel: '转出客户',
                 xtype: 'customerDbfindTrigger',
-                name: 'vc_outcustname'
+                name: 'vc_custname',
+                allowBlank : false,
             }, {
                 fieldLabel: '转入客户id',
                 xtype: 'textfield',
@@ -468,6 +471,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '转入客户',
                 xtype: 'customerDbfindTrigger',
                 name: 'vc_turncustname',
+                allowBlank : false,
             }, {
                 fieldLabel: '日期',
                 xtype: 'datefield',
@@ -491,7 +495,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
             main: [{
                 fieldLabel: '转出供应商',
                 xtype: 'textfield',
-                name: 'vc_outvendid',
+                name: 'vc_vendid',
                 hidden: true,
                 listeners: {
                     change: 'clearDetail0'
@@ -499,12 +503,13 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '转出供应商编号',
                 xtype: 'textfield',
-                name: 'vc_outvendcode',
+                name: 'vc_vendcode',
                 hidden: true
             }, {
                 fieldLabel: '转出供应商',
                 xtype: 'vendorDbfindTrigger',
-                name: 'vc_outvendname'
+                name: 'vc_vendname',
+                allowBlank : false,
             }, {
                 fieldLabel: '转入供应商id',
                 xtype: 'textfield',
@@ -519,6 +524,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '转入供应商',
                 xtype: 'vendorDbfindTrigger',
                 name: 'vc_turnvendname',
+                allowBlank : false,
             }, {
                 fieldLabel: '日期',
                 xtype: 'datefield',