Пример #1
0
        public static List <GLJournalEntrysInfo> GenerateCloseEntrys(Guid fromAccID, Guid toAccID, bool isIncludeChildren, DateTime?startDate, DateTime?endDate, String strConditionQuery, String strRemark)
        {
            List <GLJournalEntrysInfo> lstResults = new List <GLJournalEntrysInfo>();

            GLAccountsController accCtrl     = new GLAccountsController();
            GLAccountsInfo       fromAccount = accCtrl.GetObjectByID(fromAccID) as GLAccountsInfo;
            GLAccountsInfo       toAccount   = accCtrl.GetObjectByID(toAccID) as GLAccountsInfo;

            if (fromAccount == null || toAccount == null)
            {
                return(lstResults);
            }

            #region Current
            double dbDebitAmt  = AccountingProvider.GetDebitAmount(fromAccID, startDate, endDate, strConditionQuery, false);
            double dbCreditAmt = AccountingProvider.GetCreditAmount(fromAccID, startDate, endDate, strConditionQuery, false);
            double dbDiff      = dbDebitAmt - dbCreditAmt;
            if (dbDiff != 0)
            {
                GLJournalEntrysInfo entry = new GLJournalEntrysInfo();
                entry.Remark    = strRemark + String.Format(@" : TK {0} sang TK {1}", fromAccount.No, toAccount.No);
                entry.EntryType = ABCCommon.ABCConstString.EntryTypePeriodEnding;
                if (dbDiff > 0)
                {
                    entry.AmtTot = dbDiff;
                    entry.FK_GLAccountID_Debit  = toAccID;
                    entry.FK_GLAccountID_Credit = fromAccID;
                }
                else
                {
                    entry.AmtTot = -dbDiff;
                    entry.FK_GLAccountID_Debit  = fromAccID;
                    entry.FK_GLAccountID_Credit = toAccID;
                }
                entry.RaiseAmtTot = entry.AmtTot;
                entry.FK_GLAccountID_RaiseDebit  = entry.FK_GLAccountID_Debit;
                entry.FK_GLAccountID_RaiseCredit = entry.FK_GLAccountID_Credit;

                lstResults.Add(entry);
            }
            #endregion

            if (isIncludeChildren)
            {
                List <BusinessObject> lstChildren = accCtrl.GetListByForeignKey("FK_GLParentAccountID", fromAccount.GLAccountID);
                foreach (GLAccountsInfo child in lstChildren)
                {
                    lstResults.AddRange(GenerateCloseEntrys(child.GLAccountID, toAccID, true, startDate, endDate, strConditionQuery, strRemark));
                }
            }
            return(lstResults);
        }
Пример #2
0
        public static void BenifitCalculationOfRange(GLBenifitCalcsInfo benifitInfo, DateTime?startDate, DateTime?endDate)
        {
            #region BenifitGrossSale

            #region RevenueGrossSale
            benifitInfo.RevenueGrossSale = 0;
            if (AccountingProvider.GetAccountID("511") != Guid.Empty)
            {
                benifitInfo.RevenueGrossSale += AccountingProvider.GetCreditAmount(AccountingProvider.GetAccountID("511"), startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                benifitInfo.RevenueGrossSale -= AccountingProvider.GetDebitAmount(AccountingProvider.GetAccountID("511"), startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
            }
            if (AccountingProvider.GetAccountID("512") != Guid.Empty)
            {
                benifitInfo.RevenueGrossSale += AccountingProvider.GetCreditAmount(AccountingProvider.GetAccountID("512"), startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                benifitInfo.RevenueGrossSale -= AccountingProvider.GetDebitAmount(AccountingProvider.GetAccountID("512"), startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
            }
            #endregion

            #region RevenueDecrease
            benifitInfo.RevenueDecreaseTax = 0;
            benifitInfo.RevenueDecreaseCommercialDiscount = 0;
            benifitInfo.RevenueDecreaseSaleDiscount       = 0;
            benifitInfo.RevenueDecreaseReturnGood         = 0;

            #region RevenueDecreaseTax
            if (AccountingProvider.GetAccountID("3332") != Guid.Empty)
            {
                if (AccountingProvider.GetAccountID("511") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseTax += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("511"),
                                                                                          AccountingProvider.GetAccountID("3332")
                                                                                          , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }

                if (AccountingProvider.GetAccountID("512") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseTax += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("512"),
                                                                                          AccountingProvider.GetAccountID("3332")
                                                                                          , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
            }

            if (AccountingProvider.GetAccountID("3333") != Guid.Empty)
            {
                if (AccountingProvider.GetAccountID("511") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseTax += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("511"),
                                                                                          AccountingProvider.GetAccountID("3333")
                                                                                          , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
                if (AccountingProvider.GetAccountID("512") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseTax += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("512"),
                                                                                          AccountingProvider.GetAccountID("3333")
                                                                                          , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
            }
            #endregion

            #region RevenueDecreaseCommercialDiscount
            if (AccountingProvider.GetAccountID("521") != Guid.Empty)
            {
                if (AccountingProvider.GetAccountID("511") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseCommercialDiscount += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("511"),
                                                                                                         AccountingProvider.GetAccountID("521")
                                                                                                         , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
                if (AccountingProvider.GetAccountID("512") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseCommercialDiscount += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("512"),
                                                                                                         AccountingProvider.GetAccountID("521")
                                                                                                         , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
            }
            #endregion

            #region RevenueDecreaseSaleDiscount
            if (AccountingProvider.GetAccountID("532") != Guid.Empty)
            {
                if (AccountingProvider.GetAccountID("511") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseSaleDiscount += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("511"),
                                                                                                   AccountingProvider.GetAccountID("532")
                                                                                                   , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
                if (AccountingProvider.GetAccountID("512") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseSaleDiscount += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("512"),
                                                                                                   AccountingProvider.GetAccountID("532")
                                                                                                   , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
            }
            #endregion

            #region RevenueDecreaseReturnGood
            if (AccountingProvider.GetAccountID("531") != Guid.Empty)
            {
                if (AccountingProvider.GetAccountID("511") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseReturnGood += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("511"),
                                                                                                 AccountingProvider.GetAccountID("531")
                                                                                                 , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
                if (AccountingProvider.GetAccountID("512") != Guid.Empty)
                {
                    benifitInfo.RevenueDecreaseReturnGood += AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("512"),
                                                                                                 AccountingProvider.GetAccountID("531")
                                                                                                 , startDate, endDate, " (EntryType IS NULL OR EntryType != 'PeriodEnding') ", true);
                }
            }
            #endregion

            benifitInfo.RevenueDecrease = benifitInfo.RevenueDecreaseTax + benifitInfo.RevenueDecreaseCommercialDiscount
                                          + benifitInfo.RevenueDecreaseSaleDiscount + benifitInfo.RevenueDecreaseReturnGood;

            #endregion

            benifitInfo.RevenueNetSale = benifitInfo.RevenueGrossSale - benifitInfo.RevenueDecrease;

            #region CostOfGoodSolved
            benifitInfo.CostOfGoodSolved = 0;
            if (AccountingProvider.GetAccountID("632") != Guid.Empty)
            {
                benifitInfo.CostOfGoodSolved = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("911"), AccountingProvider.GetAccountID("632"), startDate, endDate, "", true);
            }
            #endregion

            benifitInfo.BenifitGrossSale = benifitInfo.RevenueNetSale - benifitInfo.CostOfGoodSolved;

            #endregion

            #region BenifitComercial

            #region RevenueCommercial
            benifitInfo.RevenueCommercial = 0;
            if (AccountingProvider.GetAccountID("515") != Guid.Empty)
            {
                benifitInfo.RevenueCommercial = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("515"), AccountingProvider.GetAccountID("911"), startDate, endDate, "", true);
            }

            #endregion

            #region CostCommercial
            benifitInfo.CostCommercial = 0;
            if (AccountingProvider.GetAccountID("635") != Guid.Empty)
            {
                benifitInfo.CostCommercial = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("911"), AccountingProvider.GetAccountID("635"), startDate, endDate, "", true);
            }

            #endregion

            benifitInfo.CostLoan = 0;

            benifitInfo.BenifitComercial = benifitInfo.RevenueCommercial - benifitInfo.CostCommercial - benifitInfo.CostLoan;

            #endregion

            #region CostSale
            benifitInfo.CostSale = 0;
            if (AccountingProvider.GetAccountID("641") != Guid.Empty)
            {
                benifitInfo.CostSale = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("911"), AccountingProvider.GetAccountID("641"), startDate, endDate, "", true);
            }

            #endregion

            #region CostManage
            benifitInfo.CostManage = 0;
            if (AccountingProvider.GetAccountID("642") != Guid.Empty)
            {
                benifitInfo.CostManage = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("911"), AccountingProvider.GetAccountID("642"), startDate, endDate, "", true);
            }

            #endregion

            benifitInfo.BenifitNet = benifitInfo.BenifitGrossSale + (benifitInfo.RevenueCommercial - benifitInfo.CostCommercial) - (benifitInfo.CostSale + benifitInfo.CostManage);

            #region BenifitOthers

            #region RevenueOthers
            benifitInfo.RevenueOthers = 0;
            if (AccountingProvider.GetAccountID("711") != Guid.Empty)
            {
                benifitInfo.RevenueOthers = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("711"), AccountingProvider.GetAccountID("911"), startDate, endDate, "", true);
            }

            #endregion

            #region CostOthers
            benifitInfo.CostOthers = 0;
            if (AccountingProvider.GetAccountID("811") != Guid.Empty)
            {
                benifitInfo.CostOthers = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("911"), AccountingProvider.GetAccountID("811"), startDate, endDate, "", true);
            }

            #endregion

            benifitInfo.BenifitOthers = benifitInfo.RevenueOthers - benifitInfo.CostOthers;

            #endregion

            benifitInfo.BenifitBeforeTax = benifitInfo.BenifitNet + benifitInfo.BenifitOthers;

            #region Income Tax

            #region CostIncomeTax
            benifitInfo.CostIncomeTax = 0;
            if (AccountingProvider.GetAccountID("8211") != Guid.Empty)
            {
                benifitInfo.CostIncomeTax = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("911"), AccountingProvider.GetAccountID("8211"), startDate, endDate, "", true);
            }

            #endregion

            #region CostIncomeTaxDelay
            benifitInfo.CostIncomeTaxDelay = 0;
            if (AccountingProvider.GetAccountID("8212") != Guid.Empty)
            {
                benifitInfo.CostIncomeTaxDelay = AccountingProvider.GetJournalAmount(AccountingProvider.GetAccountID("911"), AccountingProvider.GetAccountID("8212"), startDate, endDate, "", true);
            }

            #endregion

            #endregion

            benifitInfo.Benifit = benifitInfo.BenifitBeforeTax - benifitInfo.CostIncomeTax - benifitInfo.CostIncomeTaxDelay;
        }