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

            #region Check if the business participants already have booking account and skip creation for them.

            var checkParam = new CL3_BookingAccounts.Atomic.Retrieval.P_L3BA_GBAPBPAfBP_1717
            {
                FiscalYearID = Parameter.FiscalYearID,
                BusinessParticipantID_List = Parameter.BusinessParticipantIDs
            };

            var bpThatAlreadyHaveAccountArray = CL3_BookingAccounts.Atomic.Retrieval.cls_Get_BookingAccount_Purpose_BPAssignment_for_BPID_List.Invoke(
                Connection, Transaction, checkParam, securityTicket).Result.Select(x => x.BusinessParticipant_RefID);

            var bpItems = Parameter.BusinessParticipantIDs.Except(bpThatAlreadyHaveAccountArray);

            #endregion

            foreach (var BPID in bpItems)
            {
                var accBPAssignment = CL3_BookingAccounts.Utils.BookingAccountUtils.GetEmptyCustomerAccount();

                #region Business participant's data

                var customer = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction,
                                                                                     new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query
                {
                    Ext_BusinessParticipant_RefID = BPID,
                    IsDeleted    = false,
                    Tenant_RefID = securityTicket.TenantID
                }).Single();

                var businessParticipant = CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction,
                                                                                                   new CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query
                {
                    CMN_BPT_BusinessParticipantID = BPID,
                    IsDeleted    = false,
                    Tenant_RefID = securityTicket.TenantID
                }).Single();

                #endregion

                #region Create booking account

                var bookingAccount = new CL1_ACC_BOK.ORM_ACC_BOK_BookingAccount
                {
                    ACC_BOK_BookingAccountID = Guid.NewGuid(),
                    BookingAccountName       = businessParticipant.DisplayName, // TODO: just name or something else?
                    BookingAccountNumber     = customer.InternalCustomerNumber,
                    FiscalYear_RefID         = Parameter.FiscalYearID,
                    Creation_Timestamp       = DateTime.Now,
                    Tenant_RefID             = securityTicket.TenantID
                };
                bookingAccount.Save(Connection, Transaction);

                #endregion

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

                var accountAssignment = CL3_BookingAccounts.Utils.BookingAccountUtils.GetEmptyCustomerAccount();
                accountAssignment.ACC_BOK_BookingAccounts_Purpose_BP_AssignmentID = Guid.NewGuid();
                accountAssignment.BookingAccount_RefID      = bookingAccount.ACC_BOK_BookingAccountID;
                accountAssignment.BusinessParticipant_RefID = BPID;
                accountAssignment.Creation_Timestamp        = DateTime.Now;
                accountAssignment.Tenant_RefID = securityTicket.TenantID;

                accountAssignment.Save(Connection, Transaction);

                #endregion
            }

            returnValue.Result = true;
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_L5BL_GAPDfBH_1021 Execute(DbConnection Connection, DbTransaction Transaction, P_L5BL_GAPDfBH_1021 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5BL_GAPDfBH_1021();
            returnValue.Result = new L5BL_GAPDfBH_1021();

            #region Bill data

            var bill = CL1_BIL.ORM_BIL_BillHeader.Query.Search(Connection, Transaction,
                                                               new CL1_BIL.ORM_BIL_BillHeader.Query
            {
                BIL_BillHeaderID = Parameter.BillHeaderID,
                IsDeleted        = false,
                Tenant_RefID     = securityTicket.TenantID
            }).Single();

            var billPaymentCondition = CL1_ACC_PAY.ORM_ACC_PAY_Condition.Query.Search(Connection, Transaction,
                                                                                      new CL1_ACC_PAY.ORM_ACC_PAY_Condition.Query
            {
                ACC_PAY_ConditionID = bill.BillHeader_PaymentCondition_RefID,
                IsDeleted           = false,
                Tenant_RefID        = securityTicket.TenantID
            }).Single();

            returnValue.Result.Bill_PaymentDeadline = bill.DateOnBill.AddDays(billPaymentCondition.MaximumPaymentTreshold_InDays);
            returnValue.Result.Bill_TotalValue      = bill.TotalValue_IncludingTax;

            #endregion

            #region Payments data

            bool hasInstallmentPlan = CL1_BIL.ORM_BIL_BillHeader_2_InstallmentPlan.Query.Exists(Connection, Transaction,
                                                                                                new CL1_BIL.ORM_BIL_BillHeader_2_InstallmentPlan.Query
            {
                BIL_BillHeader_RefID = Parameter.BillHeaderID,
                IsDeleted            = false,
                Tenant_RefID         = securityTicket.TenantID
            });

            if (hasInstallmentPlan)
            {
                returnValue.Result.PaymentsWithInstallments =
                    cls_Get_Payments_with_Installments_for_BillHeader.Invoke(Connection, Transaction,
                                                                             new P_L5BL_GPwIfBH_1009 {
                    BillHeaderID = Parameter.BillHeaderID
                }, securityTicket).Result;
            }
            else
            {
                returnValue.Result.Payments =
                    cls_Get_Payments_for_BillHeader.Invoke(Connection, Transaction,
                                                           new P_L5BL_GPfBH_0926 {
                    BillHeaderID = Parameter.BillHeaderID
                }, securityTicket).Result;
            }

            #endregion

            #region Tenant's revenue booking accounts

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

            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 bookingAccountParam = new CL3_BookingAccounts.Atomic.Retrieval.P_L3BA_GBAPBPAfBP_1717
            {
                IsRevenueAccount           = true,
                FiscalYearID               = currentFiscalYearID,
                BusinessParticipantID_List = new Guid[] { tenantBPID }
            };

            returnValue.Result.BookingAccounts = CL3_BookingAccounts.Atomic.Retrieval.cls_Get_BookingAccount_Purpose_BPAssignment_for_BPID_List.Invoke(
                Connection, Transaction, bookingAccountParam, securityTicket).Result;

            #endregion

            return(returnValue);

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

            /*
             * 0. Get current fiscal year
             * 1. Get current's account business participant
             * 2. Get booking accounts for bill's revenue participant and debtor participant
             * 3. Find unpayed amount for bill
             * 4. Create accounting transaction with booking lines
             * 5. Create new bill header assigned payment entry and assign accunting transaction to installments
             * 6. Update dunning process if needed
             */

            #region 0. Load current fiscal year

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

            #endregion

            #region 1. Get current's account business participant

            Guid accountBPID = CL1_USR.ORM_USR_Account.Query.Search(Connection, Transaction,
                                                                    new CL1_USR.ORM_USR_Account.Query
            {
                USR_AccountID = securityTicket.AccountID,
                IsDeleted     = false,
                Tenant_RefID  = securityTicket.TenantID
            }).Single().BusinessParticipant_RefID;

            #endregion

            #region 2. Get booking accounts for bill's revenue participant and debtor participant

            var param = new CL3_Payments.Complex.Retrieval.P_L3PY_GBAfBP_1521
            {
                FiscalYearID = currentFiscalYearID,
                BillHeaderID = Parameter.BillHeaderID
            };

            var billDataWithBookingAccounts = CL3_Payments.Complex.Retrieval.cls_Get_Booking_Accounts_for_Bill_Participants.Invoke(Connection, Transaction, param, securityTicket).Result;

            #endregion

            #region 3. Find unpayed amount for bill

            var payedParam = new CL3_Payments.Atomic.Retrieval.P_L3PY_GPAfB_1312
            {
                BillHeaderID_List = new Guid[] { Parameter.BillHeaderID }
            };
            var payed = CL3_Payments.Atomic.Retrieval.cls_Get_Payed_Amount_for_Bills.Invoke(Connection, Transaction, payedParam, securityTicket).Result;

            decimal amountLeftToBePayed = billDataWithBookingAccounts.Bill.TotalValuee_with_DunningFees_IncludingTax - payed.Single(x => x.BillHeaderID == Parameter.BillHeaderID).TotalPayedValue;

            // check if amount left to be payed is zero or if the amount for the current payment is larger than amount that is left to pay and send error status
            if (Decimal.Compare(amountLeftToBePayed, Decimal.Zero) == 0)
            {
                throw new Exception("Amount left to be payed is zero.");
            }
            else if (Decimal.Compare((amountLeftToBePayed - Parameter.Amount), Decimal.Zero) < 0)
            {
                throw new Exception("Amount for the current payment is larger than amount that is left to pay for this bill");
            }

            #endregion

            #region 4. Create accounting transaction with booking lines

            var transactionParam = new CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315
            {
                AccountingTransactionTypeID = Guid.Empty,
                CurrencyID        = billDataWithBookingAccounts.Bill.CurrencyID,
                DateOfTransaction = Parameter.PaymentDate
            };

            var bookingLines = new List <CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a>();

            CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a bookingLine = null;

            #region Customer Account booking line

            bookingLine = new CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a();
            bookingLine.BookingAccountID = billDataWithBookingAccounts.CustomerAccount.BookingAccountID;
            // Debtor account: Arrived amount is booked with positive sign
            bookingLine.TransactionValue = Parameter.Amount;
            bookingLines.Add(bookingLine);

            #endregion

            Guid 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 bankAccountParam = new CL3_BookingAccounts.Atomic.Retrieval.P_L3BA_GBAPBPAfBP_1717
            {
                BusinessParticipantID_List = new Guid[] { tenantBPID },
                FiscalYearID  = currentFiscalYearID,
                IsBankAccount = true
            };
            var bankAccount = CL3_BookingAccounts.Atomic.Retrieval.cls_Get_BookingAccount_Purpose_BPAssignment_for_BPID_List.Invoke(
                Connection, Transaction, bankAccountParam, securityTicket).Result.SingleOrDefault();

            if (bankAccount != null)
            {
                #region Tenant's Bank Account booking line

                bookingLine = new CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a();
                bookingLine.BookingAccountID = bankAccount.BookingAccount_RefID;
                // On the tenants bank account the arrived amount is booked with negative sign
                bookingLine.TransactionValue = -1 * Parameter.Amount;
                bookingLines.Add(bookingLine);

                #endregion

                transactionParam.BookingLines = bookingLines.ToArray();

                Guid accountTransactionID = CL3_BookingAccounts.Complex.Manipulation.cls_Create_Accounting_Transaction_with_BookingLines.Invoke(
                    Connection, Transaction, transactionParam, securityTicket).Result;

                #endregion

                #region 5. Create new bill header assigned payment entry and assign accunting transaction to installments

                bool isFullyPaid = Decimal.Compare((amountLeftToBePayed - Parameter.Amount), Decimal.Zero) == 0;
                // if the whole bill is payed before -- stop
                if (Decimal.Compare(amountLeftToBePayed, Decimal.Zero) == 0)
                {
                    return(returnValue);
                }
                // if this transaction will pay the rest of the bill set flag on the bill
                else if (isFullyPaid)
                {
                    var billHeader = new CL1_BIL.ORM_BIL_BillHeader();
                    billHeader.Load(Connection, Transaction, Parameter.BillHeaderID);

                    billHeader.IsFullyPaid = true;
                    billHeader.Save(Connection, Transaction);
                }

                var assignParam = new P_L3PY_AATtB_1107
                {
                    AccountTransactionID = accountTransactionID,
                    AssignedAmount       = Parameter.Amount,
                    BillHeaderID         = Parameter.BillHeaderID,
                    PaymentDate          = Parameter.PaymentDate
                };

                cls_Assign_AccountingTransaction_to_Bill.Invoke(Connection, Transaction, assignParam, securityTicket);

                #region Load taxes and bill positions for taxes per position

                var billPositions = CL1_BIL.ORM_BIL_BillPosition.Query.Search(Connection, Transaction,
                                                                              new CL1_BIL.ORM_BIL_BillPosition.Query
                {
                    BIL_BilHeader_RefID = Parameter.BillHeaderID
                });

                Guid[] applicableTaxes = billPositions.Select(x => x.ApplicableSalesTax_RefID).Distinct().ToArray();

                var revenueAccountsParam = new CL3_BookingAccounts.Atomic.Retrieval.P_L3BA_GAfTaFY_1647
                {
                    FiscalYearID     = currentFiscalYearID,
                    TaxID            = applicableTaxes,
                    IsTaxAccount     = false,
                    IsRevenueAccount = true
                };

                var revenueAccountAssignments = CL3_BookingAccounts.Atomic.Retrieval.cls_Get_Assignment_for_TaxID_List_and_FiscalYearID.Invoke(
                    Connection, Transaction, revenueAccountsParam, securityTicket).Result;

                #endregion

                var balanceParam = new P_L3PY_CBCfAT_1329
                {
                    AccountingTransactionID = accountTransactionID,
                    BookingAccountID        = bankAccount.BookingAccount_RefID,
                    Amount = Parameter.Amount
                };
                cls_Create_BalanceChange_for_AccountingTransaction.Invoke(Connection, Transaction, balanceParam, securityTicket);

                #endregion

                #region 6. Update dunning process if needed

                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();


                if (dunningProcessMemberBill != null)
                {
                    dunningProcessMemberBill.CurrentUnpaidBillFraction = amountLeftToBePayed;
                    dunningProcessMemberBill.Save(Connection, Transaction);

                    var dunningProcess = CL1_ACC_DUN.ORM_ACC_DUN_DunningProcess.Query.Search(Connection, Transaction,
                                                                                             new CL1_ACC_DUN.ORM_ACC_DUN_DunningProcess.Query
                    {
                        ACC_DUN_DunningProcessID = dunningProcessMemberBill.ACC_DUN_DunningProcess_RefID,
                        IsDeleted    = false,
                        Tenant_RefID = securityTicket.TenantID
                    }).Single();

                    if (isFullyPaid)
                    {
                        dunningProcess.IsDunningProcessClosed      = true;
                        dunningProcess.DunningProcessClosedAt_Date = DateTime.Now;
                        dunningProcess.DunningProcessClosedBy_BusinessParticipnant_RefID = accountBPID;
                        dunningProcess.Save(Connection, Transaction);
                    }
                }
            }
            #endregion

            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3PY_CATfDF_0849 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();

            /*
             * 0. Load current fiscal year
             * 1. Find bill recepient and load his customer booking account
             * 2. Find tenant's "other income" booking account i.e. revenue account for tax that is 0%
             * 3. Create one transaction and multiple booking lines
             */

            #region 0. Load current fiscal year

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

            #endregion

            #region 1. Find bill recepient to load his customer booking account

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

            var cbaParam = new CL3_BookingAccounts.Atomic.Retrieval.P_L3BA_GBAPBPAfBP_1717
            {
                FiscalYearID               = currentFiscalYearID,
                IsCustomerAccount          = true,
                BusinessParticipantID_List = new Guid[] { billHeader.BillRecipient_BuisnessParticipant_RefID }
            };
            Guid customerBookingAccountID = CL3_BookingAccounts.Atomic.Retrieval.cls_Get_BookingAccount_Purpose_BPAssignment_for_BPID_List.Invoke(
                Connection, Transaction, cbaParam, securityTicket).Result.Single().BookingAccount_RefID;

            #endregion

            #region 2. Find tenant's "other incomes" booking account i.e. revenue account for tax that is 0%

            Guid 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 taxZero = CL1_ACC_TAX.ORM_ACC_TAX_Tax.Query.Search(Connection, Transaction,
                                                                   new CL1_ACC_TAX.ORM_ACC_TAX_Tax.Query
            {
                IsDeleted    = false,
                Tenant_RefID = securityTicket.TenantID
            }).SingleOrDefault(x => Double.Equals(x.TaxRate, 0.0d));

            if (taxZero == null)
            {
                return(returnValue);
            }

            var tbaParam = new CL3_BookingAccounts.Atomic.Retrieval.P_L3BA_GAfTaFY_1647
            {
                FiscalYearID     = currentFiscalYearID,
                IsRevenueAccount = true,
                IsTaxAccount     = false,
                TaxID            = new Guid[] { taxZero.ACC_TAX_TaxeID }
            };
            Guid otherIncomeAccountID = CL3_BookingAccounts.Atomic.Retrieval.cls_Get_Assignment_for_TaxID_List_and_FiscalYearID.Invoke(
                Connection, Transaction, tbaParam, securityTicket).Result.Single().ACC_BOK_BookingAccount_RefID;

            #endregion

            #region 3. Create one transaction and multiple booking lines

            var transactionParam = new CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315
            {
                AccountingTransactionTypeID = Guid.Empty,
                CurrencyID        = billHeader.Currency_RefID,
                DateOfTransaction = DateTime.Now
            };

            var bookingLines = new List <CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a>();
            CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a bookingLine = null;

            #region Booking line for customer account

            bookingLine = new CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a()
            {
                BookingAccountID = customerBookingAccountID,
                // Debtor account: Dunning fee is booked as receivable with negative sign
                TransactionValue = -1 * Parameter.DunningFee
            };
            bookingLines.Add(bookingLine);

            #endregion

            #region Booking line for tenant's "other income" account

            bookingLine = new CL3_BookingAccounts.Complex.Manipulation.P_L3BA_CATwBL_1315a
            {
                BookingAccountID = otherIncomeAccountID,
                // "Other income account" Dunning Fee is booked with positive sign
                TransactionValue = Parameter.DunningFee
            };
            bookingLines.Add(bookingLine);

            #endregion

            transactionParam.BookingLines = bookingLines.ToArray();

            Guid accountTransactionID = CL3_BookingAccounts.Complex.Manipulation.cls_Create_Accounting_Transaction_with_BookingLines.Invoke(
                Connection, Transaction, transactionParam, securityTicket).Result;

            #endregion

            returnValue.Result = accountTransactionID;

            return(returnValue);

            #endregion UserCode
        }