Пример #1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L3PY_GBAfBP_1521 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3PY_GBAfBP_1521 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L3PY_GBAfBP_1521 functionReturn = new FR_L3PY_GBAfBP_1521();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Get_Booking_Accounts_for_Bill_Participants", ex);
            }
            return(functionReturn);
        }
Пример #2
0
        protected static FR_L3PY_GBAfBP_1521 Execute(DbConnection Connection, DbTransaction Transaction, P_L3PY_GBAfBP_1521 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3PY_GBAfBP_1521();

            #region Load customer's account (debtor) -- from BillRecepient_BPID

            var billHeader = new CL1_BIL.ORM_BIL_BillHeader();
            billHeader.Load(Connection, Transaction, Parameter.BillHeaderID);

            // Customer's BusinessParticipant ID
            Guid customerBPID = billHeader.BillRecipient_BuisnessParticipant_RefID;

            // Current tenant's BusinessParticipant ID
            var tenantBPID = CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query
            {
                IfTenant_Tenant_RefID = securityTicket.TenantID,
                IsDeleted             = false,
                Tenant_RefID          = securityTicket.TenantID
            }).Single().CMN_BPT_BusinessParticipantID;

            var customerAccParam = new CL3_BookingAccounts.Atomic.Retrieval.P_L3BA_GBAPBPAfBP_1717
            {
                FiscalYearID = Parameter.FiscalYearID,
                BusinessParticipantID_List = new Guid[] { customerBPID, tenantBPID }
            };

            var accountsAssignments = CL3_BookingAccounts.Atomic.Retrieval.cls_Get_BookingAccount_Purpose_BPAssignment_for_BPID_List.Invoke
                                          (Connection, Transaction, customerAccParam, securityTicket).Result;

            Guid customerBookingAccountID = accountsAssignments.Single(x => x.BusinessParticipant_RefID == customerBPID).BookingAccount_RefID;

            #endregion

            #region Find dunning fees applied to this bill

            var dunningProcessMemberBill = CL1_ACC_DUN.ORM_ACC_DUN_DunningProcess_MemberBill.Query.Search(Connection, Transaction,
                                                                                                          new CL1_ACC_DUN.ORM_ACC_DUN_DunningProcess_MemberBill.Query
            {
                BIL_BillHeader_RefID = Parameter.BillHeaderID,
                IsDeleted            = false,
                Tenant_RefID         = securityTicket.TenantID
            }).SingleOrDefault();

            decimal applicableProcessDunningFees = (dunningProcessMemberBill == null) ? 0.0M : dunningProcessMemberBill.ApplicableProcessDunningFees;

            #endregion

            #region Bind retrieved data to returning object

            var result = new L3PY_GBAfBP_1521();
            // bill
            result.Bill            = new L3PY_GBAfBP_1521a();
            result.Bill.CurrencyID = billHeader.Currency_RefID;
            result.Bill.TotalValue_with_DunningFees_BeforeTax     = billHeader.TotalValue_BeforeTax + applicableProcessDunningFees;
            result.Bill.TotalValuee_with_DunningFees_IncludingTax = billHeader.TotalValue_IncludingTax + applicableProcessDunningFees;
            // customer
            result.CustomerAccount = new L3PY_GBAfBP_1521b();
            result.CustomerAccount.BookingAccountID      = customerBookingAccountID;
            result.CustomerAccount.BusinessParticipantID = customerBPID;

            #endregion

            returnValue.Result = result;
            return(returnValue);

            #endregion UserCode
        }