示例#1
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Bank == null))
                {
                    IBank bankCasted = item.As <IBank>();
                    if ((bankCasted != null))
                    {
                        this._parent.Bank = bankCasted;
                        return;
                    }
                }
                if ((this._parent.ServiceSupplier == null))
                {
                    IServiceSupplier serviceSupplierCasted = item.As <IServiceSupplier>();
                    if ((serviceSupplierCasted != null))
                    {
                        this._parent.ServiceSupplier = serviceSupplierCasted;
                        return;
                    }
                }
                IBankStatement bankStatementsCasted = item.As <IBankStatement>();

                if ((bankStatementsCasted != null))
                {
                    this._parent.BankStatements.Add(bankStatementsCasted);
                }
            }
示例#2
0
        public BankStatement(IBankStatement lastBankStatement, IJournal journal, string journalEntryNumber, decimal exchangeRate)
            : base(journal, journalEntryNumber)
        {
            if (lastBankStatement != null)
            {
                Journal = lastBankStatement.Journal;

                TransactionDate = getNextWorkingDay(lastBankStatement.TransactionDate);
                if (TransactionDate > DateTime.Today)
                    throw new ApplicationException(
                        string.Format("Journal '{0}' is up-to-date: a Bank Statement for the last working day already exists.", Journal.JournalNumber));

                PrevBankStatement = lastBankStatement;
            }
        }
示例#3
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                if ((this._parent.Bank == item))
                {
                    this._parent.Bank = null;
                    return(true);
                }
                if ((this._parent.ServiceSupplier == item))
                {
                    this._parent.ServiceSupplier = null;
                    return(true);
                }
                IBankStatement bankStatementItem = item.As <IBankStatement>();

                if (((bankStatementItem != null) &&
                     this._parent.BankStatements.Remove(bankStatementItem)))
                {
                    return(true);
                }
                return(false);
            }
示例#4
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IPointOfSale pointOfSaleItem = item.As <IPointOfSale>();

                if (((pointOfSaleItem != null) &&
                     this._parent.PointOfSales.Remove(pointOfSaleItem)))
                {
                    return(true);
                }
                ICashier cashierItem = item.As <ICashier>();

                if (((cashierItem != null) &&
                     this._parent.Cashiers.Remove(cashierItem)))
                {
                    return(true);
                }
                if ((this._parent.MerchantAccount == item))
                {
                    this._parent.MerchantAccount = null;
                    return(true);
                }
                IBankStatement bankStatementItem = item.As <IBankStatement>();

                if (((bankStatementItem != null) &&
                     this._parent.BankStatements.Remove(bankStatementItem)))
                {
                    return(true);
                }
                IVendorShift vendorShiftItem = item.As <IVendorShift>();

                if (((vendorShiftItem != null) &&
                     this._parent.VendorShifts.Remove(vendorShiftItem)))
                {
                    return(true);
                }
                return(false);
            }
示例#5
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IBankStatement bankStatementItem = item.As <IBankStatement>();

                if (((bankStatementItem != null) &&
                     this._parent.BankStatements.Remove(bankStatementItem)))
                {
                    return(true);
                }
                if ((this._parent.MerchantAgreement == item))
                {
                    this._parent.MerchantAgreement = null;
                    return(true);
                }
                ITransactor transactorItem = item.As <ITransactor>();

                if (((transactorItem != null) &&
                     this._parent.Transactors.Remove(transactorItem)))
                {
                    return(true);
                }
                IVendor vendorItem = item.As <IVendor>();

                if (((vendorItem != null) &&
                     this._parent.Vendors.Remove(vendorItem)))
                {
                    return(true);
                }
                IVendorShift vendorShiftItem = item.As <IVendorShift>();

                if (((vendorShiftItem != null) &&
                     this._parent.VendorShifts.Remove(vendorShiftItem)))
                {
                    return(true);
                }
                return(false);
            }
示例#6
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IPointOfSale pointOfSalesCasted = item.As <IPointOfSale>();

                if ((pointOfSalesCasted != null))
                {
                    this._parent.PointOfSales.Add(pointOfSalesCasted);
                }
                ICashier cashiersCasted = item.As <ICashier>();

                if ((cashiersCasted != null))
                {
                    this._parent.Cashiers.Add(cashiersCasted);
                }
                if ((this._parent.MerchantAccount == null))
                {
                    IMerchantAccount merchantAccountCasted = item.As <IMerchantAccount>();
                    if ((merchantAccountCasted != null))
                    {
                        this._parent.MerchantAccount = merchantAccountCasted;
                        return;
                    }
                }
                IBankStatement bankStatementsCasted = item.As <IBankStatement>();

                if ((bankStatementsCasted != null))
                {
                    this._parent.BankStatements.Add(bankStatementsCasted);
                }
                IVendorShift vendorShiftsCasted = item.As <IVendorShift>();

                if ((vendorShiftsCasted != null))
                {
                    this._parent.VendorShifts.Add(vendorShiftsCasted);
                }
            }
示例#7
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IBankStatement bankStatementsCasted = item.As <IBankStatement>();

                if ((bankStatementsCasted != null))
                {
                    this._parent.BankStatements.Add(bankStatementsCasted);
                }
                if ((this._parent.MerchantAgreement == null))
                {
                    IMerchantAgreement merchantAgreementCasted = item.As <IMerchantAgreement>();
                    if ((merchantAgreementCasted != null))
                    {
                        this._parent.MerchantAgreement = merchantAgreementCasted;
                        return;
                    }
                }
                ITransactor transactorsCasted = item.As <ITransactor>();

                if ((transactorsCasted != null))
                {
                    this._parent.Transactors.Add(transactorsCasted);
                }
                IVendor vendorsCasted = item.As <IVendor>();

                if ((vendorsCasted != null))
                {
                    this._parent.Vendors.Add(vendorsCasted);
                }
                IVendorShift vendorShiftsCasted = item.As <IVendorShift>();

                if ((vendorShiftsCasted != null))
                {
                    this._parent.VendorShifts.Add(vendorShiftsCasted);
                }
            }
示例#8
0
        private static string importBankMovements(IDalSession session, IBankStatement bankStatement)
        {
            if (bankStatement.Lines.Count > 0)
                return "No Lines were imported because Lines already exist.";

            IList importedBankMovements =
                ImportedBankMovementMapper.GetImportedBankMovements(session, bankStatement.Journal, bankStatement.TransactionDate);

            IGLAccount depositGLAccount = null;
            IGLAccount withdrawalGLAccount = null;

            if (importedBankMovements.Count > 0)
            {
                string accountNumberPrefixes = GetAccountNumberPrefixes(session);

                foreach (IImportedBankMovement importedBankMovement in importedBankMovements)
                {
                    if (!importedBankMovement.MovementAmount.EqualCurrency(bankStatement.Journal.Currency))
                        throw new ApplicationException(
                            string.Format("Imported movement currency and Journal currency are different ('{0}' and '{1}' respectively).",
                                          importedBankMovement.MovementAmount.Underlying.ToCurrency, bankStatement.Journal.Currency));

                    IJournalEntryLine journalEntryLine = new JournalEntryLine();

                    string accountName = FindAccountName(importedBankMovement.Description, accountNumberPrefixes);
                    if (accountName != string.Empty)
                    {
                        ICustomerAccount giroAccount = AccountMapper.GetAccountByNumber(session, accountName) as ICustomerAccount;
                        if (giroAccount != null)
                            journalEntryLine.GiroAccount = giroAccount;

                        if (importedBankMovement.MovementAmount.IsGreaterThanZero)
                        {
                            if (depositGLAccount == null)
                                depositGLAccount = GLAccountMapper.GetDepositGLAccount(session);
                            journalEntryLine.GLAccount = depositGLAccount;
                        }
                        else if (importedBankMovement.MovementAmount.IsLessThanZero)
                        {
                            if (withdrawalGLAccount == null)
                                withdrawalGLAccount = GLAccountMapper.GetWithdrawalGLAccount(session);
                            journalEntryLine.GLAccount = withdrawalGLAccount;
                        }
                    }

                    journalEntryLine.Balance = importedBankMovement.MovementAmount.Negate();
                    journalEntryLine.OriginalDescription = importedBankMovement.Description.TrimEnd();
                    journalEntryLine.ImportedBankMovement = importedBankMovement;

                    bankStatement.Lines.AddJournalEntryLine(journalEntryLine);
                }

                return string.Format("Successfully imported {0} Line{1}.", bankStatement.Lines.Count, (bankStatement.Lines.Count > 1 ? "s" : ""));
            }

            return "Could not find Lines to import.";
        }
示例#9
0
        private static string importBankBalance(IDalSession session, IBankStatement bankStatement)
        {
            if (bankStatement.HasClosingBalance)
                return "Balance was not imported because it is already set.";
            else
            {
                IImportedBankBalance importedBankBalance =
                    ImportedBankBalanceMapper.GetImportedBankBalance(session, bankStatement.Journal, bankStatement.TransactionDate);

                if (importedBankBalance != null)
                {
                    if (!importedBankBalance.BookBalance.EqualCurrency(bankStatement.Journal.Currency))
                        throw new ApplicationException(
                            string.Format("Imported balance currency and Journal currency are different ('{0}' and '{1}' respectively).",
                                          importedBankBalance.BookBalance.Underlying.ToCurrency, bankStatement.Journal.Currency.Symbol));

                    bankStatement.ClosingBalance = importedBankBalance.BookBalance;
                    bankStatement.HasClosingBalance = true;
                    bankStatement.ImportedBankBalance = importedBankBalance;

                    return "Successfully imported Balance.";
                }
                else
                    return "Could not find Balance to import.";
            }
        }
示例#10
0
        private static void doBook(IDalSession session, IBankStatement bankStatement)
        {
            if (bankStatement.Status == JournalEntryStati.Booked)
                throw new ApplicationException("This Bank Statement has been already booked.");

            if (bankStatement.OpenAmount.IsNotZero)
                throw new ApplicationException(
                    string.Format("Cannot book Bank Statement because its Open Amount is different from zero ({0:#,##0.00}).",
                                  bankStatement.OpenAmount));

            if (bankStatement.TotalBalance.IsNotZero)
                throw new ApplicationException(
                    string.Format("Cannot book Bank Statement because its Total Balance (including Fixed Account) is different from zero ({0:#,##0.00}).",
                                  bankStatement.TotalBalance));

            foreach (IJournalEntryLine line in bankStatement.Lines)
                if (line.Status == JournalEntryLineStati.New)
                {
                    if (line.GLAccount == null)
                        throw new ApplicationException(string.Format("Bank Statement Line number {0} does not have a GL Account.", line.LineNumber));

                    if (!line.IsStorno)
                    {
                        if (line.GLAccount.RequiresGiroAccount && line.GiroAccount == null)
                            throw new ApplicationException(
                                string.Format("Bank Statement Line number {0} is required by its GL Account ('{1}') to have a non-empty Giro Account.",
                                              line.LineNumber, line.GLAccount.FullDescription));
                        else if (!line.GLAccount.RequiresGiroAccount && line.GiroAccount != null)
                            throw new ApplicationException(
                                string.Format("Bank Statement Line number {0} is prohibited by its GL Account ('{1}') to have a Giro Account.",
                                              line.LineNumber, line.GLAccount.FullDescription));
                    }
                }

            JournalEntryLinesAdapter.BookJournalEntry(session, bankStatement);
        }