Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.34 KB | None | 0 0
  1. /******************************************************************************
  2.  * Product: Adempiere ERP & CRM Smart Business Solution                       *
  3.  * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.                *
  4.  * This program is free software; you can redistribute it and/or modify it    *
  5.  * under the terms version 2 of the GNU General Public License as published   *
  6.  * by the Free Software Foundation. This program is distributed in the hope   *
  7.  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
  8.  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
  9.  * See the GNU General Public License for more details.                       *
  10.  * You should have received a copy of the GNU General Public License along    *
  11.  * with this program; if not, write to the Free Software Foundation, Inc.,    *
  12.  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
  13.  * For the text or an alternative of this public license, you may reach us    *
  14.  * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
  15.  * or via info@compiere.org or http://www.compiere.org/license.html           *
  16.  *****************************************************************************/
  17. package org.adempiere.webui.apps.form;
  18.  
  19. import static org.compiere.model.SystemIDs.COLUMN_C_PAYSELECTIONCHECK_C_PAYSELECTION_ID;
  20.  
  21. import java.io.File;
  22. import java.io.FileInputStream;
  23. import java.util.ArrayList;
  24. import java.util.List;
  25. import java.util.logging.Level;
  26.  
  27. import org.adempiere.base.Core;
  28. import org.adempiere.util.Callback;
  29. import org.adempiere.webui.apps.AEnv;
  30. import org.adempiere.webui.component.Button;
  31. import org.adempiere.webui.component.ConfirmPanel;
  32. import org.adempiere.webui.component.Grid;
  33. import org.adempiere.webui.component.GridFactory;
  34. import org.adempiere.webui.component.Label;
  35. import org.adempiere.webui.component.Listbox;
  36. import org.adempiere.webui.component.ListboxFactory;
  37. import org.adempiere.webui.component.Panel;
  38. import org.adempiere.webui.component.Row;
  39. import org.adempiere.webui.component.Rows;
  40. import org.adempiere.webui.component.Window;
  41. import org.adempiere.webui.editor.WNumberEditor;
  42. import org.adempiere.webui.editor.WSearchEditor;
  43. import org.adempiere.webui.event.ValueChangeEvent;
  44. import org.adempiere.webui.event.ValueChangeListener;
  45. import org.adempiere.webui.panel.ADForm;
  46. import org.adempiere.webui.panel.CustomForm;
  47. import org.adempiere.webui.panel.IFormController;
  48. import org.adempiere.webui.session.SessionManager;
  49. import org.adempiere.webui.window.FDialog;
  50. import org.adempiere.webui.window.SimplePDFViewer;
  51. import org.compiere.apps.form.PayPrint;
  52. import org.compiere.model.MLookup;
  53. import org.compiere.model.MLookupFactory;
  54. import org.compiere.model.MPaySelectionCheck;
  55. import org.compiere.model.MPaymentBatch;
  56. import org.compiere.print.MPrintFormat;
  57. import org.compiere.print.ReportEngine;
  58. import org.compiere.process.ProcessInfo;
  59. import org.compiere.process.ServerProcessCtl;
  60. import org.compiere.util.DB;
  61. import org.compiere.util.DisplayType;
  62. import org.compiere.util.Env;
  63. import org.compiere.util.Msg;
  64. import org.compiere.util.PaymentExport;
  65. import org.compiere.util.ValueNamePair;
  66. import org.zkoss.zk.ui.event.Event;
  67. import org.zkoss.zk.ui.event.EventListener;
  68. import org.zkoss.zul.Borderlayout;
  69. import org.zkoss.zul.Center;
  70. import org.zkoss.zul.Filedownload;
  71. import org.zkoss.zul.South;
  72.  
  73. import com.lowagie.text.pdf.PdfReader;
  74.  
  75. /**
  76.  *  Payment Print & Export
  77.  *
  78.  *  @author     Jorg Janke
  79.  *  @version    $Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
  80.  *
  81.  *  Contributors:
  82.  *    Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank
  83. */
  84. public class WPayPrint extends PayPrint implements IFormController, EventListener<Event>, ValueChangeListener
  85. {
  86.     private CustomForm form = new CustomForm();
  87.  
  88.     /**
  89.      *  Initialize Panel
  90.      */
  91.     public WPayPrint()
  92.     {
  93.         try
  94.         {
  95.             m_WindowNo = form.getWindowNo();
  96.            
  97.             dynInit();
  98.             zkInit();
  99.             Borderlayout contentLayout = new Borderlayout();
  100.             contentLayout.setWidth("100%");
  101.             contentLayout.setHeight("100%");
  102.             form.appendChild(contentLayout);
  103.             Center center = new Center();
  104.             contentLayout.appendChild(center);
  105.             center.appendChild(centerPanel);
  106.             South south = new South();
  107.             south.setStyle("border: none");
  108.             contentLayout.appendChild(south);
  109.             south.appendChild(southPanel);
  110.         }
  111.         catch(Exception e)
  112.         {
  113.             log.log(Level.SEVERE, "", e);
  114.         }
  115.     }   //  init
  116.  
  117.     //  Static Variables
  118.     protected Panel centerPanel = new Panel();
  119.     protected ConfirmPanel southPanel = new ConfirmPanel(true, false, false, false, false, false, false);
  120.     protected Grid centerLayout = GridFactory.newGridLayout();
  121.     protected Button bPrint = southPanel.createButton(ConfirmPanel.A_PRINT);
  122.     protected Button bExport = southPanel.createButton(ConfirmPanel.A_EXPORT);
  123.     protected Button bCancel = southPanel.getButton(ConfirmPanel.A_CANCEL);
  124.     protected Button bProcess = southPanel.createButton(ConfirmPanel.A_PROCESS);
  125.     protected Label lPaySelect = new Label();
  126.     protected WSearchEditor paySelectSearch = null;
  127.     protected Label lBank = new Label();
  128.     protected Label fBank = new Label();
  129.     protected Label lPaymentRule = new Label();
  130.     protected Listbox fPaymentRule = ListboxFactory.newDropdownListbox();
  131.     protected Label lDocumentNo = new Label();
  132.     protected WNumberEditor fDocumentNo = new WNumberEditor();
  133.     protected Label lNoPayments = new Label();
  134.     protected Label fNoPayments = new Label();
  135.     protected Label lBalance = new Label();
  136.     protected WNumberEditor fBalance = new WNumberEditor();
  137.     protected Label lCurrency = new Label();
  138.     protected Label fCurrency = new Label();
  139.  
  140.     /**
  141.      *  Static Init
  142.      *  @throws Exception
  143.      */
  144.     protected void zkInit() throws Exception
  145.     {
  146.         //
  147.         centerPanel.appendChild(centerLayout);
  148.         //
  149.         bPrint.addActionListener(this);
  150.         bExport.addActionListener(this);
  151.         bCancel.addActionListener(this);
  152.         //
  153.         bProcess.setEnabled(false);
  154.         bProcess.addActionListener(this);
  155.         //
  156.         lPaySelect.setText(Msg.translate(Env.getCtx(), "C_PaySelection_ID"));
  157.         //
  158.         lBank.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
  159.         //
  160.         lPaymentRule.setText(Msg.translate(Env.getCtx(), "PaymentRule"));
  161.         fPaymentRule.addActionListener(this);
  162.         //
  163.         lDocumentNo.setText(Msg.translate(Env.getCtx(), "DocumentNo"));
  164.         fDocumentNo.getComponent().setIntegral(true);
  165.         lNoPayments.setText(Msg.getMsg(Env.getCtx(), "NoOfPayments"));
  166.         fNoPayments.setText("0");
  167.         lBalance.setText(Msg.translate(Env.getCtx(), "CurrentBalance"));
  168.         fBalance.setReadWrite(false);
  169.         fBalance.getComponent().setIntegral(false);
  170.         lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
  171.         //
  172.         southPanel.addButton(bExport);
  173.         southPanel.addButton(bPrint);
  174.         southPanel.addButton(bProcess);
  175.         //
  176.         Rows rows = centerLayout.newRows();
  177.         Row row = rows.newRow();
  178.         row.appendChild(lPaySelect.rightAlign());
  179.         row.appendChild(paySelectSearch.getComponent());
  180.  
  181.         row = rows.newRow();
  182.         row.appendChild(lBank.rightAlign());
  183.         row.appendChild(fBank);
  184.         row.appendChild(lBalance.rightAlign());
  185.         row.appendChild(fBalance.getComponent());
  186.  
  187.         row = rows.newRow();
  188.         row.appendChild(lPaymentRule.rightAlign());
  189.         row.appendChild(fPaymentRule);
  190.         row.appendChild(lCurrency.rightAlign());
  191.         row.appendChild(fCurrency);
  192.  
  193.         row = rows.newRow();
  194.         row.appendChild(lDocumentNo.rightAlign());
  195.         row.appendChild(fDocumentNo.getComponent());
  196.         row.appendChild(lNoPayments.rightAlign());
  197.         row.appendChild(fNoPayments);
  198.  
  199.         southPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
  200.     }   //  VPayPrint
  201.  
  202.     /**
  203.      *  Dynamic Init
  204.      */
  205.     protected void dynInit()
  206.     {
  207.         //  C_PaySelection_ID
  208.         int AD_Column_ID = COLUMN_C_PAYSELECTIONCHECK_C_PAYSELECTION_ID;        //  C_PaySelectionCheck.C_PaySelection_ID
  209.         MLookup lookupPS = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
  210.         paySelectSearch = new WSearchEditor("C_PaySelection_ID", true, false, true, lookupPS);
  211.         paySelectSearch.addValueChangeListener(this);
  212.  
  213.     }   //  dynInit
  214.  
  215.     /**
  216.      *  Dispose
  217.      */
  218.     public void dispose()
  219.     {
  220.         SessionManager.getAppDesktop().closeActiveWindow();
  221.     }   //  dispose
  222.  
  223.     /**
  224.      *  Set Payment Selection
  225.      *  @param C_PaySelection_ID id
  226.      */
  227.     public void setPaySelection (int C_PaySelection_ID)
  228.     {
  229.         if (C_PaySelection_ID == 0)
  230.             return;
  231.         //
  232.         m_C_PaySelection_ID = C_PaySelection_ID;
  233.         paySelectSearch.setValue(new Integer(m_C_PaySelection_ID));
  234.         loadPaySelectInfo();
  235.     }   //  setsetPaySelection
  236.  
  237.  
  238.     /**************************************************************************
  239.      *  Action Listener
  240.      *  @param e event
  241.      */
  242.     public void onEvent(Event e)
  243.     {
  244.         //  log.config( "VPayPrint.actionPerformed" + e.toString());
  245.         if (e.getTarget() == bCancel)
  246.             dispose();
  247.         else if (m_C_PaySelection_ID <= 0)
  248.             return;
  249.         else if (e.getTarget() == fPaymentRule)
  250.             loadPaymentRuleInfo();
  251.         //
  252.         else if (e.getTarget() == bExport)
  253.             cmd_export();
  254.         else if (e.getTarget() == bProcess)
  255.             cmd_EFT();
  256.         else if (e.getTarget() == bPrint)
  257.             confirm_cmd_print();
  258.     }   //  actionPerformed
  259.  
  260.     /**
  261.      *  PaySelect changed - load Bank
  262.      */
  263.     protected void loadPaySelectInfo()
  264.     {
  265.         log.info( "VPayPrint.loadPaySelectInfo");
  266.         if (m_C_PaySelection_ID <= 0)
  267.             return;
  268.  
  269.         //  load Banks from PaySelectLine
  270.         loadPaySelectInfo(m_C_PaySelection_ID);
  271.  
  272.         fBank.setText(bank);
  273.         fCurrency.setText(currency);
  274.         fBalance.setValue(balance);
  275.  
  276.         loadPaymentRule();
  277.     }   //  loadPaySelectInfo
  278.  
  279.     /**
  280.      *  Bank changed - load PaymentRule
  281.      */
  282.     protected void loadPaymentRule()
  283.     {
  284.         log.info("");
  285.         if (m_C_BankAccount_ID == -1)
  286.             return;
  287.  
  288.         fPaymentRule.removeAllItems();
  289.  
  290.         // load PaymentRule for Bank
  291.         ArrayList<ValueNamePair> data = loadPaymentRule(m_C_PaySelection_ID);
  292.         for(ValueNamePair pp : data)
  293.             fPaymentRule.addItem(pp);
  294.  
  295.         if (fPaymentRule.getItemCount() > 0)
  296.             fPaymentRule.setSelectedIndex(0);
  297.  
  298.         loadPaymentRuleInfo();
  299.     }   //  loadPaymentRule
  300.  
  301.     /**
  302.      *  PaymentRule changed - load DocumentNo, NoPayments,
  303.      *  enable/disable EFT, Print
  304.      */
  305.     protected void loadPaymentRuleInfo()
  306.     {
  307.         if (fPaymentRule.getSelectedItem() == null)
  308.             return;
  309.         ValueNamePair pp = fPaymentRule.getSelectedItem().toValueNamePair();
  310.         if (pp == null)
  311.             return;
  312.         String PaymentRule = pp.getValue();
  313.  
  314.         log.info("PaymentRule=" + PaymentRule);
  315.         fNoPayments.setText(" ");
  316.  
  317.         String msg = loadPaymentRuleInfo(m_C_PaySelection_ID, PaymentRule);
  318.  
  319.         if(noPayments != null)
  320.             fNoPayments.setText(noPayments);
  321.  
  322.         bProcess.setEnabled(PaymentRule.equals("T"));
  323.  
  324.         if(documentNo != null)
  325.             fDocumentNo.setValue(documentNo);
  326.  
  327.         if(msg != null && msg.length() > 0)
  328.             FDialog.error(m_WindowNo, form, msg);
  329.     }   //  loadPaymentRuleInfo
  330.  
  331.  
  332.     /**************************************************************************
  333.      *  Export payments to file
  334.      */
  335.     protected void cmd_export()
  336.     {
  337.         String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
  338.         log.info(PaymentRule);
  339.         if (!getChecks(PaymentRule))
  340.             return;
  341.  
  342.         try
  343.         {
  344.             //  Get File Info
  345.             File tempFile = File.createTempFile("paymentExport", ".txt");
  346.  
  347.             //  Create File
  348.             int no = 0;
  349.             StringBuffer err = new StringBuffer("");
  350.             if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) {
  351.                 m_PaymentExportClass = "org.compiere.util.GenericPaymentExport";
  352.             }
  353.             //  Get Payment Export Class
  354.             PaymentExport custom = Core.getPaymentExport(m_PaymentExportClass);
  355.             try{
  356.                 if(custom != null){
  357.                     no = custom.exportToFile(m_checks, tempFile, err);
  358.                 }else{
  359.                     no = -1;
  360.                 }
  361.             }catch (Exception e)
  362.             {
  363.                 no = -1;
  364.                 err.append("Error in " + m_PaymentExportClass + " check log, " + e.toString());
  365.                 log.log(Level.SEVERE, err.toString(), e);
  366.             }
  367.  
  368.             if (no >= 0) {
  369.                 Filedownload.save(new FileInputStream(tempFile), "plain/text", "paymentExport.txt");
  370.                 FDialog.info(m_WindowNo, form, "Saved",
  371.                         Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
  372.  
  373.                 FDialog.ask(m_WindowNo, form, "VPayPrintSuccess?", new Callback<Boolean>() {
  374.                    
  375.                     @Override
  376.                     public void onCallback(Boolean result)
  377.                     {
  378.                         if (result)
  379.                         {
  380.                             MPaySelectionCheck.confirmPrint (m_checks, m_batch);
  381.                             //  document No not updated
  382.                         }
  383.                        
  384.                     }
  385.                 });
  386.             } else {
  387.                 FDialog.error(m_WindowNo, form, "Error", err.toString());
  388.             }
  389.             dispose();
  390.         }
  391.         catch (Exception e)
  392.         {
  393.             log.log(Level.SEVERE, e.getLocalizedMessage(), e);
  394.         }
  395.     }   //  cmd_export
  396.  
  397.     /**
  398.      *  Create EFT payment
  399.      */
  400.     protected void cmd_EFT()
  401.     {
  402.         String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
  403.         log.info(PaymentRule);
  404.         if (!getChecks(PaymentRule))
  405.             return;
  406.         dispose();
  407.     }   //  cmd_EFT
  408.  
  409.     /**
  410.      *  Confirm before printing
  411.      */
  412.     protected void confirm_cmd_print()
  413.     {
  414.         FDialog.ask(m_WindowNo, form, "CreatePayments?", new Callback<Boolean>() {
  415.  
  416.             @Override
  417.             public void onCallback(Boolean result)
  418.             {
  419.                 if (result)
  420.                 {
  421.                     cmd_print();
  422.                 }
  423.  
  424.             }
  425.         });
  426.     }
  427.  
  428.     /**
  429.      *  Print Checks and/or Remittance
  430.      */
  431.     protected void cmd_print()
  432.     {
  433.         String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
  434.         log.info(PaymentRule);
  435.         if (!getChecks(PaymentRule))
  436.             return;
  437.        
  438.         //  get document no
  439.         int startDocumentNo = ((Number)fDocumentNo.getValue()).intValue();
  440.         if (log.isLoggable(Level.CONFIG)) log.config("DocumentNo=" + startDocumentNo);
  441.  
  442.         //  for all checks
  443.         List<File> pdfList = new ArrayList<File>();
  444.         int lastDocumentNo = startDocumentNo;
  445.         for (int i = 0; i < m_checks.length; i++)
  446.         {
  447.             MPaySelectionCheck check = m_checks[i];
  448.            
  449.             //  Set new Check Document No
  450.             check.setDocumentNo(String.valueOf(lastDocumentNo));
  451.             check.saveEx();
  452.            
  453.             //  Update BankAccountDoc
  454.             MPaySelectionCheck.confirmPrint(m_checks[i], m_batch);
  455.  
  456.             //  ReportCtrl will check BankAccountDoc for PrintFormat
  457.             ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.CHECK, check.get_ID());
  458.             try
  459.             {
  460.                 MPrintFormat format = re.getPrintFormat();
  461.                 File pdfFile = null;
  462.                 if (format.getJasperProcess_ID() > 0)  
  463.                 {
  464.                     ProcessInfo pi = new ProcessInfo("", format.getJasperProcess_ID());
  465.                     pi.setRecord_ID(check.get_ID());
  466.                     pi.setIsBatch(true);
  467.                                        
  468.                     ServerProcessCtl.process(pi, null);
  469.                     pdfFile = pi.getPDFReport();
  470.                 }
  471.                 else
  472.                 {
  473.                     pdfFile = File.createTempFile("WPayPrint", null);
  474.                     re.getPDF(pdfFile);
  475.                 }
  476.                
  477.                 if (pdfFile != null)
  478.                 {
  479.                     // increase the check document no by the number of pages of the generated pdf file
  480.                     PdfReader document = new PdfReader(pdfFile.getAbsolutePath());
  481.                     lastDocumentNo += document.getNumberOfPages();
  482.                     pdfList.add(pdfFile);
  483.                 }
  484.             }
  485.             catch (Exception e)
  486.             {
  487.                 log.log(Level.SEVERE, e.getLocalizedMessage(), e);
  488.                 return;
  489.             }
  490.         }
  491.  
  492.         SimplePDFViewer chequeViewer = null;
  493.         try
  494.         {
  495.             File outFile = File.createTempFile("WPayPrint", null);
  496.             AEnv.mergePdf(pdfList, outFile);
  497.             chequeViewer = new SimplePDFViewer(form.getFormName(), new FileInputStream(outFile));
  498.             chequeViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
  499.             chequeViewer.setWidth("100%");
  500.         }
  501.         catch (Exception e)
  502.         {
  503.             log.log(Level.SEVERE, e.getLocalizedMessage(), e);
  504.             return;
  505.         }
  506.         final SimplePDFViewer chequeViewerRef = chequeViewer;
  507.  
  508.         //  Update Check Next Document No      
  509.         if (startDocumentNo != lastDocumentNo)
  510.         {
  511.             StringBuilder sb = new StringBuilder();
  512.             sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(lastDocumentNo)
  513.                 .append(" WHERE C_BankAccount_ID=").append(m_C_BankAccount_ID)
  514.                 .append(" AND PaymentRule='").append(PaymentRule).append("'");
  515.             DB.executeUpdate(sb.toString(), null);
  516.         }
  517.  
  518.         FDialog.ask(m_WindowNo, form, "VPayPrintPrintRemittance", new Callback<Boolean>() {
  519.  
  520.             @Override
  521.             public void onCallback(Boolean result)
  522.             {      
  523.                 SimplePDFViewer remitViewer = null;
  524.                 if (result)
  525.                 {
  526.                     List<File> pdfList = new ArrayList<File>();
  527.                     for (int i = 0; i < m_checks.length; i++)
  528.                     {
  529.                         MPaySelectionCheck check = m_checks[i];
  530.                         ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.REMITTANCE, check.get_ID());
  531.                         try
  532.                         {
  533.                             MPrintFormat format = re.getPrintFormat();
  534.                             if (format.getJasperProcess_ID() > 0)  
  535.                             {
  536.                                 ProcessInfo pi = new ProcessInfo("", format.getJasperProcess_ID());
  537.                                 pi.setRecord_ID(check.get_ID());
  538.                                 pi.setIsBatch(true);
  539.                                
  540.                                 ServerProcessCtl.process(pi, null);
  541.                                 pdfList.add(pi.getPDFReport());
  542.                             }
  543.                             else
  544.                             {
  545.                                 File file = File.createTempFile("WPayPrint", null);
  546.                                 re.getPDF(file);
  547.                                 pdfList.add(file);
  548.                             }
  549.                         }
  550.                         catch (Exception e)
  551.                         {
  552.                             log.log(Level.SEVERE, e.getLocalizedMessage(), e);
  553.                         }
  554.                     }
  555.    
  556.                     try
  557.                     {
  558.                         File outFile = File.createTempFile("WPayPrint", null);
  559.                         AEnv.mergePdf(pdfList, outFile);
  560.                         String name = Msg.translate(Env.getCtx(), "Remittance");
  561.                         remitViewer = new SimplePDFViewer(form.getFormName() + " - " + name, new FileInputStream(outFile));
  562.                         remitViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
  563.                         remitViewer.setWidth("100%");
  564.                     }
  565.                     catch (Exception e)
  566.                     {
  567.                         log.log(Level.SEVERE, e.getLocalizedMessage(), e);
  568.                     }
  569.                 }
  570.                
  571.                 dispose();
  572.  
  573.                 if (chequeViewerRef != null)
  574.                     SessionManager.getAppDesktop().showWindow(chequeViewerRef);
  575.  
  576.                 if (remitViewer != null)
  577.                     SessionManager.getAppDesktop().showWindow(remitViewer);
  578.             }
  579.         });
  580.     }   //  cmd_print
  581.  
  582.  
  583.     /**************************************************************************
  584.      *  Get Checks
  585.      *  @param PaymentRule Payment Rule
  586.      *  @return true if payments were created
  587.      */
  588.     protected boolean getChecks(String PaymentRule)
  589.     {
  590.         //  do we have values
  591.         if (m_C_PaySelection_ID <= 0 || m_C_BankAccount_ID == -1
  592.             || fPaymentRule.getSelectedIndex() == -1 || fDocumentNo.getValue() == null)
  593.         {
  594.             FDialog.error(m_WindowNo, form, "VPayPrintNoRecords",
  595.                 "(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + "=0)");
  596.             return false;
  597.         }
  598.  
  599.         if (log.isLoggable(Level.CONFIG)) log.config("C_PaySelection_ID=" + m_C_PaySelection_ID + ", PaymentRule=" +  PaymentRule);
  600.        
  601.         //  get payment selection checks without check no assignment
  602.         m_checks = MPaySelectionCheck.get(m_C_PaySelection_ID, PaymentRule, null);
  603.  
  604.         //
  605.         if (m_checks == null || m_checks.length == 0)
  606.         {
  607.             FDialog.error(m_WindowNo, form, "VPayPrintNoRecords",
  608.                 "(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + " #0");
  609.             return false;
  610.         }
  611.         m_batch = MPaymentBatch.getForPaySelection (Env.getCtx(), m_C_PaySelection_ID, null);
  612.         return true;
  613.     }   //  getChecks
  614.  
  615.     public ADForm getForm() {
  616.         return form;
  617.     }
  618.  
  619.     /**
  620.      *  Vetoable Change Listener.
  621.      *  - Payment Selection
  622.      *  @param e event
  623.      */
  624.     @Override
  625.     public void valueChange(ValueChangeEvent e) {
  626.         String name = e.getPropertyName();
  627.         Object value = e.getNewValue();
  628.         if (log.isLoggable(Level.CONFIG)) log.config(name + "=" + value);
  629.         if (value == null)
  630.             return;
  631.        
  632.         // Payment Selection
  633.         if (name.equals("C_PaySelection_ID"))
  634.         {
  635.             paySelectSearch.setValue(value);
  636.             m_C_PaySelection_ID = ((Integer)value).intValue();
  637.             loadPaySelectInfo();
  638.         }
  639.     }
  640.  
  641. }   //  PayPrint
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement