private IEnumerable <JournalVoucherReportOutputItem> CreateJournalVoucherOutputItemsForDist(
            string fundId,
            string primaryFundId,
            List <Domain.Core.DistDbModels.Gl00100> distFunds,
            decimal entryValue,
            int entryRowIndex,
            bool isExceptionRule,
            JournalVoucherType journalVoucher,
            JournalVoucherMatchingResultBuilder matchingResultBuilder)
        {
            if (entryValue == 0)
            {
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            (string debitFundId, string creditFundId) = GetDebitAndCreditFundIdsForRemit(primaryFundId, entryValue);

            var debitFund  = distFunds.FirstOrDefault(t => t.Actnumbr3.Trim() == debitFundId);
            var creditFund = distFunds.FirstOrDefault(t => t.Actnumbr3.Trim() == creditFundId);

            if (debitFund == null)
            {
                matchingResultBuilder.ReportUnmatchedDistFund(entryRowIndex, _sheetName, primaryFundId, journalVoucher, debitFundId);
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            if (creditFund == null)
            {
                matchingResultBuilder.ReportUnmatchedDistFund(entryRowIndex, _sheetName, primaryFundId, journalVoucher, creditFundId);
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            string debitAccountNumber = $"{primaryFundId}.{debitFund.Actnumbr2.Trim()}.{debitFundId}";

            if (isExceptionRule)
            {
                fundId = fundId.Replace('-', '.');
                if (fundId.IndexOf('.') == 3)
                {
                    fundId = fundId.Remove(3, 1);
                }
                debitAccountNumber = $"{fundId}.{debitFundId}";
            }
            string creditAccountNumber = $"{primaryFundId}.{creditFund.Actnumbr2.Trim()}.{creditFundId}";

            if (isExceptionRule)
            {
                fundId = fundId.Replace('-', '.');
                if (fundId.IndexOf('.') == 3)
                {
                    fundId = fundId.Remove(3, 1);
                }
                creditAccountNumber = $"{fundId}.{creditFundId}";
            }

            return(new[] {
                CreateDebitJournalVoucherOutputItem(debitAccountNumber, debitFund.Actdescr.Trim(), entryValue, journalVoucher, DbSource.DIST),
                CreateCreditJournalVoucherOutputItem(creditAccountNumber, creditFund.Actdescr.Trim(), entryValue, journalVoucher, DbSource.DIST)
            });
        }
Beispiel #2
0
        public MonthlyReportRule GetMonthlyReportRule(JournalVoucherType jvType, string fundId)
        {
            var rules            = _monthlyReportRepository.Get(t => t.JournalVoucherType == jvType).ToList();
            var specificityRules = rules.Where(t => !string.IsNullOrWhiteSpace(t.FundIds));
            var defaultRule      = rules.FirstOrDefault(t => string.IsNullOrWhiteSpace(t.FundIds));

            foreach (var rule in specificityRules)
            {
                bool isRuleHasMatchedFundId = false;
                if (jvType == JournalVoucherType.Remits)
                {
                    isRuleHasMatchedFundId =
                        rule.FundIds
                        .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                        .Any(fund => fundId.Trim().StartsWith(fund.Trim()));
                }
                else
                {
                    isRuleHasMatchedFundId =
                        rule.FundIds
                        .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                        .Any(fund => fund.Trim() == fundId.Trim());
                }

                if (isRuleHasMatchedFundId)
                {
                    return(rule);
                }
            }
            return(defaultRule);
        }
        private IEnumerable <JournalVoucherReportOutputItem> CreateJournalVoucherOutputItemsForGc(
            string fundId,
            string primaryFundId,
            List <Domain.Core.GcDbModels.Gl00100> gcFunds,
            decimal entryValue,
            int entryRowIndex,
            bool isExceptionRule,
            JournalVoucherType journalVoucher,
            JournalVoucherMatchingResultBuilder matchingResultBuilder)
        {
            if (entryValue == 0)
            {
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            string debitFundId  = string.Empty;
            string creditFundId = string.Empty;

            var getDebitAndCreditForInvestmentJournalVoucherResult = GetDebitAndCreditForInvestmentJournalVoucher(journalVoucher, primaryFundId, entryValue);

            debitFundId  = getDebitAndCreditForInvestmentJournalVoucherResult.debit;
            creditFundId = getDebitAndCreditForInvestmentJournalVoucherResult.credit;
            var debitFund  = gcFunds.FirstOrDefault(t => t.Actnumbr5.Trim() == debitFundId);
            var creditFund = gcFunds.FirstOrDefault(t => t.Actnumbr5.Trim() == creditFundId);

            if (debitFund == null)
            {
                matchingResultBuilder.ReportUnmatchedGcFund(entryRowIndex, _sheetName, primaryFundId, journalVoucher, debitFundId);
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            if (creditFund == null)
            {
                matchingResultBuilder.ReportUnmatchedGcFund(entryRowIndex, _sheetName, primaryFundId, journalVoucher, creditFundId);
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            string debitAccountNumber = $"{primaryFundId}.{debitFund.Actnumbr2.Trim()}.{debitFund.Actnumbr3.Trim()}.{debitFund.Actnumbr4.Trim()}.{debitFundId}";

            if (isExceptionRule)
            {
                fundId             = fundId.Replace('-', '.');
                debitAccountNumber = $"{fundId}.{debitFundId}";
            }
            string creditAccountNumber = $"{primaryFundId}.{creditFund.Actnumbr2.Trim()}.{debitFund.Actnumbr3.Trim()}.{debitFund.Actnumbr4.Trim()}.{creditFundId}";

            if (isExceptionRule)
            {
                fundId = fundId.Replace('-', '.');
                creditAccountNumber = $"{fundId}.{creditFundId}";
            }

            return(new[] {
                CreateDebitJournalVoucherOutputItem(debitAccountNumber, debitFund.Actdescr.Trim(), entryValue, journalVoucher, DbSource.GC),
                CreateCreditJournalVoucherOutputItem(creditAccountNumber, creditFund.Actdescr.Trim(), entryValue, journalVoucher, DbSource.GC)
            });
        }
Beispiel #4
0
 protected JournalVoucherReportOutputItem CreateCreditJournalVoucherOutputItem(
     string accountNumber,
     string description,
     decimal entryValue,
     JournalVoucherType journalVoucher,
     DbSource dbSource)
 {
     return(new JournalVoucherReportOutputItem()
     {
         AccountNumber = accountNumber,
         Description = description,
         Debit = 0,
         Credit = Math.Abs(entryValue),
         JournalVoucher = journalVoucher,
         DbSource = dbSource
     });
 }
Beispiel #5
0
 public void ReportUnmatchedDistFund(int rowIndex, string sheetName, string unmatchedFund, JournalVoucherType journalVoucher, string unmatchedJvRuleAccount)
 {
     UnmatchedFunds.Add(new JournalVoucherUnamtchedResult(rowIndex, unmatchedFund, sheetName, "DIST", journalVoucher, unmatchedJvRuleAccount));
 }
Beispiel #6
0
        private IEnumerable <JournalVoucherReportOutputItem> CreateJournalVoucherOutputItemsForGc(
            string fundId,
            string primaryFundId,
            List <Domain.Core.GcDbModels.Gl00100> gcFunds,
            decimal entryValue,
            int entryRowIndex,
            bool isExceptionRule,
            JournalVoucherType journalVoucher,
            JournalVoucherMatchingResultBuilder matchingResultBuilder)
        {
            if (entryValue == 0)
            {
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            string debitFundId  = string.Empty;
            string creditFundId = string.Empty;

            switch (journalVoucher)
            {
            case JournalVoucherType.WarrantIssues:
                (debitFundId, creditFundId) = GetDebitAndCreditFundIdsForWarrantIssues(primaryFundId, entryValue);
                break;

            case JournalVoucherType.WarrantPresented:
                (debitFundId, creditFundId) = GetDebitAndCreditFundIdsForWarrantPresented(primaryFundId, entryValue);
                break;

            case JournalVoucherType.WarrantCancels:
                (debitFundId, creditFundId) = GetDebitAndCreditFundIdsForWarrantCancels(primaryFundId, entryValue);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(journalVoucher));
            }
            var debitFund  = gcFunds.FirstOrDefault(t => t.Actnumbr5.Trim() == debitFundId);
            var creditFund = gcFunds.FirstOrDefault(t => t.Actnumbr5.Trim() == creditFundId);

            if (debitFund == null)
            {
                matchingResultBuilder.ReportUnmatchedGcFund(entryRowIndex, _sheetName, primaryFundId, journalVoucher, debitFundId);
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            if (creditFund == null)
            {
                matchingResultBuilder.ReportUnmatchedGcFund(entryRowIndex, _sheetName, primaryFundId, journalVoucher, creditFundId);
                return(Enumerable.Empty <JournalVoucherReportOutputItem>());
            }

            string debitAccountNumber = $"{primaryFundId}.{debitFund.Actnumbr2.Trim()}.{debitFund.Actnumbr3.Trim()}.{debitFund.Actnumbr4.Trim()}.{debitFundId}";

            if (isExceptionRule)
            {
                fundId             = fundId.Replace('-', '.');
                debitAccountNumber = $"{fundId}.{debitFundId}";
            }

            string creditAccountNumber = $"{primaryFundId}.{creditFund.Actnumbr2.Trim()}.{debitFund.Actnumbr3.Trim()}.{debitFund.Actnumbr4.Trim()}.{creditFundId}";

            if (isExceptionRule)
            {
                fundId = fundId.Replace('-', '.');
                creditAccountNumber = $"{fundId}.{creditFundId}";
            }

            return(new[] {
                CreateDebitJournalVoucherOutputItem(debitAccountNumber, debitFund.Actdescr.Trim(), entryValue, journalVoucher, DbSource.GC),
                CreateCreditJournalVoucherOutputItem(creditAccountNumber, creditFund.Actdescr.Trim(), entryValue, journalVoucher, DbSource.GC)
            });
        }
        private (string debit, string credit) GetDebitAndCreditForInvestmentJournalVoucher(JournalVoucherType journalVoucher, string primaryFundId, decimal entryValue)
        {
            string debitFundId  = string.Empty;
            string creditFundId = string.Empty;

            switch (journalVoucher)
            {
            case JournalVoucherType.InvestmentPurchases:
                return((debitFundId, creditFundId) = GetDebitAndCreditFundIdsForInvestmentPurchases(primaryFundId, entryValue));

            case JournalVoucherType.InvestmentSales:
                return((debitFundId, creditFundId) = GetDebitAndCreditFundIdsForInvestmentSales(primaryFundId, entryValue));

            case JournalVoucherType.InvestmentInterest:
                return((debitFundId, creditFundId) = GetDebitAndCreditFundIdsForInvestmentInterest(primaryFundId, entryValue));

            default:
                throw new ArgumentOutOfRangeException(nameof(journalVoucher));
            }
        }