Example #1
0
        private string AttatchFile(string pStrFile)
        {
            int    lIntAttachement = 0;
            string lStrAttach      = string.Empty;
            string lStrAttachPath  = mObjPurchaseServiceFactory.GetPurchaseService().GetAttachPath();

            if (!string.IsNullOrEmpty(pStrFile))
            {
                if (!Directory.Exists(lStrAttachPath))
                {
                    if (SAPbouiCOM.Framework.Application.SBO_Application.MessageBox(string.Format("Carpeta {0} \n no accesible es posible que no pueda adjuntar el xml ¿Desea continuar?", lStrAttachPath), 2, "Si", "No", "") == 2)
                    {
                        return("");
                    }
                }
            }
            AttachmentDI lObjAttachmentDI = new AttachmentDI();

            lIntAttachement = lObjAttachmentDI.AttachFile(pStrFile);
            if (lIntAttachement > 0)
            {
                lStrAttach = lStrAttachPath + System.IO.Path.GetFileName(pStrFile);
            }
            else
            {
                LogService.WriteError("InvoiceDI (AttachDocument) " + DIApplication.Company.GetLastErrorDescription());
                UIApplication.ShowError(string.Format("InvoiceDI (AttachDocument) : {0}", DIApplication.Company.GetLastErrorDescription()));
            }
            return(lStrAttach);
        }
Example #2
0
        private void ChooseFromListAfterEvent(ItemEvent pObjValEvent)
        {
            try
            {
                if (pObjValEvent.Action_Success)
                {
                    SAPbouiCOM.IChooseFromListEvent lObjCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pObjValEvent;
                    if (lObjCFLEvento.SelectedObjects != null)
                    {
                        SAPbouiCOM.DataTable lObjDataTable = lObjCFLEvento.SelectedObjects;

                        if (lObjDataTable != null)
                        {
                            this.UIAPIRawForm.DataSources.UserDataSources.Item(lObjDataTable.UniqueID).ValueEx = System.Convert.ToString(lObjDataTable.GetValue(0, 0));

                            switch (lObjDataTable.UniqueID)
                            {
                            case "CFL_Area":
                                string lStrArea = lObjDataTable.GetValue(0, 0).ToString();
                                this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Area").ValueEx   = lStrArea;
                                this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Employ").ValueEx = "";
                                AddConditionChoseFromListEmployee(mObjCFLEmployee, mObjPurchasesServiceFactory.GetPurchaseService().GetDepartment(lStrArea));
                                break;

                            case "CFL_Employ":
                                this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Employ").ValueEx = lObjDataTable.GetValue(2, 0).ToString() + " " + lObjDataTable.GetValue(3, 0).ToString() + lObjDataTable.GetValue(1, 0).ToString();
                                mStrEmployeId = lObjDataTable.GetValue(0, 0).ToString();
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("frmSearchRefunds (ChooseFromListAfterEvent) " + ex.Message);
                LogService.WriteError(ex);
            }
        }
Example #3
0
        public IList <string> CreateDocument(List <PurchaseNote> pLstPurchaseNotes, Vouchers pObjVoucher, TypeEnum.Type pNoteType)
        {
            IList <string> lLstResult = new List <string>();

            try
            {
                string lStrDocEntry = string.Empty;
                SAPbobsCOM.JournalEntries lObjJournalEntryes = (SAPbobsCOM.JournalEntries)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries); //SAPbobsCOM.BoObjectTypes.oInvoices);
                lObjJournalEntryes.TransactionCode = "S/CF";
                lObjJournalEntryes.Memo            = "CND" + " " + pObjVoucher.Area;
                lObjJournalEntryes.ReferenceDate   = pObjVoucher.Date;
                if (pNoteType == TypeEnum.Type.Refund)
                {
                    lObjJournalEntryes.Reference = pObjVoucher.Folio;
                }
                else
                {
                    lObjJournalEntryes.Reference = pObjVoucher.CodeMov;
                }

                var pLstPurchaseNotesAffectable = pLstPurchaseNotes.GroupBy(x => x.Affectable).Select(x => new PurchaseNote()
                {
                    Affectable  = x.First().Affectable,
                    Area        = x.First().Area,
                    CostingCode = x.First().CostingCode,
                    Aux         = x.First().AuxAfectable,
                    AF          = x.First().AF,
                    CodeMov     = x.First().CodeMov,
                    CodeVoucher = x.First().CodeVoucher,
                    Amount      = x.Sum(y => y.Amount) //x.Select(y=> y.Amount).Sum().ToString(),
                }).ToList();

                string lStrAttachPath = mObjPurchaseServiceFactory.GetPurchaseService().GetAttachPath();
                foreach (PurchaseNote lObjNotes in pLstPurchaseNotes)
                {
                    int    lIntAttachement = 0;
                    string lStrAttach      = string.Empty;
                    if (!string.IsNullOrEmpty(lObjNotes.File))
                    {
                        AttachmentDI lObjAttachmentDI = new AttachmentDI();
                        lIntAttachement = lObjAttachmentDI.AttachFile(lObjNotes.File);
                        if (lIntAttachement > 0)
                        {
                            lStrAttach = lStrAttachPath + System.IO.Path.GetFileName(lObjNotes.File);
                        }
                        else
                        {
                            lStrAttach = lObjNotes.File;
                        }
                    }
                    lObjJournalEntryes.Lines.Credit       = 0; // Convert.ToDouble(lObjMovement.Credit);
                    lObjJournalEntryes.Lines.Debit        = lObjNotes.Amount;
                    lObjJournalEntryes.Lines.AccountCode  = lObjNotes.Account;
                    lObjJournalEntryes.Lines.ProjectCode  = lObjNotes.Project;
                    lObjJournalEntryes.Lines.CostingCode  = lObjNotes.Area;
                    lObjJournalEntryes.Lines.CostingCode2 = lObjNotes.AF;
                    lObjJournalEntryes.Lines.CostingCode3 = lObjNotes.AGL;
                    lObjJournalEntryes.Lines.CostingCode4 = lObjNotes.Line;
                    lObjJournalEntryes.Lines.Reference2   = lObjNotes.Folio;
                    lObjJournalEntryes.Lines.LineMemo     = lObjNotes.Provider;
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_Coments").Value  = lObjNotes.Coments;
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_File").Value     = lStrAttach;
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_TypeAux").Value  = "2";
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_Auxiliar").Value = lObjNotes.Aux;
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_CodeMov").Value  = string.IsNullOrEmpty(lObjNotes.CodeMov) ? pObjVoucher.Folio : lObjNotes.CodeMov;


                    if (!string.IsNullOrEmpty(lObjNotes.Aux))
                    {
                        lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_TypeAux").Value = "2";
                    }

                    lObjJournalEntryes.Lines.Add();
                }

                foreach (PurchaseNote lObjAffectable in pLstPurchaseNotesAffectable)
                {
                    lObjJournalEntryes.Lines.AccountCode  = lObjAffectable.Affectable;
                    lObjJournalEntryes.Lines.Credit       = lObjAffectable.Amount;
                    lObjJournalEntryes.Lines.Debit        = 0;
                    lObjJournalEntryes.Lines.CostingCode  = lObjAffectable.CostingCode;
                    lObjJournalEntryes.Lines.CostingCode2 = lObjAffectable.AF;
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_TypeAux").Value  = "2";
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_Auxiliar").Value = lObjAffectable.Aux;
                    lObjJournalEntryes.Lines.UserFields.Fields.Item("U_GLO_CodeMov").Value  = pNoteType == TypeEnum.Type.Refund ? pObjVoucher.Folio : lObjAffectable.CodeMov;

                    /*string.IsNullOrEmpty(lObjAffectable.CodeMov) ?
                     * lObjAffectable.CodeVoucher
                     * :lObjAffectable.CodeMov;*///lObjAffectable.CodeVoucher;
                }

                if (lObjJournalEntryes.Add() != 0)
                {
                    lLstResult.Add(string.Format("Mensaje: {0} ", DIApplication.Company.GetLastErrorDescription()));
                    LogService.WriteError("PolicyDI (CreateDocument)  Código de comprobante:" + pObjVoucher.RowCode + " Mensaje:" + DIApplication.Company.GetLastErrorDescription());
                }
                else
                {
                    LogService.WriteSuccess("Asiento creado correctamente: Código de comprobante:" + pObjVoucher.RowCode);
                    // AddVoucherDetail(pLstPurchaseNotes);
                }
                // var ss = pLstPurchaseNotes.GroupBy(x => x.Account, x => x.AF, x => x.Area);
            }
            catch (Exception ex)
            {
                LogService.WriteError("PolicyDI (CreateDocument) Código de comprobante:" + pObjVoucher.RowCode + " Mensaje:" + ex.Message);
                LogService.WriteError(ex);
                lLstResult.Add(ex.Message);
                // throw new Exception(ex.Message);
            }
            return(lLstResult);
        }
Example #4
0
        public void LoadPayment()
        {
            Form lObjPaymentForm    = null;
            Form lObjPaymentFormUDF = null;
            Form lObjAccountForm    = null;

            try
            {
                if (mIntRowSelected > 0)
                {
                    StatusEnum lEnmStatus  = (StatusEnum)int.Parse(DtMatrix.GetValue("C_Status", mIntRowSelected - 1).ToString());
                    string     lStrFolio   = DtMatrix.GetValue("C_Folio", mIntRowSelected - 1).ToString();
                    string     lStrEmpCode = DtMatrix.GetValue("C_EmpId", mIntRowSelected - 1).ToString();
                    string     lStrArea    = DtMatrix.GetValue("C_Area", mIntRowSelected - 1).ToString();
                    double     lDblImport  = double.Parse(DtMatrix.GetValue("C_SaldoPen", mIntRowSelected - 1).ToString());
                    lDblImport = lDblImport * -1;
                    string lStrEmpName     = mObjPurchasesServiceFactory.GetPurchaseService().GetEmpName(lStrEmpCode);
                    string lStrLineAccount = mObjPurchasesServiceFactory.GetPurchaseReceiptsService().GetAccountRefund(lStrArea);
                    //string lStrChkAcct = mObjPurchasesServiceFactory.GetPurchaseReceiptsService().GetAccountInConfig("GLO_CTAREEMBCHEQ");
                    string lStrChkAcct = cbAccount.Value;
                    // Dictionary<string, string> lStrBankInfo = mObjPurchasesServiceFactory.GetPurchaseReceiptsService().GetBankInfo(lStrChkAcct);
                    Dictionary <string, string> lStrBankInfo = new Dictionary <string, string>();
                    lStrBankInfo.Add(cbAccount.Value, cbBank.Selected.Description);

                    if (lEnmStatus != StatusEnum.Authorized_Ope_Admon)
                    {
                        UIApplication.ShowError("El reembolso seleccionado no está autorizado");
                        return;
                    }

                    string lStrValidation = ValidatePaymentsFields(lStrFolio, lStrEmpCode, lStrArea, lDblImport, lStrChkAcct, lStrBankInfo, lStrLineAccount);
                    if (!string.IsNullOrEmpty(lStrValidation))
                    {
                        UIApplication.ShowMessageBox(lStrValidation);
                        return;
                    }
                    if (mObjPurchasesServiceFactory.GetPurchaseReceiptsService().ExistsPayment(lStrEmpCode, lStrFolio, lStrArea))

                    /*string lStrDocEntry = DtMatrix.GetValue("C_DocEntry", mIntRowSelected - 1).ToString();
                     * if (mObjPurchasesServiceFactory.GetPurchaseReceiptsService().ExistsPayment(lStrDocEntry))*/
                    {
                        UIApplication.ShowError("Ya existe un pago para el reembolso seleccionado");
                        return;
                    }
                    this.UIAPIRawForm.Freeze(true);
                    UIApplication.GetApplication().ActivateMenuItem("2818");
                    if (!UIApplication.GetApplication().Menus.Item("6913").Checked)
                    {
                        UIApplication.GetApplication().ActivateMenuItem("6913");//2050
                    }

                    lObjPaymentForm    = UIApplication.GetApplication().Forms.GetForm("426", -1);
                    lObjPaymentFormUDF = UIApplication.GetApplication().Forms.GetForm("-426", -1);

                    lObjPaymentForm.Freeze(true);
                    lObjPaymentFormUDF.Freeze(true);
                    SAPbouiCOM.EditText txtDocDate = ((SAPbouiCOM.EditText)lObjPaymentForm.Items.Item("10").Specific);
                    txtDocDate.Value = DateTime.Now.ToString("yyyyMMdd");

                    SAPbouiCOM.OptionBtn optionBtnAccount = ((SAPbouiCOM.OptionBtn)lObjPaymentForm.Items.Item("58").Specific);
                    optionBtnAccount.Selected = true;

                    SAPbouiCOM.ComboBox cboPymtType = ((SAPbouiCOM.ComboBox)lObjPaymentFormUDF.Items.Item("U_GLO_PaymentType").Specific);
                    cboPymtType.Select("GLREG", SAPbouiCOM.BoSearchKey.psk_ByValue);

                    SAPbouiCOM.EditText txtCodeMov = ((SAPbouiCOM.EditText)lObjPaymentFormUDF.Items.Item("U_GLO_CodeMov").Specific);
                    txtCodeMov.Value = lStrFolio;

                    SAPbouiCOM.ComboBox txtCostCenter = ((SAPbouiCOM.ComboBox)lObjPaymentFormUDF.Items.Item("U_GLO_CostCenter").Specific);
                    txtCostCenter.Select(lStrArea, SAPbouiCOM.BoSearchKey.psk_ByValue);

                    SAPbouiCOM.ComboBox cboAuxiliarType = ((SAPbouiCOM.ComboBox)lObjPaymentFormUDF.Items.Item("U_FZ_AuxiliarType").Specific);
                    cboAuxiliarType.Select("2", SAPbouiCOM.BoSearchKey.psk_ByValue);

                    SAPbouiCOM.EditText txtName = ((SAPbouiCOM.EditText)lObjPaymentForm.Items.Item("10000166").Specific);
                    txtName.Value = lStrEmpName;

                    SAPbouiCOM.EditText txtAuxiliar = ((SAPbouiCOM.EditText)lObjPaymentFormUDF.Items.Item("U_FZ_Auxiliar").Specific);
                    txtAuxiliar.Value = lStrEmpCode;


                    SAPbouiCOM.Button btnBank = ((SAPbouiCOM.Button)lObjPaymentForm.Items.Item("234000001").Specific);
                    btnBank.Item.Click();

                    lObjAccountForm = UIApplication.GetApplication().Forms.GetForm("196", -1);
                    lObjAccountForm.Freeze(true);
                    SAPbouiCOM.Folder folderCheck = ((SAPbouiCOM.Folder)lObjAccountForm.Items.Item("3").Specific);
                    folderCheck.Item.Click();

                    SAPbouiCOM.Matrix mtxCheck = ((SAPbouiCOM.Matrix)lObjAccountForm.Items.Item("28").Specific);
                    ((SAPbouiCOM.EditText)mtxCheck.Columns.Item("7").Cells.Item(1).Specific).Value = lDblImport.ToString();

                    ComboBox cb = ((SAPbouiCOM.ComboBox)mtxCheck.Columns.Item("2").Cells.Item(1).Specific);

                    string ss = lStrBankInfo[lStrBankInfo.Keys.ElementAt(0)]; //lStrBankInfo.ElementAt(0);


                    ((SAPbouiCOM.ComboBox)mtxCheck.Columns.Item("2").Cells.Item(1).Specific).Select(lStrBankInfo[lStrBankInfo.Keys.ElementAt(0)], SAPbouiCOM.BoSearchKey.psk_ByValue); //Banco
                    ((SAPbouiCOM.ComboBox)mtxCheck.Columns.Item("4").Cells.Item(1).Specific).Select(lStrBankInfo.Keys.ElementAt(0), SAPbouiCOM.BoSearchKey.psk_ByValue);               //Cuenta?

                    SAPbouiCOM.Button btnOk = ((SAPbouiCOM.Button)lObjAccountForm.Items.Item("1").Specific);
                    btnOk.Item.Click();

                    SAPbouiCOM.Matrix mtxPayment = ((SAPbouiCOM.Matrix)lObjPaymentForm.Items.Item("71").Specific);
                    mtxPayment.AddRow();
                    ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("5").Cells.Item(1).Specific).Value = lDblImport.ToString();
                    ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("8").Cells.Item(1).Specific).Value = lStrLineAccount; //cuenta de mayor
                }
                else
                {
                    UIApplication.ShowMessageBox("Favor de seleccionar un registro");
                }



                lObjPaymentFormUDF.Freeze(false);
                this.UIAPIRawForm.Freeze(false);



                if (lObjPaymentForm != null)
                {
                    lObjPaymentForm.Freeze(false);
                }
                if (lObjAccountForm != null)
                {
                    lObjPaymentFormUDF.Freeze(false);
                }
                if (this.UIAPIRawForm != null)
                {
                    this.UIAPIRawForm.Freeze(false);
                }
                // if (lObjAccountForm. ==) lObjAccountForm.Freeze(false);
                UIApplication.ShowSuccess("Carga de pago terminada");
            }
            catch (Exception ex)
            {
                LogService.WriteError("frmSearchRefunds (btnPayments_ClickBefore) " + ex.Message);
                LogService.WriteError(ex);
                UIApplication.ShowMessageBox(string.Format("Error al abrir pantalla de pagos: {0}", ex.Message));
            }
            finally
            {
                if (lObjPaymentFormUDF != null)
                {
                    lObjPaymentFormUDF.Freeze(false);
                }
                this.UIAPIRawForm.Freeze(false);
            }
        }