Пример #1
0
        /// <summary>
        /// Kassenabschluss durchführen
        /// </summary>
        /// <param name="btn">sendender Button</param>
        private void submitCashClosure(Button btn)
        {
            MessageBoxResult result = MessageBoxEnhanced.Warning(IniParser.GetSetting("ACCOUNTING", "cashClosureWarning"));
            if (result == MessageBoxResult.No)
                return;

            string comment = tbComment.Text;

            int cashClosureID = -1;
            int cashClosureReportID = -1;
            int cashClosureReceiptID = -1;
            CashClosureHelper cashClosureHelper = new CashClosureHelper();

            try
            {
                // Lege CashClosure, CashClosureReport und CashClosureReceipt an
                cashClosureID = CashClosure.Add(UserSession.userAccountID, DateTime.Now, this.revenuesTotal, this.expensesTotal, comment);
                cashClosureReportID = CashClosureReport.Add(cashClosureID, false, null, false, null, null, null);
                cashClosureReceiptID = CashClosureReceipt.Add(cashClosureID, false, null, null);

                // Setze für Kassenabschluss-Konten NewBalance als LatestBalance
                foreach (var accModel in this.accountModels)
                {
                    double latestBalance = accModel.newBalanceDOUBLE;
                    Account.Update(accModel.account.AccountID, accModel.account.Name, accModel.account.Number, accModel.account.ZeroPeriodEnum, accModel.account.IsOfficial, accModel.account.Description, latestBalance, accModel.account.IsCapital, accModel.account.IsFixed);
                }

                // Setze für alle anderen Konten den LatestBalance auf 0 bei Überschreitung des Nullzeitraums
                List<Account> noClosureAccounts = Account.GetAccounts().Where(a => !(a.IsOfficial && a.IsCapital)).ToList();
                foreach (var account in noClosureAccounts)
                {
                    double latestBalance;
                    if (CashClosureHelper.exceededZeroPeriod(account.ZeroPeriodEnum))
                        latestBalance = 0.0;
                    else
                        latestBalance = account.LatestBalance;
                    Account.Update(account.AccountID, account.Name, account.Number, account.ZeroPeriodEnum, account.IsOfficial, account.Description, latestBalance, account.IsCapital, account.IsFixed);
                }

                MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
                Type pageType = typeof(pCashClosureManager);
                mainWindow.switchPage(IniParser.GetSetting("ACCOUNTING", "cashClosure"), pageType);
            }
            catch
            {
                try
                {
                    if (cashClosureID != -1)
                        CashClosure.Delete(cashClosureID);
                    if (cashClosureReportID != -1)
                        CashClosureReport.Delete(cashClosureReportID);
                    if (cashClosureReceiptID != 1)
                        CashClosureReceipt.Delete(cashClosureReceiptID);
                }
                catch
                {
                    MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "newCashClosure"));
                }
                MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "newCashClosure"));
            }
        }
Пример #2
0
        /// <summary>
        /// DataGrid aktualisieren
        /// </summary>
        private void refreshDataGrid()
        {
            CashClosureHelper cashClosureHelper = new CashClosureHelper();
            List<Account> closureAccounts = cashClosureHelper.closureAccounts;
            this.accountModels.Clear();

            double sumRevenues = 0;
            double sumExpenses = 0;
            double sumNewBalances = 0;

            // Berechne für jedes Kassenschluss-Konto die Summen
            foreach (var account in closureAccounts)
            {
                double oldBalance = cashClosureHelper.getOldBalanceForAccount(account.AccountID);
                double revenues = cashClosureHelper.getRevenuesForAccount(account.AccountID);
                double expenses = cashClosureHelper.getExpensesForAccount(account.AccountID);
                double newBalance = oldBalance + revenues - expenses;

                CashClosureAccountsDataGridModel model = new CashClosureAccountsDataGridModel(account, oldBalance, revenues, expenses, newBalance);
                accountModels.Add(model);

                sumRevenues += revenues;
                sumExpenses += expenses;
                sumNewBalances += newBalance;
            }
            AccountsDataGrid.ItemsSource = accountModels;
            AccountsDataGrid.Items.Refresh();

            // Zeige Gesamt-Summen an
            lbRevenues.Content = SafeStringParser.safeParseToMoney(sumRevenues, true);
            lbExpenses.Content = SafeStringParser.safeParseToMoney(sumExpenses, true);
            lbSum.Content = SafeStringParser.safeParseToMoney(sumNewBalances, true);

            this.expensesTotal = sumExpenses;
            this.revenuesTotal = sumRevenues;
        }
Пример #3
0
        /// <summary>
        /// Setzt in der GUI das Einkommen dieses und des letzten Jahres.
        /// </summary>
        private void SetRevenues()
        {
            CashClosureHelper helper = new CashClosureHelper(false);
            int currentYear = DateTime.Now.Year;

            //Revenues of this year
            DateTime from = BookingsHelper.makeDateSmall(new DateTime(currentYear, 1, 1));
            DateTime to = BookingsHelper.makeDateGreat(DateTime.Today);
            revenuesThisYear = helper.getAllRevenuesForPeriod(from, to);

            //Revenues of last year
            from = BookingsHelper.makeDateSmall(new DateTime(currentYear - 1, 1, 1));
            to = BookingsHelper.makeDateGreat(new DateTime(currentYear - 1, 12, 31));
            revenuesLastYear = helper.getAllRevenuesForPeriod(from, to);

            lRevenuesThisYear.Content = SafeStringParser.safeParseToMoney(revenuesThisYear, true);
            lRevenuesLastYear.Content = SafeStringParser.safeParseToMoney(revenuesLastYear, true);
        }