コード例 #1
0
ファイル: PolicyBL.cs プロジェクト: NelsonAyala0580/Projects
        public Response CreateCustomerClass(string line_of_business, string policy_type, string vehicle_type, string zone,
                                            string country, string channel, string supervisor, int supervisor_code, string custclass, string GpProductID)
        {
            RMCustomerClass rmcustclass = new RMCustomerClass();
            AccountBuilder  aBuilder    = new AccountBuilder();
            Response        response;
            Customers       custom = new Customers();

            string taxid      = ConfigKey.ReadSetting("TAXID");
            string accountREC = ConfigKey.ReadSetting("IDREC");
            string company    = ConfigKey.ReadSetting("Company");

            try
            {
                rmcustclass.CLASSID             = custclass;
                rmcustclass.CLASDSCR            = custclass;
                rmcustclass.CRLMTTYP            = 1;
                rmcustclass.TAXSCHID            = taxid;
                rmcustclass.STMTCYCL            = 5;
                rmcustclass.CUSTPRIORITY        = 1;
                rmcustclass.ORDERFULFILLDEFAULT = 1;
                rmcustclass.ACCTRECACCT         = aBuilder.BuildARAccount(Convert.ToInt32(accountREC), line_of_business, policy_type, vehicle_type, country, channel, supervisor, supervisor_code, GpProductID);

                response = custom.CreateCustomerClass(rmcustclass, company);
                return(response);
            }
            catch (Exception ex)
            {
                log.LogExeption("Ocurrió un error: ", 2, ex);
                throw;
            }
        }
コード例 #2
0
        public Response VoidTransaction(RMVoidTransaction rmvoidtran, string company)
        {
            Response response;
            string   server         = ConfigKey.ReadSetting("SERVER");
            string   transactionXML = string.Empty;
            string   CNX            = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var      eConnect       = new eConnectRequest();
            RMVoidTransactionType rmvoidtransaction = new RMVoidTransactionType();

            try
            {
                rmvoidtransaction.taRMVoidTransaction = SetVoidValues(rmvoidtran);
                transactionXML = SerializeRMVoid(rmvoidtransaction);
                response       = eConnect.CreateGPTransaction(CNX, transactionXML);
                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
                //throw;
            }
        }
コード例 #3
0
        public Response SalesPresonCreate(RMSalesPerson salesperson, string company)
        {
            var    response = new Response();
            string SalesPersonXML;
            string server   = ConfigKey.ReadSetting("SERVER");
            string CNX      = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var    eConnect = new eConnectRequest();

            taCreateSalesperson rmSalesPerson;

            try
            {
                rmSalesPerson  = SetSalesPersonValues(salesperson);
                SalesPersonXML = SerializeSalesPerson(rmSalesPerson);
                response       = eConnect.CreateGPMaster(CNX, SalesPersonXML);

                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vendor"></param>
        /// <param name="company"></param>
        /// <returns></returns>
        public Response VendorCreateUpdate(PMVendor vendor, string company)
        {
            var    response = new Response();
            string VendorXML;
            string server = ConfigKey.ReadSetting("SERVER");
            //var server = Properties.Settings.Default.SERVER.ToString();
            string CNX      = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var    eConnect = new eConnectRequest();
            taUpdateCreateVendorRcd pmVendorCreateUpdate;

            try
            {
                pmVendorCreateUpdate = SetVendorValues(vendor);
                VendorXML            = SerializeVendor(pmVendorCreateUpdate);
                response             = eConnect.CreateGPMaster(CNX, VendorXML);
                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
        }
コード例 #5
0
        public Response CustomerClassCreate(RMCustomerClass customerClass, string company)
        {
            var    response = new Response();
            string CustomerCLassXML;
            string server   = ConfigKey.ReadSetting("SERVER");
            string CNX      = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var    eConnect = new eConnectRequest();
            taCreateCustomerClass rmCustomerClass;

            try
            {
                rmCustomerClass  = SetCustomerClassValues(customerClass);
                CustomerCLassXML = SerializeCustomerClass(rmCustomerClass);
                response         = eConnect.CreateGPMaster(CNX, CustomerCLassXML);

                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
        }
コード例 #6
0
        /// <summary>
        /// Create RM transaction
        /// <param name="transaction">Header of RM transaction</param>
        /// <param name="Distribution">Distribution Account of RM Transaction</param>
        /// <param name="Taxes">Taxes of RM transaction</param>
        /// <param name="company">COMPANY SHORT NAME</param>
        /// <returns>Response Class</returns>
        /// </summary>
        // Log4NetMR.classClsRegistrarLog logW = new Log4NetMR.classClsRegistrarLog();
        public Response TransactionCreate(RMTransactionHeader transaction, RMTransactionDist[] Distribution, RMDocumentTaxes[] Taxes, string company)
        {
            Response          response;
            string            server         = ConfigKey.ReadSetting("SERVER");
            string            transactionXML = string.Empty;
            string            CNX            = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var               eConnect       = new eConnectRequest();
            RMTransactionType rmTranType     = new RMTransactionType();

            var getnext = new GetNextDocNumbers();

            getnext.RequireServiceProxy = false;

            try
            {
                string DOCNUMBR = string.Empty;

                if (string.IsNullOrEmpty(transaction.DOCNUMBR))
                {
                    DOCNUMBR = getnext.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMCreditMemo, CNX);
                }
                else
                {
                    DOCNUMBR = transaction.DOCNUMBR;
                }

                rmTranType.taRMTransaction = SetTransactionValues(transaction, DOCNUMBR);

                if (transaction.CREATEDIST == 0)
                {
                    rmTranType.taRMDistribution_Items = SetDistributionValues(Distribution, DOCNUMBR);
                }
                if (transaction.CreateTaxes == 1)
                {
                    rmTranType.taRMTransactionTaxInsert_Items = SetTaxValues(Taxes, DOCNUMBR);
                }

                transactionXML = SerializeRMTransaction(rmTranType);

                response = eConnect.CreateGPTransaction(CNX, transactionXML);
                return(response);
            }
            catch (Exception ex)
            {
                //logW.LogExeption("Econnect", 2, ex);
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
            finally
            {
                getnext.Dispose();
            }
        }
コード例 #7
0
        public Response TransactionCreate(GLTrasactionHeader Header, GLTransactionDetail[] Detail, string company)
        {
            Response response;
            string   transactionXML = string.Empty;
            //var server = Properties.Settings.Default.SERVER.ToString();
            string server = ConfigKey.ReadSetting("SERVER");
            string CNX    = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=True;packet size=4096";

            //string CNX = "data source=stsv-qa15;initial catalog=ELSIN;integrated security=SSPI;persist security info=True;packet size=4096";
            var eConnect = new eConnectRequest();
            GLTransactionType GLTranType = new GLTransactionType();
            var getnext = new GetNextDocNumbers();

            //getnext.RequireServiceProxy = false;
            try
            {
                int jrnEntry = Convert.ToInt32(getnext.GetNextGLJournalEntryNumber(IncrementDecrement.Increment, CNX));

                GLTranType.taGLTransactionHeaderInsert     = SetTransactionValues(Header, jrnEntry);
                GLTranType.taGLTransactionLineInsert_Items = SetDetailValues(Detail, jrnEntry);
                transactionXML = SerializeGLTransacion(GLTranType);

                response = eConnect.CreateGPTransaction(CNX, transactionXML);

                return(response);
            }
            catch (eConnectException ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                if (ex.InnerException != null)
                {
                    response.STACK += ex.InnerException.Message;
                }
                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                if (ex.InnerException != null)
                {
                    response.STACK += ex.InnerException.Message;
                }
                return(response);
            }
            finally
            {
                //getnext.Dispose();
            }
        }
コード例 #8
0
        public void ProcessNC()
        {
            var transactions = new InvoiceBL();
            var gpInvoice    = new GPServicesREF.SOP.Invoices();
            var rminvoice    = new GPServicesREF.RM.Receivables();
            List <TRANSACTION_INVOICE> transactionlist = transactions.GetTransactions();
            var company = ConfigKey.ReadSetting("Company");

            SYSFLEX_POLICY policyInfo;
            List <TRANSACTION_BY_COVERAGE> TransactionCoverage;

            try
            {
                log.WriteLog(0, "Total de Transacciones: " + transactionlist.Count.ToString());
                foreach (TRANSACTION_INVOICE policyTransaction in transactionlist)
                {
                    policyInfo          = transactions.GetPolicyInfo(policyTransaction.POLICY_NUMBER.Trim());
                    TransactionCoverage = transactions.GetCoverageDistribution(policyTransaction.POLICY_NUMBER.Trim(), policyTransaction.TRANSACTION_SEQUENCE.GetValueOrDefault());
                    var channel_no_comm = ConfigKey.ReadSetting("CHANNEL_NO_COMM");
                    //var arrChannelNoComm = String.Join(",", channel_no_comm.ToArray());


                    if (policyTransaction.TRANS_TYPE == "C")
                    {
                        RMTransactionHeader header;
                        RMTransactionDist[] distrib;
                        RMDocumentTaxes[]   taxes;
                        try
                        {
                            header = transactions.CreateRMHeader(policyInfo, policyTransaction, TransactionCoverage);


                            taxes   = transactions.CreateRMTax(policyInfo, policyTransaction, header, TransactionCoverage, false);
                            distrib = transactions.CreateRMDistribution(policyInfo, policyTransaction, TransactionCoverage, taxes, header);
                            //Generar partida normal

                            transactions.SaveRenewDistribution(policyInfo.INITAL_DATE.GetValueOrDefault(), policyTransaction, distrib);
                        }
                        catch (Exception ex)
                        {
                            log.LogExeption("Ocurrió un error: ", 2, ex);
                            // throw;
                        }
                    }
                }/////
                //transactions.UpdateCommission();
            }
            catch (Exception ex)
            {
                log.LogExeption("Ocurrió un error: ", 2, ex);
                throw;
            }
        }
コード例 #9
0
        public Response CustomerCreateUpdate(RMCustomer customer, RMParentID parent, List <RMParentIDChild> children, string company)
        {
            var response = new Response();

            string CustomerXML;
            string server = ConfigKey.ReadSetting("SERVER");
            //var server = Properties.Settings.Default.SERVER.ToString();
            string CNX      = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var    eConnect = new eConnectRequest();

            taUpdateCreateCustomerRcd rmCustomerCreateUpdate;
            taCreateParentID          rmparent;

            taParentIDChild_ItemsTaParentIDChild[] rmchildren;

            try
            {
                rmCustomerCreateUpdate = SetCustomerValues(customer);

                if (children.Count > 0)
                {
                    rmchildren  = SetParentChildValues(children);
                    CustomerXML = SerializeCustomerChild(rmCustomerCreateUpdate, rmchildren);
                }
                else if (children.Count == 0 && !string.IsNullOrEmpty(parent.CPRCSTNM))
                {
                    rmparent    = SetParentValues(parent);
                    CustomerXML = SerializeCustomerParent(rmCustomerCreateUpdate, rmparent);
                }
                else
                {
                    CustomerXML = SerializeCustomer(rmCustomerCreateUpdate);
                }

                //CustomerXML = SerializeCustomer(rmCustomerCreateUpdate, rmparent, rmchildren);
                response = eConnect.CreateGPMaster(CNX, CustomerXML);

                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
        }
コード例 #10
0
        /// <summary>
        /// Create PM transaction
        /// </summary>
        /// <param name="transaction">Header of PM transaction</param>
        /// <param name="Distribution">Distribution Account of PM Transaction</param>
        /// <param name="Taxes">Taxes of PM transaction</param>
        /// <param name="company">COMPANY SHORT NAME</param>
        /// <returns>Response Class</returns>
        public Response TransactionCreate(PMTransactionHeader transaction, PMTransactionDist[] Distribution, PMTransactionTax[] Taxes, string company)
        {
            Response response;
            string   server         = ConfigKey.ReadSetting("SERVER");
            string   transactionXML = string.Empty;
            //var server = Properties.Settings.Default.SERVER.ToString();
            string            CNX        = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var               eConnect   = new eConnectRequest();
            PMTransactionType pmTranType = new PMTransactionType();

            var getnext = new GetNextDocNumbers();

            getnext.RequireServiceProxy = false;

            try
            {
                string VCHRNUMBER = getnext.GetPMNextVoucherNumber(IncrementDecrement.Increment, CNX);
                pmTranType.taPMTransactionInsert = SetTransactionValues(transaction, VCHRNUMBER);

                if (transaction.CREATEDIST == 0)
                {
                    pmTranType.taPMDistribution_Items = SetDistributionValues(Distribution, VCHRNUMBER);
                }
                if (transaction.CreateTaxes == 1)
                {
                    pmTranType.taPMTransactionTaxInsert_Items = SetTaxValues(Taxes, VCHRNUMBER);
                }

                transactionXML = SerializePMTransaction(pmTranType);

                response = eConnect.CreateGPTransaction(CNX, transactionXML);
                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace; //+ " Inner Exception: " + ex.InnerException.Message;
                return(response);
            }
            finally
            {
                getnext.Dispose();
            }
        }
コード例 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Cashreceipt"></param>
        /// <param name="Distribution"></param>
        /// <param name="company"></param>
        /// <returns></returns>
        public Response CashReceiptCreate(RMCashReceipt Cashreceipt, RMTransactionDist[] Distribution, string company)
        {
            Response           response;
            string             server            = ConfigKey.ReadSetting("SERVER");
            string             transactionXML    = string.Empty;
            string             CNX               = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var                eConnect          = new eConnectRequest();
            RMCashReceiptsType rmcashreceipttype = new RMCashReceiptsType();

            var getnext = new GetNextDocNumbers();

            getnext.RequireServiceProxy = false;

            try
            {
                string DOCNUMBR = string.Empty;
                DOCNUMBR = getnext.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMPayments, CNX);

                rmcashreceipttype.taRMCashReceiptInsert = SetReceiptValues(Cashreceipt, DOCNUMBR);

                if (Cashreceipt.CREATEDIST == 0)
                {
                    rmcashreceipttype.taRMDistribution_Items = SetPaymentDistributionValues(Distribution, DOCNUMBR);
                }

                transactionXML    = SerializeRMCashReceipts(rmcashreceipttype);
                response          = eConnect.CreateGPTransaction(CNX, transactionXML);
                response.DOCUMENT = DOCNUMBR.Trim();
                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
            finally
            {
                getnext.Dispose();
            }
        }
コード例 #12
0
        public Response TransactionCreate(SOPHeader header, List <SOPDetail> detail, List <SOPDistribution> distribution, List <SOPTax> taxes, List <SOPCommissions> commissions, SopType soptype, string company)
        {
            Response response;
            string   server         = ConfigKey.ReadSetting("SERVER");
            string   transactionXML = string.Empty;
            //var server = Properties.Settings.Default.SERVER.ToString();
            string CNX      = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var    eConnect = new eConnectRequest();

            SOPTransactionType sopTranType = new SOPTransactionType();
            var getnext = new GetNextDocNumbers();

            getnext.RequireServiceProxy = false;
            string INVOICENUMBER;

            try
            {
                if (header.SOPNUMBE == string.Empty)
                {
                    INVOICENUMBER = getnext.GetNextSOPNumber(IncrementDecrement.Increment, header.DOCID, soptype, CNX);
                }
                else
                {
                    INVOICENUMBER = header.SOPNUMBE;
                }


                sopTranType.taSopHdrIvcInsert           = SetHeaderValues(header, INVOICENUMBER);
                sopTranType.taSopLineIvcInsert_Items    = SetDetailValues(detail, INVOICENUMBER);
                sopTranType.taSopDistribution_Items     = SetDistributionValues(distribution, INVOICENUMBER);
                sopTranType.taSopLineIvcTaxInsert_Items = SetTaxValues(taxes, INVOICENUMBER);
                sopTranType.taSopCommissions_Items      = SetCommissionValues(commissions, INVOICENUMBER);

                transactionXML = SerializeSOPTransaction(sopTranType);
                response       = eConnect.CreateGPTransaction(CNX, transactionXML);

                return(response);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #13
0
        /// <summary>
        /// Procesar Customers
        /// </summary>
        public void Process()
        {
            var    customer      = new CustomerBL();
            string integrationid = ConfigKey.ReadSetting("INTEGRATIONID");
            List <SYSFLEX_CUSTOMER> customerlist = customer.GetCustomer();
            var company = ConfigKey.ReadSetting("Company");

            eConnectIntegration.CLASS.Response response;

            try
            {
                foreach (SYSFLEX_CUSTOMER cust in customerlist)
                {
                    try
                    {
                        log.escribirLog(0, "Sincronización de Cliente " + cust.CUSTNMBR);
                        var rmcustomer = new RMCustomer();

                        if (string.IsNullOrEmpty(cust.CUSTNAME))
                        {
                            cust.CUSTNAME = "";
                        }

                        if (string.IsNullOrEmpty(cust.SHRTNAME))
                        {
                            cust.SHRTNAME = "";
                        }

                        if (string.IsNullOrEmpty(cust.STMTNAME))
                        {
                            cust.STMTNAME = "";
                        }

                        if (string.IsNullOrEmpty(cust.CUSTCLAS))
                        {
                            cust.CUSTCLAS = "";
                        }

                        if (string.IsNullOrEmpty(cust.CNTCPRSN))
                        {
                            cust.CNTCPRSN = "";
                        }

                        if (string.IsNullOrEmpty(cust.ADDRESS1))
                        {
                            cust.ADDRESS1 = "";
                        }

                        if (string.IsNullOrEmpty(cust.CITY))
                        {
                            cust.CITY = "";
                        }

                        if (string.IsNullOrEmpty(cust.COUNTRY))
                        {
                            cust.COUNTRY = "";
                        }

                        if (string.IsNullOrEmpty(cust.PHNUMBR1))
                        {
                            cust.PHNUMBR1 = "";
                        }

                        if (string.IsNullOrEmpty(cust.PHNUMBR2))
                        {
                            cust.PHNUMBR2 = "";
                        }

                        if (string.IsNullOrEmpty(cust.PHNUMBR3))
                        {
                            cust.PHNUMBR3 = "";
                        }

                        if (string.IsNullOrEmpty(cust.fax))
                        {
                            cust.fax = "";
                        }

                        rmcustomer.CUSTNMBR = cust.CUSTNMBR.ToString();
                        //rmcustomer.HOLD = cust.HOLD.GetValueOrDefault();
                        rmcustomer.INACTIVE       = cust.INACTIVE.GetValueOrDefault();
                        rmcustomer.CUSTNAME       = cust.CUSTNAME.Trim() + " " + cust.SHRTNAME.Trim() + " " + cust.STMTNAME.Trim();
                        rmcustomer.SHRTNAME       = cust.CUSTNAME.Trim() + " " + cust.STMTNAME;
                        rmcustomer.STMTNAME       = cust.CUSTNAME.Trim() + " " + cust.STMTNAME;
                        rmcustomer.CUSTCLASS      = cust.CUSTCLAS;
                        rmcustomer.CNTCPRSN       = cust.CNTCPRSN;
                        rmcustomer.ADRSCODE       = "PRIMARY        ";
                        rmcustomer.ADDRESS1       = cust.ADDRESS1;
                        rmcustomer.ADDRESS2       = cust.ADDRESS2.GetValueOrDefault().ToString();
                        rmcustomer.ADDRESS3       = cust.ADDRESS3.GetValueOrDefault().ToString();
                        rmcustomer.CITY           = cust.CITY;
                        rmcustomer.COUNTRY        = cust.COUNTRY;
                        rmcustomer.PHNUMBR1       = cust.PHNUMBR1;
                        rmcustomer.PHNUMBR2       = cust.PHNUMBR2;
                        rmcustomer.PHNUMBR3       = cust.PHNUMBR3;
                        rmcustomer.FAX            = cust.fax;
                        rmcustomer.INTEGRATIONID  = integrationid;
                        rmcustomer.CreateAddress  = 1;
                        rmcustomer.UpdateIfExists = 1;

                        var rmparent = new RMParentID();
                        rmparent.CPRCSTNM        = cust.CUSTNMBR.ToString();
                        rmparent.UpdateIfExists  = 1;
                        rmparent.NAALLOWRECEIPTS = 1;

                        response = customer.CreateUpdateCustomer(rmcustomer, rmparent, company);

                        if (response.SUCCESS)
                        {
                            var customerupdate = new ST_CLIENT_TABLE_SYNC();
                            customerupdate.CUSTNMBR = rmcustomer.CUSTNMBR;
                            customer.Customer_UpdateLastUpdate(customerupdate);
                            log.escribirLog(0, response.MESSAGE);
                        }
                        else
                        {
                            log.escribirLog(1, response.MESSAGE);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.escribirLog(2, "Ocurrió un error con el customer " + cust.CUSTNMBR);
                        log.LogExeption("Detalle del error: ", 2, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                log.LogExeption("Ocurrió un error: ", 2, ex);
                //throw;
            }
        }
コード例 #14
0
        public void Process()
        {
            var transactions = new InvoiceBL();

            List <TRANSACTION_INVOICE> transactionlist = transactions.GetTransactions();
            var company = ConfigKey.ReadSetting("Company");

            SYSFLEX_POLICY policyInfo;
            List <TRANSACTION_BY_COVERAGE> TransactionCoverage;

            try
            {
                log.WriteLog(0, "Total de Transacciones: " + transactionlist.Count.ToString());
                foreach (TRANSACTION_INVOICE policyTransaction in transactionlist)
                {
                    policyInfo          = transactions.GetPolicyInfo(policyTransaction.POLICY_NUMBER.Trim());
                    TransactionCoverage = transactions.GetCoverageDistribution(policyTransaction.POLICY_NUMBER.Trim(), policyTransaction.TRANSACTION_SEQUENCE.GetValueOrDefault());
                    var channel_no_comm = ConfigKey.ReadSetting("CHANNEL_NO_COMM");
                    //var arrChannelNoComm = String.Join(",", channel_no_comm.ToArray());
                    if (policyTransaction.TRANS_TYPE == "D")
                    {
                        SOPHeader         header;
                        SOPDetail[]       detail;
                        SOPCommissions[]  commission;
                        SOPTax[]          taxes;
                        SOPDistribution[] distribution;
                        SOPDistribution[] distributionRenew;
                        Microsoft.Dynamics.GP.eConnect.SopType soptype;
                        try
                        {
                            header = transactions.CreateHeader(policyInfo, policyTransaction, TransactionCoverage);

                            if (header.SOPTYPE == 3)
                            {
                                soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPInvoice;
                            }
                            else if (header.SOPTYPE == 4)
                            {
                                soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPReturn;
                            }
                            else if (header.SOPTYPE == 1)
                            {
                                soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPQuote;
                            }
                            else if (header.SOPTYPE == 2)
                            {
                                soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPOrder;
                            }
                            else
                            {
                                soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPBackOrder;
                            }
                            if (policyTransaction.TRANS_DESC.Trim() == "RENOVACION" && (policyInfo.INITAL_DATE.GetValueOrDefault().Month > policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year >= policyTransaction.TRANS_DATE.GetValueOrDefault().Year))
                            {
                                detail = transactions.CreateUnitDetail(policyInfo, policyTransaction, TransactionCoverage, header);
                                taxes  = transactions.CreateUnitTax(policyInfo, policyTransaction, header, TransactionCoverage);

                                if (!channel_no_comm.Contains(policyInfo.CHANNEL.Trim()))
                                {
                                    commission = transactions.CreateCommissions(policyInfo, policyTransaction, header, detail, TransactionCoverage);
                                }
                                else
                                {
                                    commission = new List <SOPCommissions>().ToArray();
                                }

                                distribution = transactions.CreateUnitDistribution(policyInfo, policyTransaction, TransactionCoverage, detail, commission, taxes, header);
                            }
                            else
                            {
                                detail = transactions.CreateDetail(policyInfo, policyTransaction, TransactionCoverage, header);
                                taxes  = transactions.CreateTax(policyInfo, policyTransaction, header, TransactionCoverage);

                                if (!channel_no_comm.Contains(policyInfo.CHANNEL.Trim()))
                                {
                                    commission = transactions.CreateCommissions(policyInfo, policyTransaction, header, detail, TransactionCoverage);
                                }
                                else
                                {
                                    commission = new List <SOPCommissions>().ToArray();
                                }


                                distribution = transactions.CreateDistribution(policyInfo, policyTransaction, TransactionCoverage, detail, commission, taxes, header);
                            }
                            //commission = transactions.CreateCommissions(policyInfo, policyTransaction, header, detail, TransactionCoverage);
                            header.SUBTOTAL = detail.Sum(X => X.XTNDPRCE);
                            header.USINGHEADERLEVELTAXES = 1;
                            header.TAXAMNT  = taxes.Sum(x => x.STAXAMNT);
                            header.DOCAMNT  = header.SUBTOTAL.GetValueOrDefault() + header.TAXAMNT.GetValueOrDefault();
                            header.COMMAMNT = commission.Sum(x => x.COMMAMNT.GetValueOrDefault());
                            if (policyTransaction.TRANS_DESC.Trim() == "REHABILITACION DE POLIZA")
                            {
                                transactions.ChangeCustomerState(header.CUSTNMBR, 0);
                            }

                            ////Eliminar Reserva de Correlativo
                            transactions.DeleteReserve(header.SOPNUMBE);


                            ///Generar partida Normal y guardarla en temporal
                            var detailRenew = transactions.CreateDetail(policyInfo, policyTransaction, TransactionCoverage, header);
                            var taxesRenew  = transactions.CreateTax(policyInfo, policyTransaction, header, TransactionCoverage);
                            distributionRenew = transactions.CreateDistribution(policyInfo, policyTransaction, TransactionCoverage, detailRenew, commission, taxesRenew, header);
                            transactions.SaveRenewDistribution(policyInfo.INITAL_DATE.GetValueOrDefault(), policyTransaction, distributionRenew);
                        }
                        catch (Exception ex)
                        {
                            log.LogExeption("Ocurrió un error al generar el invoice para la poliza " + policyInfo.POLICY_NUMBER.Trim(), 2, ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.LogExeption("Ocurrió un error: ", 2, ex);
                throw;
            }
        }
コード例 #15
0
        public void Process()
        {
            var transactions = new InvoiceBL();

            transactions.InsertTransactionFromSysflex();
            var gpInvoice = new GPServicesREF.SOP.Invoices();
            var rminvoice = new GPServicesREF.RM.Receivables();
            List <TRANSACTION_INVOICE> transactionlist = transactions.GetTransactions();
            var      company = ConfigKey.ReadSetting("Company");
            Response response;

            SYSFLEX_POLICY policyInfo;
            List <TRANSACTION_BY_COVERAGE> TransactionCoverage;

            try
            {
                log.WriteLog(0, "Total de Transacciones: " + transactionlist.Count.ToString());
                foreach (TRANSACTION_INVOICE policyTransaction in transactionlist)
                {
                    policyInfo = transactions.GetPolicyInfo(policyTransaction.POLICY_NUMBER.Trim());
                    if (policyInfo == null)
                    {
                        /////Si la poliza se encuentra en estado "IN TRANSIT" pasa al siguiente item
                        continue;
                    }
                    else
                    {
                        TransactionCoverage = transactions.GetCoverageDistribution(policyTransaction.POLICY_NUMBER.Trim(), policyTransaction.TRANSACTION_SEQUENCE.GetValueOrDefault());
                        //var channel_no_comm = ConfigKey.ReadSetting("CHANNEL_NO_COMM");
                        //var arrChannelNoComm = String.Join(",", channel_no_comm.ToArray());
                        if (policyTransaction.TRANS_TYPE == "D")
                        {
                            SOPHeader         header;
                            SOPDetail[]       detail;
                            SOPCommissions[]  commission;
                            SOPTax[]          taxes;
                            SOPDistribution[] distribution;
                            SOPDistribution[] distributionRenew;
                            Microsoft.Dynamics.GP.eConnect.SopType soptype;
                            try
                            {
                                header = transactions.CreateHeader(policyInfo, policyTransaction, TransactionCoverage);

                                if (header.SOPTYPE == 3)
                                {
                                    soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPInvoice;
                                }
                                else if (header.SOPTYPE == 4)
                                {
                                    soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPReturn;
                                }
                                else if (header.SOPTYPE == 1)
                                {
                                    soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPQuote;
                                }
                                else if (header.SOPTYPE == 2)
                                {
                                    soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPOrder;
                                }
                                else
                                {
                                    soptype = Microsoft.Dynamics.GP.eConnect.SopType.SOPBackOrder;
                                }
                                //if (policyTransaction.TRANS_DESC.Trim() == "RENOVACION" && (policyInfo.INITAL_DATE.GetValueOrDefault().Month > policyTransaction.TRANS_DATE.GetValueOrDefault().Month && policyInfo.INITAL_DATE.GetValueOrDefault().Year >= policyTransaction.TRANS_DATE.GetValueOrDefault().Year))
                                if (policyTransaction.TRANS_DESC.Trim() == "RENOVACION" &&
                                    ((policyInfo.INITAL_DATE.GetValueOrDefault().Month > policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year == policyTransaction.TRANS_DATE.GetValueOrDefault().Year) ||
                                     (policyInfo.INITAL_DATE.GetValueOrDefault().Month <= policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year > policyTransaction.TRANS_DATE.GetValueOrDefault().Year)))
                                {
                                    detail = transactions.CreateUnitDetail(policyInfo, policyTransaction, TransactionCoverage, header);
                                    taxes  = transactions.CreateUnitTax(policyInfo, policyTransaction, header, TransactionCoverage);

                                    //if (!channel_no_comm.Contains(policyInfo.CHANNEL.Trim()))
                                    if (!transactions.ChannelNoComm(policyInfo.CHANNEL.Trim()))
                                    {
                                        commission = transactions.CreateCommissions(policyInfo, policyTransaction, header, detail, TransactionCoverage);
                                    }
                                    else
                                    {
                                        commission = new List <SOPCommissions>().ToArray();
                                    }

                                    distribution = transactions.CreateUnitDistribution(policyInfo, policyTransaction, TransactionCoverage, detail, commission, taxes, header);
                                }
                                else
                                {
                                    detail = transactions.CreateDetail(policyInfo, policyTransaction, TransactionCoverage, header);
                                    taxes  = transactions.CreateTax(policyInfo, policyTransaction, header, TransactionCoverage);

                                    //if (!channel_no_comm.Contains(policyInfo.CHANNEL.Trim()))
                                    if (!transactions.ChannelNoComm(policyInfo.CHANNEL.Trim()))
                                    {
                                        commission = transactions.CreateCommissions(policyInfo, policyTransaction, header, detail, TransactionCoverage);
                                    }
                                    else
                                    {
                                        commission = new List <SOPCommissions>().ToArray();
                                    }


                                    distribution = transactions.CreateDistribution(policyInfo, policyTransaction, TransactionCoverage, detail, commission, taxes, header);
                                }
                                //commission = transactions.CreateCommissions(policyInfo, policyTransaction, header, detail, TransactionCoverage);
                                header.SUBTOTAL = detail.Sum(X => X.XTNDPRCE);
                                header.USINGHEADERLEVELTAXES = 1;
                                header.TAXAMNT  = taxes.Sum(x => x.STAXAMNT);
                                header.DOCAMNT  = header.SUBTOTAL.GetValueOrDefault() + header.TAXAMNT.GetValueOrDefault();
                                header.COMMAMNT = commission.Sum(x => x.COMMAMNT.GetValueOrDefault());
                                if (policyTransaction.TRANS_DESC.Trim() == "REHABILITACION DE POLIZA")
                                {
                                    transactions.ChangeCustomerState(header.CUSTNMBR, 0);
                                }

                                ////Eliminar Reserva de Correlativo
                                transactions.DeleteReserve(header.SOPNUMBE);

                                response = gpInvoice.CreateInvoice(header, detail, distribution, commission, taxes, soptype, company);

                                if (response.SUCCESS)
                                {
                                    transactions.UpdateTransactionInvoce(header.SOPTYPE, "SOP", header.CUSTNMBR, policyTransaction.TRANSACTION_SEQUENCE.GetValueOrDefault());
                                    log.WriteLog(0, "Invoice Creado:" + response.MESSAGE);
                                    //if (policyTransaction.TRANS_DESC.Trim() == "RENOVACION" && (policyInfo.INITAL_DATE.GetValueOrDefault().Month > policyTransaction.TRANS_DATE.GetValueOrDefault().Month && policyInfo.INITAL_DATE.GetValueOrDefault().Year >= policyTransaction.TRANS_DATE.GetValueOrDefault().Year))
                                    if (policyTransaction.TRANS_DESC.Trim() == "RENOVACION" &&
                                        ((policyInfo.INITAL_DATE.GetValueOrDefault().Month > policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year == policyTransaction.TRANS_DATE.GetValueOrDefault().Year) ||
                                         (policyInfo.INITAL_DATE.GetValueOrDefault().Month <= policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year > policyTransaction.TRANS_DATE.GetValueOrDefault().Year)))
                                    {
                                        ///Generar partida Normal y guardarla en temporal
                                        var detailRenew = transactions.CreateDetail(policyInfo, policyTransaction, TransactionCoverage, header);
                                        var taxesRenew  = transactions.CreateTax(policyInfo, policyTransaction, header, TransactionCoverage);
                                        distributionRenew = transactions.CreateDistribution(policyInfo, policyTransaction, TransactionCoverage, detailRenew, commission, taxesRenew, header);
                                        transactions.SaveRenewDistribution(policyInfo.INITAL_DATE.GetValueOrDefault(), policyTransaction, distributionRenew);
                                    }
                                }
                                else
                                {
                                    log.WriteLog(2, "Ocurrió un error: " + response.MESSAGE);
                                    //log.escribirLog(2, header);
                                }
                            }
                            catch (Exception ex)
                            {
                                log.LogExeption("Ocurrió un error al generar el invoice para la poliza " + policyInfo.POLICY_NUMBER.Trim(), 2, ex);
                            }
                        }

                        if (policyTransaction.TRANS_TYPE == "C")
                        {
                            RMTransactionHeader header;
                            RMTransactionDist[] distrib;
                            RMDocumentTaxes[]   taxes;
                            try
                            {
                                header = transactions.CreateRMHeader(policyInfo, policyTransaction, TransactionCoverage);

                                if (((policyInfo.INITAL_DATE.GetValueOrDefault().Month > policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year == policyTransaction.TRANS_DATE.GetValueOrDefault().Year) ||
                                     (policyInfo.INITAL_DATE.GetValueOrDefault().Month <= policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year > policyTransaction.TRANS_DATE.GetValueOrDefault().Year)))
                                {
                                    taxes   = transactions.CreateRMTax(policyInfo, policyTransaction, header, TransactionCoverage, true);
                                    distrib = transactions.CreateRMUnitDistribution(policyInfo, policyTransaction, TransactionCoverage, taxes, header);
                                }
                                else
                                {
                                    taxes   = transactions.CreateRMTax(policyInfo, policyTransaction, header, TransactionCoverage, false);
                                    distrib = transactions.CreateRMDistribution(policyInfo, policyTransaction, TransactionCoverage, taxes, header);
                                }


                                response = rminvoice.CreateRMInvoice(header, distrib, taxes, company);

                                if (response.SUCCESS)
                                {
                                    transactions.UpdateTransactionInvoce(header.RMDTYPAL, "RM", header.CUSTNMBR, policyTransaction.TRANSACTION_SEQUENCE.GetValueOrDefault());
                                    log.WriteLog(0, "Invoice Creado:" + response.MESSAGE);

                                    if (((policyInfo.INITAL_DATE.GetValueOrDefault().Month > policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year == policyTransaction.TRANS_DATE.GetValueOrDefault().Year) ||
                                         (policyInfo.INITAL_DATE.GetValueOrDefault().Month <= policyTransaction.TRANS_DATE.GetValueOrDefault().Month&& policyInfo.INITAL_DATE.GetValueOrDefault().Year > policyTransaction.TRANS_DATE.GetValueOrDefault().Year)))
                                    {
                                        var taxesrenew   = transactions.CreateRMTax(policyInfo, policyTransaction, header, TransactionCoverage, false);
                                        var distribrenew = transactions.CreateRMDistribution(policyInfo, policyTransaction, TransactionCoverage, taxesrenew, header);
                                        transactions.SaveRenewDistribution(policyInfo.INITAL_DATE.GetValueOrDefault(), policyTransaction, distribrenew);
                                    }
                                }
                                else
                                {
                                    log.WriteLog(2, "Ocurrió un error: " + response.MESSAGE);
                                    //log.escribirLog(2, header);
                                }
                            }
                            catch (Exception ex)
                            {
                                log.LogExeption("Ocurrió un error: ", 2, ex);
                                // throw;
                            }
                        }
                    }
                }/////
                transactions.UpdateCommission();
            }
            catch (Exception ex)
            {
                log.LogExeption("Ocurrió un error: ", 2, ex);
                throw;
            }
        }
コード例 #16
0
        public void Process()
        {
            var policy = new PolicyBL();
            List <SYSFLEX_POLICY> policyList = policy.GetPolicy();
            string company       = ConfigKey.ReadSetting("Company");
            string integrationid = ConfigKey.ReadSetting("INTEGRATIONID");

            eConnectIntegration.CLASS.Response response;

            try
            {
                foreach (SYSFLEX_POLICY pol in policyList)
                {
                    log.WriteLog(0, "Inicia sincronización de Poliza: " + pol.POLICY_NUMBER.Trim());
                    var custAdd        = policy.SetCustomerAdditional(pol);
                    var syscustomer    = policy.GetPolicyParent(Convert.ToInt32(pol.CLIENT_ID));
                    var customerexists = policy.CheckCustomerExists(pol.POLICY_NUMBER, syscustomer.CUSTNMBR.ToString());
                    try
                    {
                        var custclass   = policy.GetCustomerClass(pol.LINE_OF_BUSINESS.Trim(), pol.POLICY_TYPE, pol.VEHICLE_TYPE, pol.ZONE, syscustomer.COUNTRY.Trim(), pol.CHANNEL, pol.SUPERVISOR, pol.GpProductID);
                        var classexists = policy.CheckCustomerClassExists(custclass);
                        if (!classexists)
                        {
                            response = policy.CreateCustomerClass(pol.LINE_OF_BUSINESS.Trim(),
                                                                  pol.POLICY_TYPE.Trim(),
                                                                  pol.VEHICLE_TYPE.Trim(),
                                                                  pol.ZONE.Trim(),
                                                                  syscustomer.COUNTRY.Trim(),
                                                                  pol.CHANNEL.Trim(),
                                                                  pol.SUPERVISOR.Trim(),
                                                                  pol.SUPERVISOR_CODE.GetValueOrDefault(), custclass, pol.GpProductID);

                            if (response.SUCCESS)
                            {
                                log.WriteLog(0, "Clase creada: " + custclass);
                            }
                            else
                            {
                                log.WriteLog(2, "Ocurrio un error al crear la clase: " + custclass + ". " + response.MESSAGE);
                            }
                        }
                        var gpcustomer = new RMClass.RMCustomer();

                        if (string.IsNullOrEmpty(syscustomer.CUSTNAME))
                        {
                            syscustomer.CUSTNAME = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.SHRTNAME))
                        {
                            syscustomer.SHRTNAME = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.STMTNAME))
                        {
                            syscustomer.STMTNAME = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.CNTCPRSN))
                        {
                            syscustomer.CNTCPRSN = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.ADDRESS1))
                        {
                            syscustomer.ADDRESS1 = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.CITY))
                        {
                            syscustomer.CITY = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.COUNTRY))
                        {
                            syscustomer.COUNTRY = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.PHNUMBR1))
                        {
                            syscustomer.PHNUMBR1 = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.PHNUMBR2))
                        {
                            syscustomer.PHNUMBR2 = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.PHNUMBR3))
                        {
                            syscustomer.PHNUMBR3 = "";
                        }

                        if (string.IsNullOrEmpty(syscustomer.fax))
                        {
                            syscustomer.fax = "";
                        }

                        gpcustomer.CUSTNMBR         = pol.POLICY_NUMBER;
                        gpcustomer.CUSTNAME         = syscustomer.CUSTNAME.Trim() + " " + syscustomer.SHRTNAME.Trim() + " " + syscustomer.STMTNAME.Trim();
                        gpcustomer.SHRTNAME         = syscustomer.CUSTNAME.Trim() + " " + syscustomer.STMTNAME;
                        gpcustomer.STMTNAME         = syscustomer.CUSTNAME.Trim() + " " + syscustomer.STMTNAME;
                        gpcustomer.CUSTCLASS        = custclass;
                        gpcustomer.CNTCPRSN         = syscustomer.CNTCPRSN;
                        gpcustomer.ADRSCODE         = "PRIMARY        ";
                        gpcustomer.ADDRESS1         = syscustomer.ADDRESS1;
                        gpcustomer.ADDRESS2         = syscustomer.ADDRESS2.GetValueOrDefault().ToString();
                        gpcustomer.ADDRESS3         = syscustomer.ADDRESS3.GetValueOrDefault().ToString();
                        gpcustomer.CITY             = syscustomer.CITY;
                        gpcustomer.COUNTRY          = syscustomer.COUNTRY;
                        gpcustomer.PHNUMBR1         = syscustomer.PHNUMBR1;
                        gpcustomer.PHNUMBR2         = syscustomer.PHNUMBR2;
                        gpcustomer.PHNUMBR3         = syscustomer.PHNUMBR3;
                        gpcustomer.FAX              = syscustomer.fax;
                        gpcustomer.INTEGRATIONID    = integrationid;
                        gpcustomer.CreateAddress    = 1;
                        gpcustomer.UpdateIfExists   = 1;
                        gpcustomer.UseCustomerClass = 1;
                        gpcustomer.SLPRSNID         = pol.AGENT_CODE.ToString();

                        var rmchildren = new RMParentIDChild();
                        List <RMParentIDChild> children = new List <RMParentIDChild>();
                        if (!customerexists)
                        {
                            rmchildren.CPRCSTNM = syscustomer.CUSTNMBR.ToString();
                            rmchildren.CUSTNMBR = pol.POLICY_NUMBER.Trim();
                            children.Add(rmchildren);
                        }


                        response = policy.CreateCustomer(gpcustomer, children.ToArray(), company);

                        if (response.SUCCESS)
                        {
                            log.WriteLog(0, "Poliza sincronizada correctamente: " + pol.POLICY_NUMBER.Trim());
                        }
                        else
                        {
                            log.WriteLog(2, "Ocurrió un error al sincronizar la póliza: " + pol.POLICY_NUMBER.Trim() + ". " + response.MESSAGE);
                        }
                        //log.escribirLog(0, "Finaliza la sincronización de Poliza: " + pol.POLICY_NUMBER.Trim());
                    }
                    catch (Exception ex)
                    {
                        log.LogExeption("Error al sincronizar la poliza: " + pol.POLICY_NUMBER.Trim(), 2, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                log.LogExeption("Ocurrió un error: ", 2, ex);
                ///throw;
            }
        }