public Cmd_Export Cmd_Export(Ctx ctx, int C_PaySelection_ID, int m_C_BankAccount_ID, string PaymentRule, int startDocumentNo) { Cmd_Export objCmdExport = new Cmd_Export(); bool res = false; log.Info(PaymentRule); log.Config("C_PaySelection_ID=" + C_PaySelection_ID + ", PaymentRule=" + PaymentRule + ", DocumentNo=" + startDocumentNo); string expFile = "Export.txt"; m_checks = VAdvantage.Model.MPaySelectionCheck.Get(C_PaySelection_ID, PaymentRule, startDocumentNo, null); // if (m_checks == null || m_checks.Length == 0) { // ShowMessage.Error("VPayPrintNoRecords", null, "(" + Msg.Translate(Envs.GetCtx(), "C_PaySelectionLine_ID") + " #0"); res = false; //return false; } else { res = true; } m_batch = VAdvantage.Model.MPaymentBatch.GetForPaySelection(ctx, C_PaySelection_ID, null); //return true; if (!res) { return(null); } // Get File Info Dictionary <VAdvantage.Model.MPaySelectionCheck, String> oldCheckValues = new Dictionary <VAdvantage.Model.MPaySelectionCheck, string>(); // Create File List <int> check_ID = new List <int>(); foreach (VAdvantage.Model.MPaySelectionCheck check in m_checks) { //oldCheckValues.put(check,(String)check.get_ValueOld("DocumentNo")); oldCheckValues.Add(check, Util.GetValueOfString(check.Get_ValueOld("DocumentNo"))); check_ID.Add(Util.GetValueOfInt(check.Get_ID())); } List <String[]> busPart = new List <String[]>(); List <String[]> bankAcc = new List <String[]>(); List <String> comm = new List <String>(); List <String> DocumentNo = new List <String>(); List <String> PayDate = new List <String>(); List <String> ISOCode = new List <String>(); List <String> PayAmt = new List <String>(); //// write lines for (int i = 0; i < m_checks.Length; i++) { VAdvantage.Model.MPaySelectionCheck mpp = m_checks[i]; if (mpp == null) { continue; } // BPartner Info bp = GetBPartnerInfo(mpp.GetC_BPartner_ID()); busPart.Add(bp); // TarGet BankAccount Info bpba = GetBPBankAccountInfo(mpp.GetC_BP_BankAccount_ID()); bankAcc.Add(bpba); // Comment - list of invoice document no StringBuilder comment = new StringBuilder(); VAdvantage.Model.MPaySelectionLine[] psls = mpp.GetPaySelectionLines(false); for (int l = 0; l < psls.Length; l++) { if (l > 0) { comment.Append(", "); } comment.Append(psls[l].GetInvoice().GetDocumentNo()); } comm.Add(comment.ToString()); DocumentNo.Add(mpp.GetDocumentNo()); PayDate.Add(mpp.GetParent().GetPayDate().ToString()); ISOCode.Add(VAdvantage.Model.MCurrency.GetISO_Code(ctx, mpp.GetParent().GetC_Currency_ID())); PayAmt.Add(mpp.GetPayAmt().ToString()); } string filepath = Export(m_checks, expFile, comm, busPart, bankAcc, DocumentNo, PayDate, ISOCode, PayAmt); objCmdExport.check_ID = check_ID; objCmdExport.m_batch = m_batch.GetC_PaymentBatch_ID(); objCmdExport.filepath = filepath; return(objCmdExport); }
/// <summary> /// Print Checks and/or Remittance /// </summary> public Cmd_Print Cmd_Print(Ctx ctx, int C_PaySelection_ID, int m_C_BankAccount_ID, string PaymentRule, int startDocumentNo) { Cmd_Print objCmdPrint = new Cmd_Print(); VAdvantage.ProcessEngine.ProcessCtl pctrl = null; bool res = false; log.Info(PaymentRule); log.Config("C_PaySelection_ID=" + C_PaySelection_ID + ", PaymentRule=" + PaymentRule + ", DocumentNo=" + startDocumentNo); m_checks = VAdvantage.Model.MPaySelectionCheck.Get(C_PaySelection_ID, PaymentRule, startDocumentNo, null); if (m_checks == null || m_checks.Length == 0) { //ShowMessage.Error("VPayPrintNoRecords", null, "(" + Msg.Translate(Envs.GetCtx(), "C_PaySelectionLine_ID") + " #0"); res = false; //return false; } else { res = true; } m_batch = VAdvantage.Model.MPaymentBatch.GetForPaySelection(ctx, C_PaySelection_ID, null); if (!m_batch.Save()) { } //return true; if (!res) { return(null); } bool somethingPrinted = false; bool directPrint = !Ini.IsPropertyBool(Ini.P_PRINTPREVIEW); Dictionary <VAdvantage.Model.MPaySelectionCheck, String> oldCheckValues = new Dictionary <VAdvantage.Model.MPaySelectionCheck, string>(); int checkID = 0; int c_payment_ID = 0; List <int> check_ID = new List <int>(); foreach (VAdvantage.Model.MPaySelectionCheck check in m_checks) { // ReportCtrl will check BankAccountDoc for PrintFormat oldCheckValues.Add(check, Util.GetValueOfString(check.Get_ValueOld("CheckNo"))); check.Save(); checkID = Util.GetValueOfInt(check.Get_ID()); check_ID.Add(checkID); if (!somethingPrinted) { somethingPrinted = true; } } int table_ID = 0; int AD_Process_ID = 0; string sql = ""; int paymentTable_ID = 0; int paymentAD_Process_ID = 0; try { sql = "select ad_table_id from ad_table where tablename = 'C_PaySelectionCheck'"; table_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)); //sql = "select ad_process_id from ad_process where value = 'CheckPrint'"; sql = "select ad_process_id from ad_process where ad_printformat_id = (select check_printformat_id from c_bankaccountdoc where c_bankaccount_id = (select c_bankaccount_id from c_payment where c_payment_id = (select c_payment_id from c_payselectioncheck where c_payselectioncheck_id = " + checkID + ")) and c_bankaccountdoc.isactive = 'Y' and rownum =1)"; AD_Process_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)); sql = "select ad_table_id from ad_table where tablename = 'C_Payment'"; paymentTable_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)); sql = "select ad_process_id from ad_process where value = 'PaymentPrintFormat'"; paymentAD_Process_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)); // int paymentAD_Process_ID = 313; } catch { } //for (int j = 0; j < check_ID.Count; j++) //{ // int record_ID = Util.GetValueOfInt(checkID); // VAdvantage.ProcessEngine.ProcessInfo pi = new VAdvantage.ProcessEngine.ProcessInfo(null, AD_Process_ID, table_ID, Util.GetValueOfInt(check_ID[j])); // pi.SetAD_User_ID(ctx.GetAD_User_ID()); // pi.SetAD_Client_ID(ctx.GetAD_Client_ID()); // byte[] reportData = null; // string result=""; // pctrl = new VAdvantage.ProcessEngine.ProcessCtl(ctx,null, pi, null); // pctrl.Process(pi, ctx,out reportData,out result); //} objCmdPrint.check_ID = check_ID; objCmdPrint.m_batch = m_batch.GetC_PaymentBatch_ID(); return(objCmdPrint); }