Exemplo n.º 1
0
        public static bool PeriodMonthEnd(
            Int32 ALedgerNumber,
            bool AInfoMode,
            out List <Int32> AglBatchNumbers,
            out Boolean AStewardshipBatch,
            out TVerificationResultCollection AVerificationResults)
        {
            AglBatchNumbers   = new List <int>();
            AStewardshipBatch = false;
            try
            {
                TLedgerInfo ledgerInfo    = new TLedgerInfo(ALedgerNumber);
                Int32       PeriodClosing = ledgerInfo.CurrentPeriod;
                bool        res           = new TMonthEnd(ledgerInfo).RunMonthEnd(AInfoMode,
                                                                                  out AglBatchNumbers,
                                                                                  out AStewardshipBatch,
                                                                                  out AVerificationResults);

                if (!res && !AInfoMode)
                {
                    TDBTransaction         Transaction = null;
                    AAccountingPeriodTable PeriodTbl   = null;

                    DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadUncommitted,
                                                                              TEnforceIsolationLevel.eilMinimum,
                                                                              ref Transaction,
                                                                              delegate
                    {
                        PeriodTbl = AAccountingPeriodAccess.LoadByPrimaryKey(ledgerInfo.LedgerNumber, PeriodClosing, Transaction);
                    });

                    if (PeriodTbl.Rows.Count > 0)
                    {
                        AVerificationResults.Add(
                            new TVerificationResult(
                                Catalog.GetString("Month End"),
                                String.Format(Catalog.GetString("The period {0} - {1} has been closed."),
                                              PeriodTbl[0].PeriodStartDate.ToShortDateString(), PeriodTbl[0].PeriodEndDate.ToShortDateString()),
                                TResultSeverity.Resv_Status));
                    }
                }

                return(res);
            }
            catch (Exception e)
            {
                TLogging.Log("TPeriodIntervallConnector.TPeriodMonthEnd() throws " + e.ToString());
                AVerificationResults = new TVerificationResultCollection();
                AVerificationResults.Add(
                    new TVerificationResult(
                        Catalog.GetString("Month End"),
                        Catalog.GetString("Uncaught Exception: ") + e.Message,
                        TResultSeverity.Resv_Critical));


                return(true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populate ledger with gifts and invoices, post batches, close periods and years, according to FNumberOfClosedPeriods
        /// </summary>
        /// <param name="datadirectory"></param>
        public static void PopulateData(string datadirectory)
        {
            int periodOverall = 0;
            int yearCounter   = 0;
            int period        = 1;
            int YearAD        = DateTime.Today.Year - (FNumberOfClosedPeriods / 12);

            SampleDataGiftBatches.LoadBatches(Path.Combine(datadirectory, "donations.csv"));
            SampleDataAccountsPayable.GenerateInvoices(Path.Combine(datadirectory, "invoices.csv"), YearAD);

            while (periodOverall <= FNumberOfClosedPeriods)
            {
                SampleDataGiftBatches.CreateGiftBatches(period);
                SampleDataGiftBatches.PostBatches(yearCounter, period, periodOverall == FNumberOfClosedPeriods ? 1 : 0);
                SampleDataAccountsPayable.PostAndPayInvoices(yearCounter, period, periodOverall == FNumberOfClosedPeriods ? 1 : 0);
                TLedgerInfo LedgerInfo = new TLedgerInfo(FLedgerNumber);

                if (periodOverall < FNumberOfClosedPeriods)
                {
                    TAccountPeriodInfo AccountingPeriodInfo =
                        new TAccountPeriodInfo(FLedgerNumber, period);
                    TLogging.Log("closing period at " + AccountingPeriodInfo.PeriodEndDate.ToShortDateString());

                    // run month end
                    TMonthEnd MonthEndOperator = new TMonthEnd(LedgerInfo);
                    MonthEndOperator.SetNextPeriod();

                    if (period == 12)
                    {
                        TYearEnd YearEndOperator = new TYearEnd(LedgerInfo);
                        // run year end
                        TVerificationResultCollection verificationResult = new TVerificationResultCollection();
                        TReallocation reallocation = new TReallocation(LedgerInfo);
                        reallocation.VerificationResultCollection = verificationResult;
                        reallocation.IsInInfoMode = false;
                        reallocation.RunOperation();

                        TGlmNewYearInit glmNewYearInit = new TGlmNewYearInit(LedgerInfo, yearCounter, YearEndOperator);
                        glmNewYearInit.VerificationResultCollection = verificationResult;
                        glmNewYearInit.IsInInfoMode = false;
                        glmNewYearInit.RunOperation();

                        YearAD++;
                        yearCounter++;
                        SampleDataAccountsPayable.GenerateInvoices(Path.Combine(datadirectory, "invoices.csv"), YearAD);
                        period = 0;
                    }
                }

                period++;
                periodOverall++;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Populate ledger with gifts and invoices, post batches, close periods and years, according to FNumberOfClosedPeriods
        /// </summary>
        public static void PopulateData(string datadirectory, bool smallNumber = false)
        {
            int periodOverall = 0;
            int yearCounter   = 0;
            int period        = 1;
            int YearAD        = DateTime.Today.Year - (FNumberOfClosedPeriods / 12);

            SampleDataGiftBatches.FLedgerNumber     = FLedgerNumber;
            SampleDataAccountsPayable.FLedgerNumber = FLedgerNumber;
            SampleDataGiftBatches.LoadBatches(Path.Combine(datadirectory, "donations.csv"), smallNumber);
            SampleDataAccountsPayable.GenerateInvoices(Path.Combine(datadirectory, "invoices.csv"), YearAD, smallNumber);

            while (periodOverall <= FNumberOfClosedPeriods)
            {
                TLogging.LogAtLevel(1, "working on year " + yearCounter.ToString() + " / period " + period.ToString());

                SampleDataGiftBatches.CreateGiftBatches(period);

                if (!SampleDataGiftBatches.PostBatches(yearCounter, period, (periodOverall == FNumberOfClosedPeriods) ? 1 : 0))
                {
                    throw new Exception("could not post gift batches");
                }

                if (!SampleDataAccountsPayable.PostAndPayInvoices(yearCounter, period, (periodOverall == FNumberOfClosedPeriods) ? 1 : 0))
                {
                    throw new Exception("could not post invoices");
                }

                TLedgerInfo LedgerInfo = new TLedgerInfo(FLedgerNumber);

                if (periodOverall < FNumberOfClosedPeriods)
                {
                    TAccountPeriodInfo AccountingPeriodInfo =
                        new TAccountPeriodInfo(FLedgerNumber, period);
                    TLogging.Log("closing period at " + AccountingPeriodInfo.PeriodEndDate.ToShortDateString());

                    // run month end
                    TMonthEnd MonthEndOperator = new TMonthEnd(LedgerInfo);
                    MonthEndOperator.SetNextPeriod(null);


                    if (period == 12)
                    {
                        TDBTransaction transaction  = null;
                        bool           SubmissionOK = false;

                        DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(
                            IsolationLevel.Serializable,
                            TEnforceIsolationLevel.eilMinimum,
                            ref transaction,
                            ref SubmissionOK,
                            delegate
                        {
                            TYearEnd YearEndOperator = new TYearEnd(LedgerInfo);
                            // run year end
                            TVerificationResultCollection verificationResult = new TVerificationResultCollection();
                            List <Int32> glBatches     = new List <int>();
                            TReallocation reallocation = new TReallocation(LedgerInfo, glBatches, transaction);
                            reallocation.VerificationResultCollection = verificationResult;
                            reallocation.IsInInfoMode = false;
                            reallocation.RunOperation();

                            TGlmNewYearInit glmNewYearInit = new TGlmNewYearInit(LedgerInfo, yearCounter, YearEndOperator, transaction);
                            glmNewYearInit.VerificationResultCollection = verificationResult;
                            glmNewYearInit.IsInInfoMode = false;
                            glmNewYearInit.RunOperation();
                            YearEndOperator.SetNextPeriod(transaction);

                            SampleDataLedger.InitExchangeRate();

                            YearAD++;
                            yearCounter++;
                            SampleDataAccountsPayable.GenerateInvoices(Path.Combine(datadirectory, "invoices.csv"), YearAD, smallNumber);
                            period       = 0;
                            SubmissionOK = true;
                        });
                    }
                }

                period++;
                periodOverall++;
            }
        }
Exemplo n.º 4
0
        public static bool PeriodMonthEnd(
            Int32 ALedgerNumber,
            bool AInfoMode,
            out List <Int32> AglBatchNumbers,
            out Boolean AStewardshipBatch,
            out TVerificationResultCollection AVerificationResults,
            TDataBase ADataBase = null)
        {
            AglBatchNumbers   = new List <int>();
            AStewardshipBatch = false;
            try
            {
                TLedgerInfo ledgerInfo    = new TLedgerInfo(ALedgerNumber, ADataBase);
                Int32       PeriodClosing = ledgerInfo.CurrentPeriod;
                bool        succeeded     = new TMonthEnd(ADataBase, ledgerInfo).RunMonthEnd(AInfoMode,
                                                                                             out AglBatchNumbers,
                                                                                             out AStewardshipBatch,
                                                                                             out AVerificationResults);

                if (succeeded && !AInfoMode)
                {
                    TDBTransaction         Transaction = new TDBTransaction();
                    TDataBase              db          = DBAccess.Connect("PeriodMonthEnd", ADataBase);
                    AAccountingPeriodTable PeriodTbl   = null;

                    db.ReadTransaction(
                        ref Transaction,
                        delegate
                    {
                        PeriodTbl = AAccountingPeriodAccess.LoadByPrimaryKey(ledgerInfo.LedgerNumber, PeriodClosing, Transaction);
                    });

                    if (ADataBase == null)
                    {
                        db.CloseDBConnection();
                    }

                    if (succeeded && PeriodTbl.Rows.Count > 0)
                    {
                        AVerificationResults.Add(
                            new TVerificationResult(
                                Catalog.GetString("Month End"),
                                String.Format(Catalog.GetString("The period {0} - {1} has been closed."),
                                              PeriodTbl[0].PeriodStartDate.ToShortDateString(), PeriodTbl[0].PeriodEndDate.ToShortDateString()),
                                TResultSeverity.Resv_Status));
                    }
                }

                return(succeeded);
            }
            catch (Exception e)
            {
                TLogging.Log("TPeriodIntervallConnector.TPeriodMonthEnd() throws " + e.ToString());
                AVerificationResults = new TVerificationResultCollection();
                AVerificationResults.Add(
                    new TVerificationResult(
                        Catalog.GetString("Month End"),
                        Catalog.GetString("Uncaught Exception: ") + e.Message,
                        TResultSeverity.Resv_Critical));


                return(false);
            }
        }