Esempio n. 1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3BA_CBAfFY_1249 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            Guid currentFiscalYearID = Parameter.ACC_FiscalYearID;

            #region Get current fiscal year if none is given by the parameter

            if (currentFiscalYearID == Guid.Empty)
            {
                currentFiscalYearID = CL2_FiscalYear.Complex.Retrieval.cls_Get_Current_FiscalYear.Invoke(Connection, Transaction, securityTicket).Result.ACC_FiscalYearID;
            }

            #endregion

            #region Get tenant's business participant ID

            var tenantBusinessParticipantID = CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new
                                                                                                       CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query
            {
                IsDeleted             = false,
                IsTenant              = true,
                IfTenant_Tenant_RefID = securityTicket.TenantID
            }).Single().CMN_BPT_BusinessParticipantID;

            #endregion

            #region Create VAT accounts (made for each tax)

            var taxParam = new P_L3BA_CTBAfFY_1530
            {
                BusinessParticipantID = tenantBusinessParticipantID,
                FiscalYearID          = currentFiscalYearID
            };

            cls_Create_Tax_Booking_Accounts_for_FiscalYear.Invoke(Connection, Transaction, taxParam, securityTicket);

            #endregion

            #region Create customer accounts for each business participant that is the customer

            var customerBPIDs = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction,
                                                                                      new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query
            {
                IsDeleted    = false,
                Tenant_RefID = securityTicket.TenantID
            }).Select(x => x.Ext_BusinessParticipant_RefID);

            if (customerBPIDs.Count() > 0)
            {
                var customerAccParam = new P_L3BA_CCAfBP_1655
                {
                    FiscalYearID           = currentFiscalYearID,
                    BusinessParticipantIDs = customerBPIDs.ToArray()
                };
                cls_Create_Customer_Account_for_BusinessParticipants.Invoke(Connection, Transaction, customerAccParam, securityTicket);
            }

            #endregion

            #region Create revenue account for business participant that is the current tenant

            var revAccParam = new P_L3BA_CRAfT_0903
            {
                FiscalYearID = currentFiscalYearID
            };

            cls_Create_Revenue_Account_for_TenantID.Invoke(Connection, Transaction, revAccParam, securityTicket);

            #endregion

            #region Create bank account for business participant that is the current tenant

            var tenantBP = CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction,
                                                                                    new CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query
            {
                IsTenant = true,
                IfTenant_Tenant_RefID = securityTicket.TenantID,
                Tenant_RefID          = securityTicket.TenantID
            }).Single();

            var bnkAccParam = new P_L3BA_CBA_1141
            {
                FiscalYearID          = currentFiscalYearID,
                BusinessParticipantID = tenantBP.CMN_BPT_BusinessParticipantID,
                BookingAccountName    = tenantBP.DisplayName
            };

            cls_Create_Bank_Account.Invoke(Connection, Transaction, bnkAccParam, securityTicket);

            #endregion

            return(returnValue);

            #endregion UserCode
        }
Esempio n. 2
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3BA_CTBAfFY_1530 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Bool functionReturn = new FR_Bool();

            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_Create_Tax_Booking_Accounts_for_FiscalYear", ex);
            }
            return(functionReturn);
        }
Esempio n. 3
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Bool Invoke(string ConnectionString, P_L3BA_CTBAfFY_1530 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }
Esempio n. 4
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, P_L3BA_CTBAfFY_1530 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Esempio n. 5
0
        protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L3BA_CTBAfFY_1530 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Bool();

            #region Retrieve all valid taxes

            var taxQuery = new CL1_ACC_TAX.ORM_ACC_TAX_Tax.Query
            {
                IsDeleted    = false,
                Tenant_RefID = securityTicket.TenantID
            };
            var taxes = CL1_ACC_TAX.ORM_ACC_TAX_Tax.Query.Search(Connection, Transaction, taxQuery).Select(x => x.ACC_TAX_TaxeID).ToArray();

            #endregion

            #region Create tax booking account for retrieved taxes

            var taxParam = new P_L3BA_CTBAfT_1519
            {
                BusinessParticipantID = Parameter.BusinessParticipantID,
                FiscalYearID          = Parameter.FiscalYearID,
                TaxIDs = taxes
            };

            cls_Create_Tax_Booking_Accounts_for_Taxes.Invoke(Connection, Transaction, taxParam, securityTicket);

            #endregion

            return(returnValue);

            #endregion UserCode
        }