Exemplo 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
        }
Exemplo n.º 2
0
        protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L3BA_CBA_1141 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Bool();

            #region Bank account

            var bankAccount = new CL1_ACC_BNK.ORM_ACC_BNK_BankAccount
            {
                ACC_BNK_BankAccountID = Guid.NewGuid(),
                Bank_RefID            = Parameter.BankID,
                BankAccountType_RefID = Parameter.BankAccountTypeID,
                Currency_RefID        = Parameter.CurrencyID,
                IBAN                = Parameter.IBAN,
                IsValid             = true,
                AccountOpenedAtDate = Parameter.OpenedAtDate,
                Tenant_RefID        = securityTicket.TenantID
            };
            bankAccount.Save(Connection, Transaction);

            #endregion

            #region Booking account

            var bookingAccountParam = new P_L3BA_CBA_1305
            {
                FiscalYearID         = Parameter.FiscalYearID,
                BookingAccountName   = Parameter.BookingAccountName,
                BookingAccountNumber = Parameter.BookingAccountName
            };
            Guid bookingAccountID = cls_Create_Booking_Account.Invoke(Connection, Transaction, bookingAccountParam, securityTicket).Result;

            #endregion

            #region Create Account assignment to booking account as "Bank Account"

            var accountAssignment = CL3_BookingAccounts.Utils.BookingAccountUtils.GetEmptyBankAccount();
            accountAssignment.ACC_BOK_BookingAccounts_Purpose_BP_AssignmentID = Guid.NewGuid();
            accountAssignment.BookingAccount_RefID                 = bookingAccountID;
            accountAssignment.BusinessParticipant_RefID            = Parameter.BusinessParticipantID;
            accountAssignment.If_L3_AssetAccount_BankAccount_RefID = bankAccount.ACC_BNK_BankAccountID;
            accountAssignment.Tenant_RefID = securityTicket.TenantID;

            accountAssignment.Save(Connection, Transaction);

            #endregion

            returnValue.Result = true;
            return(returnValue);

            #endregion UserCode
        }
Exemplo n.º 3
0
 ///<summary>
 /// Ivokes the method with the given Connection, leaving it open if no exceptions occured
 ///<summary>
 public static FR_Bool Invoke(DbConnection Connection, P_L3BA_CBA_1141 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, null, null, Parameter, securityTicket));
 }
Exemplo n.º 4
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3BA_CBA_1141 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_Bank_Account", ex);
            }
            return(functionReturn);
        }