Esempio n. 1
0
 public bool CancelPayment(string pStrDocEntry)
 {
     try
     {
         int lIntDocNum = Convert.ToInt32(mObjPurchaseServiceFactory.GetPurchasePaymentService().GetPaymentDocNum(pStrDocEntry));
         if (lIntDocNum != 0)
         {
             SAPbobsCOM.Payments lObjPayment = (SAPbobsCOM.Payments)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments);
             lObjPayment.GetByKey(lIntDocNum);
             if (lObjPayment.CancelbyCurrentSystemDate() != 0)
             {
                 UIApplication.ShowMessageBox(DIApplication.Company.GetLastErrorDescription());
                 LogService.WriteError("PaymentDI (CancelPayment) DocEntry:" + pStrDocEntry + " Mensaje:" + DIApplication.Company.GetLastErrorDescription());
                 return(false);
             }
             else
             {
                 LogService.WriteSuccess("Pago cancelado correctamente: PaymentDocEntry: " + pStrDocEntry);
                 return(true);
             }
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         UIApplication.ShowMessageBox(ex.Message);
         LogService.WriteError("PaymentDI (CancelPayment) DocEntry:" + pStrDocEntry + " Mensaje:" + ex.Message);
         LogService.WriteError(ex);
         return(false);
     }
 }
 public void AddPayment(SAPbouiCOM.Form form, double total)
 {
     try
     {
         SAPbobsCOM.Documents oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
         int sNum = int.Parse(getItemValue(form, fidRecordID));
         oDoc.GetByKey(sNum);
         if (!oDoc.GetByKey(sNum))
         {
             SBO_Application.MessageBox(oCompany.GetLastErrorDescription());
             return;
         }
         SAPbobsCOM.Payments oPmt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);
         oPmt.Invoices.DocEntry = sNum;
         oPmt.CardCode          = oDoc.CardCode;
         oPmt.DocDate           = DateTime.Now;
         oPmt.DocTypte          = SAPbobsCOM.BoRcptTypes.rCustomer;
         string acct = GetConfig("SAPAccountForIncomingPayment");
         if (acct != "")
         {
             oPmt.CashAccount = acct;
         }
         oPmt.CashSum        = total;
         oPmt.JournalRemarks = GetRemark(form);
         int r = oPmt.Add();
         if (r != 0)
         {
             SBO_Application.MessageBox(oCompany.GetLastErrorDescription());
         }
     }
     catch (Exception ex)
     {
         errorLog(ex);
     }
 }
Esempio n. 3
0
        public bool CreatePayment(AuctionDTO pObjAuctionDTO, List <InvoiceDTO> pLstObjInvoice)
        {
            bool lBolIsSuccess = false;

            try
            {
                SAPbobsCOM.Payments lObjPayment = (SAPbobsCOM.Payments)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);

                lObjPayment.CardCode      = pObjAuctionDTO.CardCode;
                lObjPayment.DocObjectCode = SAPbobsCOM.BoPaymentsObjectType.bopot_IncomingPayments;
                lObjPayment.DocDate       = DateTime.Now;
                lObjPayment.DocType       = SAPbobsCOM.BoRcptTypes.rCustomer;
                lObjPayment.UserFields.Fields.Item("U_GLO_PaymentType").Value  = "GLPGO";
                lObjPayment.UserFields.Fields.Item("U_FZ_AuxiliarType").Value  = "1";
                lObjPayment.UserFields.Fields.Item("U_FZ_Auxiliar").Value      = pObjAuctionDTO.CardCode;
                lObjPayment.UserFields.Fields.Item("U_FZ_FolioAuction").Value  = pObjAuctionDTO.AuctionID;
                lObjPayment.UserFields.Fields.Item("U_GLO_CostCenter").Value   = pObjAuctionDTO.LocationId;
                lObjPayment.UserFields.Fields.Item("U_FechaPago").Value        = DateTime.Now.ToString("dd-MM-yyyy");
                lObjPayment.UserFields.Fields.Item("U_HoraPago").Value         = DateTime.Now.ToString("HH:mm");
                lObjPayment.UserFields.Fields.Item("U_B1SYS_PmntMethod").Value = "17";


                lObjPayment.CashSum = Convert.ToDouble(pObjAuctionDTO.TotalSell);

                lObjPayment.CashAccount = pObjAuctionDTO.AccountD;// lObjPurchasesDAO.GetAccountRefund(pObjPurchase.Area);



                foreach (InvoiceDTO lObjInvoice in pLstObjInvoice)
                {
                    lObjPayment.Invoices.DocEntry    = Convert.ToInt32(lObjInvoice.DocEntry);
                    lObjPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice;
                    lObjPayment.Invoices.SumApplied  = Convert.ToDouble(lObjInvoice.Amount);
                    lObjPayment.Invoices.Add();
                }


                if (lObjPayment.Add() != 0)
                {
                    UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription()));
                    LogService.WriteError("PaymentDI (CreatePayment) DocEntry:" + pObjAuctionDTO.AuctionID + " Mensaje:" + DIApplication.Company.GetLastErrorDescription());
                }
                else
                {
                    LogService.WriteSuccess("pago creado correctamente: InvoiceDocEntry: " + pObjAuctionDTO.AuctionID);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("PaymentDI (Create) InvoiceDocEntry:" + pObjAuctionDTO.AuctionID + " Mensaje:" + ex.Message);
                LogService.WriteError(ex);
            }
            return(lBolIsSuccess);
        }
Esempio n. 4
0
    public bool job_AddPayment( CCJOB job , SAPbobsCOM.Documents oDoc, SAPCust cust, string amt = "", string customerID = "")
    {
        try
        {
            double dtotal = 0;
            if(oDoc != null)
                dtotal = oDoc.DocTotal;
            if (amt != "")
                dtotal = getDoubleValue(amt);
            SAPbobsCOM.Payments oPmt = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);
            int bplid = getBranchIdFromINV(oDoc.DocEntry.ToString());
            if (bplid != 0)
                oPmt.BPLID = bplid;
            if (oDoc != null)
            {
                oPmt.Invoices.DocEntry = oDoc.DocEntry;
                oPmt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice;
                oPmt.CardCode = oDoc.CardCode;
                oPmt.Invoices.SumApplied = dtotal;
            }
            else
                oPmt.CardCode = customerID;
            oPmt.DocDate = DateTime.Now;
            oPmt.Remarks = "eBizCharge Payment On Account Recurring Billing " + confirmNum;
            //oPmt.TransferDate = DateTime.Now;
            oPmt.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer;
            AddCreditCardPayment(oPmt, cust, dtotal, true);
            int r = oPmt.Add();
            if (r != 0)
            {
                errorLog("Job Failed on Add Payment. ID:" + job.jobID + "\r\n" +
                    "OrderID:" + job.OrderID + "\r\n" +
                    "CCAcountID:" + cust.cccust.CCAccountID + "\r\n" +
                    getErrorString());
                voidCustomer(confirmNum);
                job.Result = "Failed. " + getErrorString();
                job.LastRunDate = DateTime.Today;
                update(job);
                return false;
            }
            CCTRANUpdateIncomingPaymentID(confirmNum);
        }
        catch (Exception ex)
        {
            errorLog(ex);
            job.Result = "Failed. " +ex.Message;
            job.LastRunDate = DateTime.Today;
            update(job);
            voidCustomer(confirmNum);
            return false;

        }
        return true;
    }
Esempio n. 5
0
        /// <summary>
        /// Crea un pago
        /// </summary>
        public bool CreatePayment(PurchaseXMLDTO pObjPurchase)
        {
            bool lBolIsSuccess = false;

            try
            {
                SAPbobsCOM.Payments lObjPayment = (SAPbobsCOM.Payments)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments);
                lObjPayment.CardCode = pObjPurchase.CardCode;

                lObjPayment.DocObjectCode = SAPbobsCOM.BoPaymentsObjectType.bopot_OutgoingPayments;
                //lObjPayment.DocDate = pObjPurchase.DocDate;
                lObjPayment.TaxDate = pObjPurchase.TaxDate;
                lObjPayment.DocDate = pObjPurchase.DocDate;
                lObjPayment.DocType = SAPbobsCOM.BoRcptTypes.rSupplier;

                lObjPayment.CashSum = Convert.ToDouble(pObjPurchase.Total);

                lObjPayment.CashAccount = pObjPurchase.Account;// lObjPurchasesDAO.GetAccountRefund(pObjPurchase.Area);

                lObjPayment.Invoices.DocEntry    = pObjPurchase.DocEntry;
                lObjPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_PurchaseInvoice;
                lObjPayment.Invoices.SumApplied  = Convert.ToDouble(pObjPurchase.Total);


                lObjPayment.UserFields.Fields.Item("U_GLO_PaymentType").Value = "GLPGO";
                lObjPayment.UserFields.Fields.Item("U_FZ_AuxiliarType").Value = "2";
                lObjPayment.UserFields.Fields.Item("U_FZ_Auxiliar").Value     = pObjPurchase.Employee;
                lObjPayment.UserFields.Fields.Item("U_GLO_CostCenter").Value  = pObjPurchase.Area;
                lObjPayment.UserFields.Fields.Item("U_GLO_CodeMov").Value     = pObjPurchase.CodeMov;

                if (lObjPayment.Add() != 0)
                {
                    UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription()));
                    LogService.WriteError("PaymentDI (CreatePayment) DocEntry:" + pObjPurchase.DocEntry + " Mensaje:" + DIApplication.Company.GetLastErrorDescription());
                }
                else
                {
                    LogService.WriteSuccess("pago creado correctamente: InvoiceDocEntry: " + pObjPurchase.DocEntry);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("PaymentDI (CancelDocument) InvoiceDocEntry:" + pObjPurchase.DocEntry + " Mensaje:" + ex.Message);
                LogService.WriteError(ex);
            }
            return(lBolIsSuccess);
        }
 public void AddOutgoingPayment(SAPbouiCOM.Form form, double total)
 {
     try
     {
         SAPbobsCOM.Documents oDoc = null;
         oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oCreditNotes);
         int sNum = int.Parse(getItemValue(form, fidRecordID));
         if (!oDoc.GetByKey(sNum))
         {
             SBO_Application.MessageBox(oCompany.GetLastErrorDescription());
             return;
         }
         SAPbobsCOM.Payments oPmt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments);
         oPmt.Invoices.DocEntry    = sNum;
         oPmt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_CredItnote;
         oPmt.CashAccount          = GetConfig("SAPAccountForOutgoingPayment");
         oPmt.CardCode             = oDoc.CardCode;
         oPmt.DocDate        = DateTime.Now;
         oPmt.DocTypte       = SAPbobsCOM.BoRcptTypes.rCustomer;
         oPmt.CashSum        = total;
         oPmt.JournalRemarks = GetRemark(form);
         int r = oPmt.Add();
         if (r != 0)
         {
             SBO_Application.MessageBox(oCompany.GetLastErrorDescription());
         }
         else
         {
             SBO_Application.MessageBox("Outgoing payment record added");
         }
     }
     catch (Exception ex)
     {
         errorLog(ex);
     }
 }
Esempio n. 7
0
    public void checkePayPaidStatus(string custid, string securityID = "")
    {
        SAPDBDataContext db = new SAPDBDataContext(connStr);

        try
        {
            if (custid == "" || custid == null)
            {
                return;
            }
            SAPbobsCOM.Documents oDoc = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
            string invType            = "Invoice";
            if (oePaymentFormForm != null)
            {
                invType = getFormItemVal(oePaymentFormForm, cbInvType);
                showStatus("Checking " + invType + " payment status for customer: " + custid + ". Please wait...", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
            }
            else if (cfgConnectUseDP == "Y")
            {
                invType = "Down Payment";
            }
            showStatus("Checking payment status for customer: " + custid + ". Please wait...", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
            if (invType == "Down Payment")
            {
                oDoc = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDownPayments);
            }
            string invSql = " OINV (NOLOCK) ";
            if (invType == "Down Payment")
            {
                invSql = " ODPI (NOLOCK) ";
            }
            SecurityToken securityToken = getTokenEx(custid, "", "", "");
            if (securityID != "")
            {
                securityToken.SecurityId = securityID;
            }

            Payment[] pmts = ebiz.SearchEbizWebFormReceivedPayments(securityToken, custid, DateTime.Today.AddDays(-90), DateTime.Today.AddDays(1), null, 0, 1000, "");
            trace(string.Format("ebiz.SearchEbizWebFormReceivedPayments found {0} for custid {1}", pmts.Count(), custid));

            foreach (Payment p in pmts)
            {
                trace(string.Format("eMail Form pmt = {0}, {1}, {2}, {3}, {4}", p.InvoiceNumber, p.CustomerId, p.RefNum, p.AuthCode, p.PaidAmount));
                if (p.InvoiceNumber == "Method Request")
                {
                    continue;
                }
                //Invoice inv = ebiz.GetInvoice(securityToken, p.DatePaid, "", p.InvoiceNumber, "");
                var q = from x in db.CCPayFormInvoices
                        where x.InvoiceID == p.InvoiceNumber
                        select x;
                if (q.Count() == 0)
                {
                    trace("EMAIL Form invoice with payment not found in CCPayFormInvoice invoice no. " + p.InvoiceNumber);

                    CCPayFormInvoice ccinv = new CCPayFormInvoice();
                    ccinv.CustomerID      = p.CustomerId;
                    ccinv.InvoiceID       = p.InvoiceNumber;
                    ccinv.InvoiceGUID     = getSQLInt(string.Format("select DocEntry from {0} where cardcode='{1}' and docnum = {2}", invSql, p.CustomerId, p.InvoiceNumber)).ToString();
                    ccinv.UploadedBalance = p.InvoiceAmount.ToString();
                    ccinv.PaidAmount      = "0";
                    ccinv.Status          = "Uploaded";
                    ccinv.UploadDate      = DateTime.Today;
                    db.CCPayFormInvoices.InsertOnSubmit(ccinv);
                    db.SubmitChanges();
                    q = from x in db.CCPayFormInvoices
                        where x.InvoiceID == p.InvoiceNumber
                        select x;
                }
                foreach (CCPayFormInvoice i in q)
                {
                    try
                    {
                        if (!oDoc.GetByKey(int.Parse(i.InvoiceGUID)))
                        {
                            errorLog("Inv not found: " + i.InvoiceGUID);
                            i.Status = "Invoice not found: " + i.InvoiceGUID;

                            db.SubmitChanges();
                            continue;
                        }
                        if (oDoc.DocumentStatus == SAPbobsCOM.BoStatus.bost_Close)
                        {
                            i.PaidAmount = p.PaidAmount;
                            i.PaidDate   = DateTime.Parse(p.DatePaid);
                            i.Status     = "Paid";
                            db.SubmitChanges();
                        }
                        else
                        {
                            var qcc = from x in db.CCPayFormPayments
                                      where x.CustomerID == p.CustomerId && x.InvoiceID == p.InvoiceNumber && x.PaymentID == p.AuthCode
                                      select x;
                            if (qcc.Count() == 0)
                            {
                                SAPbobsCOM.Payments oPmt = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);
                                int bplid = getBranchIdFromINV(p.InvoiceNumber);
                                if (bplid != 0)
                                {
                                    oPmt.BPLID = bplid;
                                }
                                oPmt.CardCode = i.CustomerID;
                                oPmt.DocDate  = DateTime.Now;
                                //  oPmt.Remarks = "eBizCharge ePayment Form Payment";

                                oPmt.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer;
                                // oPmt.JournalRemarks = "eBizCharge ePayment Form payment";
                                oPmt.Invoices.DocEntry    = int.Parse(i.InvoiceGUID);
                                oPmt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice;
                                if (oDoc.DocObjectCode == SAPbobsCOM.BoObjectTypes.oDownPayments)
                                {
                                    oPmt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_DownPayment;
                                }

                                oPmt.Invoices.SumApplied = getDoubleValue(p.PaidAmount);

                                SAPCust sapcust = getCustomerByID(i.CustomerID, "");
                                sapcust.cccust.CCAccountID = geteConnectCardCode(p.PaymentMethod);
                                AddCreditCardPayment(oPmt, sapcust, getDoubleValue(p.PaidAmount), true, p.RefNum);
                                int r = oPmt.Add();
                                if (r != 0)
                                {
                                    errorLog("ePaymentForm Failed Payment. ID:" + i.CustomerID + "\r\n" +
                                             "InvoiceID:" + i.InvoiceGUID + "\r\n" +
                                             oCompany.GetLastErrorDescription());
                                }
                                else
                                {
                                    CCPayFormPayment pmt = new CCPayFormPayment();
                                    pmt.InvoiceID    = p.InvoiceNumber;
                                    pmt.CustomerID   = p.CustomerId;
                                    pmt.PaymentID    = p.AuthCode;
                                    pmt.Amount       = p.PaidAmount;
                                    pmt.DateImported = DateTime.Now;
                                    db.CCPayFormPayments.InsertOnSubmit(pmt);
                                    db.SubmitChanges();
                                }
                            }
                            i.PaidAmount = p.PaidAmount;
                            i.PaidDate   = DateTime.Parse(p.DatePaid);
                            if (getDoubleValue(p.PaidAmount) < getDoubleValue(p.InvoiceAmount))
                            {
                                i.Status = EPAY_STATUS_PARTIAL;
                            }
                            else
                            {
                                i.Status = EPAY_STATUS_PAID;
                            }
                            db.SubmitChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        errorLog(ex);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            errorLog(ex);
        }
        showStatus("Status check for customer: " + custid + " completed.", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
    }
Esempio n. 8
0
    public void checkePayPaidStatus(string custid)
    {
        try
        {
            if (custid == "" || custid == null)
            {
                return;
            }
            if (!IsPayFormCustomerExist(custid))
            {
                return;
            }
            SBO_Application.SetStatusBarMessage("Checking payment status for customer: " + custid + ". Please wait...", SAPbouiCOM.BoMessageTime.bmt_Medium, false);


            SecurityToken securityToken = getToken();

            Payment[] pmts = ebiz.SearchEbizWebFormReceivedPayments(securityToken, custid, DateTime.Today.AddDays(-90), DateTime.Today.AddDays(1), null, 0, 1000, "");
            foreach (Payment p in pmts)
            {
                List <CCPayFormInvoice> q = findCCPayFormInvoice(string.Format(" where \"U_InvoiceID\" = '{0}' and \"U_CustomerID\"='{1}'", p.InvoiceNumber, p.CustomerId));
                foreach (CCPayFormInvoice i in q)
                {
                    try
                    {
                        SAPbobsCOM.Documents oDoc = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
                        if (!oDoc.GetByKey(int.Parse(i.InvoiceGUID)))
                        {
                            errorLog("Inv not found: " + i.InvoiceGUID);
                            i.Status = "Invoice not found: " + i.InvoiceGUID;

                            update(i);
                            continue;
                        }
                        if (oDoc.DocumentStatus == SAPbobsCOM.BoStatus.bost_Close)
                        {
                            i.PaidAmount = p.PaidAmount;
                            i.PaidDate   = DateTime.Parse(p.DatePaid);
                            i.Status     = "Paid";
                            update(i);
                        }
                        else
                        {
                            string where = string.Format(" where \"U_CustomerID\"='{0}' and \"U_InvoiceID\"='{1}' and \"U_PaymentID\"='{2}'", p.CustomerId, p.InvoiceNumber, p.AuthCode);

                            var qcc = findCCPayFormPayment(where);
                            if (qcc.Count() == 0)
                            {
                                SAPbobsCOM.Payments oPmt = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);
                                int bplid = getBranchIdFromINV(i.InvoiceGUID);
                                if (bplid != 0)
                                {
                                    oPmt.BPLID = bplid;
                                }
                                oPmt.CardCode = i.CustomerID;
                                oPmt.DocDate  = DateTime.Now;
                                oPmt.Remarks  = "eBizCharge ePayment Form Payment";

                                oPmt.DocTypte             = SAPbobsCOM.BoRcptTypes.rCustomer;
                                oPmt.JournalRemarks       = "eBizCharge ePayment Form payment";
                                oPmt.Invoices.DocEntry    = int.Parse(i.InvoiceGUID);
                                oPmt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice;
                                oPmt.Invoices.SumApplied  = double.Parse(p.PaidAmount);
                                SAPCust sapcust = getCustomerByID(i.CustomerID, "");
                                AddCreditCardPayment(oPmt, sapcust, double.Parse(p.PaidAmount), true);
                                int r = oPmt.Add();
                                if (r != 0)
                                {
                                    errorLog("ePaymentForm Failed Payment. ID:" + i.CustomerID + "\r\n" +
                                             "InvoiceID:" + i.InvoiceGUID + "\r\n" +
                                             oCompany.GetLastErrorDescription());
                                }
                                else
                                {
                                    CCPayFormPayment pmt = new CCPayFormPayment();
                                    pmt.InvoiceID    = p.InvoiceNumber;
                                    pmt.CustomerID   = p.CustomerId;
                                    pmt.PaymentID    = p.AuthCode;
                                    pmt.Amount       = p.PaidAmount;
                                    pmt.DateImported = DateTime.Now;
                                    insert(pmt);
                                }
                            }
                            i.PaidAmount = p.PaidAmount;
                            i.PaidDate   = DateTime.Parse(p.DatePaid);
                            if (double.Parse(p.PaidAmount) < double.Parse(p.InvoiceAmount))
                            {
                                i.Status = EPAY_STATUS_PARTIAL;
                            }
                            else
                            {
                                i.Status = EPAY_STATUS_PAID;
                            }
                            update(i);
                        }
                    }
                    catch (Exception ex)
                    {
                        errorLog(ex);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            errorLog(ex);
        }
        SBO_Application.SetStatusBarMessage("Status check for customer: " + custid + " completed.", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
    }
Esempio n. 9
0
        private static void addDownPayment(int docEntry)
        {
            bool Success = false;

            SAPbobsCOM.Documents ObjDownPayment;
            SAPbobsCOM.Documents objSO;
            objSO = (SAPbobsCOM.Documents)sboDI.oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
            objSO.GetByKey(docEntry);



            string PayMethod = objSO.UserFields.Fields.Item("U_B1_ABC_PAYMETHOD").Value.ToString();
            string PayRef    = objSO.UserFields.Fields.Item("U_B1_ABC_PAYREF").Value.ToString();

            ObjDownPayment = (SAPbobsCOM.Documents)sboDI.oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDownPayments);
            ObjDownPayment.DownPaymentType = SAPbobsCOM.DownPaymentTypeEnum.dptInvoice;
            ObjDownPayment.CardCode        = objSO.CardCode;
            ObjDownPayment.NumAtCard       = objSO.NumAtCard;
            ObjDownPayment.DocDate         = objSO.DocDate;
            ObjDownPayment.DocDueDate      = objSO.DocDate;
            ObjDownPayment.NumAtCard       = objSO.NumAtCard;
            ObjDownPayment.TrackingNumber  = PayRef;
            ObjDownPayment.UserFields.Fields.Item("U_B1_ABC_PAYMETHOD").Value = objSO.UserFields.Fields.Item("U_B1_ABC_PAYMETHOD").Value.ToString();
            ObjDownPayment.UserFields.Fields.Item("U_B1_ABC_PAYREF").Value    = objSO.UserFields.Fields.Item("U_B1_ABC_PAYREF").Value.ToString();

            for (int i = 0; i < objSO.Lines.Count; i++)
            {
                objSO.Lines.SetCurrentLine(i);

                ObjDownPayment.Lines.BaseType  = 17;
                ObjDownPayment.Lines.BaseEntry = objSO.DocEntry;
                ObjDownPayment.Lines.BaseLine  = objSO.Lines.VisualOrder;
                ObjDownPayment.Lines.ItemCode  = objSO.Lines.ItemCode;
                ObjDownPayment.Lines.Quantity  = objSO.Lines.Quantity;
                //  ObjDownPayment.Lines.UnitPrice = objSO.Lin
                ObjDownPayment.Lines.Add();
            }



            ObjDownPayment.DownPaymentPercentage = 100;


            // ObjDownPayment.DownPaymentAmount = amount

            Int32 lRetCode = ObjDownPayment.Add();

            if (lRetCode != 0)
            {
                Success = false;
                int    erroCode = 0;
                string errDescr = "";
                sboDI.oDiCompany.GetLastError(out erroCode, out errDescr);
                errDescr = errDescr.Replace("'", "");

                if (errDescr.Contains("Closing Period"))
                {
                }
                else
                {
                }
            }
            else
            {
                Success = true;
                int dpmKey = Convert.ToInt32(sboDI.oDiCompany.GetNewObjectKey());

                SAPbobsCOM.Payments ObjPayment = (SAPbobsCOM.Payments)sboDI.oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);
                ObjPayment.CardCode             = objSO.CardCode;
                ObjPayment.DocDate              = objSO.DocDate;
                ObjPayment.DocType              = SAPbobsCOM.BoRcptTypes.rCustomer;
                ObjPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_DownPayment;
                ObjPayment.Invoices.DocEntry    = dpmKey;

                ObjPayment.Invoices.SumApplied = objSO.DocTotal;

                ObjPayment.Invoices.Add();

                ObjPayment.UserFields.Fields.Item("U_B1_ABC_PAYREF").Value    = PayRef;
                ObjPayment.UserFields.Fields.Item("U_B1_ABC_PAYMETHOD").Value = PayMethod;
                ObjPayment.UserFields.Fields.Item("U_B1_ABC_WEBNUM").Value    = objSO.NumAtCard;



                ObjPayment.CashSum     = objSO.DocTotal;
                ObjPayment.CashAccount = getCashAcct(PayMethod);


                if (ObjPayment.Add() == 0)
                {
                    Success = true;
                }
                else
                {
                    Success = false;
                    int erroCode = 0;
                }
            }
        }
        private void DoPayment()
        {
            try
            {
                if (ValidateEmptyControls())
                {
                    Application.SBO_Application.SetStatusBarMessage("Verificar campos vacíos", SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    return;
                }

                if (dtTravelExp.Rows.Count <= 0)
                {
                    Application.SBO_Application.SetStatusBarMessage("No puede crear un pago sin líneas", SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    return;
                }

                if (string.IsNullOrEmpty(mStrExpDayAcct) || string.IsNullOrEmpty(mStrMinorPurchAcct) || string.IsNullOrEmpty(mStrViaticExpAcct) || string.IsNullOrEmpty(mStrViaticPaymAcct))
                {
                    Application.SBO_Application.SetStatusBarMessage("Alguna de las cuentas de configuración no tiene valor, favor de verificar", SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    return;
                }

                this.UIAPIRawForm.Freeze(true);

                SAPbobsCOM.Payments lObjOutgoingPayment = (SAPbobsCOM.Payments)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments);
                lObjOutgoingPayment.DocObjectCode = SAPbobsCOM.BoPaymentsObjectType.bopot_OutgoingPayments;
                lObjOutgoingPayment.DocDate       = DateTime.Now;
                lObjOutgoingPayment.DocType       = SAPbobsCOM.BoRcptTypes.rAccount;
                lObjOutgoingPayment.CashAccount   = mStrViaticPaymAcct;
                lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_PaymentType").Value = ((int)PaymentsTypesEnum.TravelExpenses).ToString();
                lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_CodeMov").Value     = txtFolio.Value; //folio de solicitud de viáticos
                lObjOutgoingPayment.UserFields.Fields.Item("U_GLO_CostCenter").Value  = "MQ_MAQUI";     //centro de costo
                lObjOutgoingPayment.CashSum = double.Parse(txtTotal.Value);

                for (int i = 0; i < dtTravelExp.Rows.Count; i++)
                {
                    int    lIntMovTypeCode  = int.Parse(dtTravelExp.GetValue(9, i).ToString());
                    double lDblLineImport   = double.Parse(dtTravelExp.GetValue(8, i).ToString());
                    string lStrEmployeeType = dtTravelExp.GetValue(10, i).ToString();
                    string lStrEmployeeCode = dtTravelExp.GetValue(5, i).ToString();
                    double lDblDayPrice     = double.Parse(dtTravelExp.GetValue(7, i).ToString());

                    lObjOutgoingPayment.AccountPayments.SetCurrentLine(i);
                    lObjOutgoingPayment.AccountPayments.SumPaid = lDblLineImport;
                    lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_GLO_TypeViatic").Value = lIntMovTypeCode.ToString();
                    lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_MQ_TypeEmp").Value     = lStrEmployeeType;
                    lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_MQ_Aux").Value         = lStrEmployeeCode; //code empleado
                    lObjOutgoingPayment.AccountPayments.UserFields.Fields.Item("U_MQ_DayPrice").Value    = lDblDayPrice;

                    switch (lIntMovTypeCode)
                    {
                    case (int)TravelExpMovTypesEnum.DayExpenses:
                        lObjOutgoingPayment.AccountPayments.AccountCode = mStrExpDayAcct;
                        break;

                    case (int)TravelExpMovTypesEnum.MinorExpenses:
                        lObjOutgoingPayment.AccountPayments.AccountCode = mStrMinorPurchAcct;
                        break;

                    case (int)TravelExpMovTypesEnum.TravelExpenses:
                        lObjOutgoingPayment.AccountPayments.AccountCode = mStrViaticExpAcct;
                        break;

                    default:
                        break;
                    }
                    lObjOutgoingPayment.AccountPayments.Add();
                }

                if (lObjOutgoingPayment.Add() != 0)
                {
                    string lStrLastError = DIApplication.Company.GetLastErrorDescription();
                    UIApplication.ShowMessageBox(string.Format("Error al generar el pago: {0}", DIApplication.Company.GetLastErrorDescription()));
                }
                else
                {
                    int lIntDocEntry = int.Parse(DIApplication.Company.GetNewObjectKey());

                    mObjTravelExpensesDTO = mObjMachinerySeviceFactory.GetTravelExpensesService().GetPayment(lIntDocEntry);

                    this.UIAPIRawForm.Close();
                }
            }
            catch (Exception lObjException)
            {
                Application.SBO_Application.MessageBox(string.Format("Error al realizar el pago efectuado: {0}", lObjException.Message));
            }
            finally
            {
                this.UIAPIRawForm.Freeze(false);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Generates a payment for every auction seller.
        /// </summary>
        public void GeneratePayments()
        {
            mBtnGenerate.Item.Enabled = false;

            string lStrAccount     = string.Empty;
            string lStrCostingCode = mObjLastAuction.Location;

            if (lStrCostingCode == "SU_HERMO")
            {
                lStrAccount = mQueryManager.GetValue("U_Value", "Name", "SU_VENDEDOR", Constants.STR_CONFIG_TABLE);
            }
            else
            {
                lStrAccount = mQueryManager.GetValue("U_Value", "Name", "SU_VENDEDORSS", Constants.STR_CONFIG_TABLE);
            }

            string lStrUsername = DIApplication.Company.UserName;

            //string lStrCostingCenter = mQueryManager.GetValue("U_GLO_CostCenter", "USER_CODE", lStrUsername, "OUSR");
            DIApplication.Company.StartTransaction();
            bool lBolSuccess = true;
            int  i           = 0;

            try
            {
                foreach (AuctionSellerDTO lObjSeller in mLstSellers)
                {
                    i++;
                    SAPbobsCOM.Payments lObjPayment = (SAPbobsCOM.Payments)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments);
                    lObjPayment.DocType       = SAPbobsCOM.BoRcptTypes.rAccount;
                    lObjPayment.DocObjectCode = SAPbobsCOM.BoPaymentsObjectType.bopot_OutgoingPayments;

                    //lObjPayment.CardCode = lObjSeller.CardCode;

                    lObjPayment.CardName = lObjSeller.CardName;

                    lObjPayment.AccountPayments.SetCurrentLine(0);
                    lObjPayment.AccountPayments.AccountCode = lStrAccount;
                    lObjPayment.AccountPayments.SumPaid     = lObjSeller.Amount;
                    lObjPayment.BankCode = mCmbBank.Value.ToString(); /// Linea necesaria para que genere el pago con cualquier cuenta de banco
                    lObjPayment.AccountPayments.Add();

                    //lObjPayment.CheckAccount = lStrAccount;

                    lObjPayment.Checks.SetCurrentLine(0);
                    lObjPayment.Checks.CheckSum    = lObjSeller.Amount;
                    lObjPayment.Checks.BankCode    = mCmbBank.Value.ToString();
                    lObjPayment.Checks.AccounttNum = mCmbAcct.Value.ToString();
                    lObjPayment.Checks.Trnsfrable  = SAPbobsCOM.BoYesNoEnum.tYES;
                    lObjPayment.Checks.Add();

                    lObjPayment.UserFields.Fields.Item("U_GLO_PaymentType").Value = "GLPGO";
                    lObjPayment.UserFields.Fields.Item("U_FZ_AuxiliarType").Value = "1";
                    lObjPayment.UserFields.Fields.Item("U_FZ_Auxiliar").Value     = lObjSeller.CardCode;
                    lObjPayment.UserFields.Fields.Item("U_FZ_FolioAuction").Value = mObjLastAuction.Folio;

                    lObjPayment.UserFields.Fields.Item("U_GLO_CostCenter").Value = mObjLastAuction.Location;

                    lObjPayment.Remarks = mObjLastAuction.Folio;



                    int    intError = lObjPayment.Add();
                    string lStrErrMsg;
                    if (intError != 0)
                    {
                        DIApplication.Company.GetLastError(out intError, out lStrErrMsg);
                        LogUtility.WriteError(String.Format("[CheckGeneration - GeneratePayments] Error generando cheque para {0}: {1}", lObjSeller.CardName, lStrErrMsg));
                        throw new Exception(String.Format("Error generando cheque para {0}: {1}", lObjSeller.CardName, lStrErrMsg));

                        /*lBolSuccess = false;
                         * break;*/
                    }
                    else
                    {
                        int lIntDocEntry = int.Parse(DIApplication.Company.GetNewObjectKey());
                        LogUtility.WriteError(String.Format("[CheckGeneration - GeneratePayments] Pago generado correctamente con DocEntry {0} para el cliente {1}", lIntDocEntry, lObjSeller.CardName));
                    }
                }
            }
            catch (Exception e)
            {
                LogUtility.WriteError(string.Format("[CheckGeneration - GeneratePayments] Error al crear el pago: {0}", e.Message));
                throw new Exception(string.Format("Error al crear el pago: {0}", e.Message));
                //lBolSuccess = false;
            }
            if (lBolSuccess)
            {
                mAuctionDAO.AutorizeAuction(mObjLastAuction.Folio, 'Y');
                UIApplication.ShowMessageBox("Pagos generados exitosamente.");
                mBolGenerated = true;
                DIApplication.Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                LogUtility.WriteSuccess("[CheckGeneration - GeneratePayments] Pagos generados exitosamente");
            }
            else
            {
                //DIApplication.Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                UIApplication.ShowMessageBox("Ocurrio un error generando cheques.");
            }
            ValidateFields();
        }