Beispiel #1
0
 public DiaryJournal_Fact get_DiaryJournal_Fact(Session session, int DiaryJournal_FactId)
 {
     try
     {
         DiaryJournal_Fact DJF = session.FindObject <DiaryJournal_Fact>(
             CriteriaOperator.And(
                 new BinaryOperator("DiaryJournal_FactId", DiaryJournal_FactId, BinaryOperatorType.Equal)
                 ));
         if (DJF == null)
         {
             return(null);
         }
         return(DJF);
     }
     catch (Exception) { throw; }
 }
Beispiel #2
0
        // Get
        public DiaryJournal_Fact GetDiaryJournalFact(
            Session session,
            Guid OwnerOrgId,
            DateTime IssueDate,
            string FinancialAccountCode)
        {
            DiaryJournal_Fact result = null;

            try
            {
                Util                util                = new Util();
                OwnerOrgDim         ownerOrgDim         = util.GetXpoObjectByFieldName <OwnerOrgDim, Guid>(session, "RefId", OwnerOrgId, BinaryOperatorType.Equal);
                MonthDim            monthDim            = util.GetXpoObjectByFieldName <MonthDim, string>(session, "Name", IssueDate.Month.ToString(), BinaryOperatorType.Equal);
                YearDim             yearDim             = util.GetXpoObjectByFieldName <YearDim, string>(session, "Name", IssueDate.Year.ToString(), BinaryOperatorType.Equal);
                FinancialAccountDim financialAccountDim = util.GetXpoObjectByFieldName <FinancialAccountDim, string>(session, "Code", FinancialAccountCode, BinaryOperatorType.Equal);

                if (ownerOrgDim == null || monthDim == null || yearDim == null || financialAccountDim == null)
                {
                    return(null);
                }
                else
                {
                    //CriteriaOperator criteria_RowStatus = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
                    CriteriaOperator criteria_OwnerOrg    = new BinaryOperator("OwnerOrgDimId", ownerOrgDim, BinaryOperatorType.Equal);
                    CriteriaOperator criteria_Month       = new BinaryOperator("MonthDimId", monthDim, BinaryOperatorType.Equal);
                    CriteriaOperator criteria_Year        = new BinaryOperator("YearDimId", yearDim, BinaryOperatorType.Equal);
                    CriteriaOperator criteria_AccountCode = new BinaryOperator("FinancialAccountDimId", financialAccountDim, BinaryOperatorType.Equal);
                    CriteriaOperator criteria             = CriteriaOperator.And(criteria_OwnerOrg, criteria_Month, criteria_Year, criteria_AccountCode);

                    DiaryJournal_Fact fact = session.FindObject <DiaryJournal_Fact>(criteria);

                    if (fact == null)
                    {
                        return(null);
                    }
                    {
                        result = fact;
                    }
                }
            }
            catch (Exception)
            {
                return(result);
            }

            return(result);
        }
Beispiel #3
0
 public DiaryJournal_Fact get_DiaryJournal_Fact_1(Session session, int FinancialAccountDimId, int MonthDimId, int YearDimId) //, int OwnerOrgDimId
 {
     try
     {
         DiaryJournal_Fact DJF = session.FindObject <DiaryJournal_Fact>(
             CriteriaOperator.And(
                 new BinaryOperator("FinancialAccountDimId", FinancialAccountDimId, BinaryOperatorType.Equal),
                 // new BinaryOperator("OwnerOrgDimId", OwnerOrgDimId, BinaryOperatorType.Equal),
                 new BinaryOperator("MonthDimId", MonthDimId, BinaryOperatorType.Equal),
                 new BinaryOperator("YearDimId", YearDimId, BinaryOperatorType.Equal)
                 ));
         if (DJF == null)
         {
             return(null);
         }
         return(DJF);
     }
     catch (Exception) { throw; }
 }
Beispiel #4
0
        // Create
        public DiaryJournal_Fact CreateDiaryJournalFact(Session session,
                                                        Guid OwnerOrgId,
                                                        DateTime IssueDate,
                                                        DiaryJournalTemplate diaryJournal,
                                                        string accountCode)
        {
            DiaryJournal_Fact result = new DiaryJournal_Fact(session);

            try
            {
                ETLAccountingBO accountingBO = new ETLAccountingBO();
                DimBO           dimBO        = new DimBO();
                result.FinancialAccountDimId = accountingBO.GetFinancialAccountDim(session, accountCode);
                result.MonthDimId            = dimBO.GetMonthDim(session, (short)IssueDate.Month);
                result.YearDimId             = dimBO.GetYearDim(session, (short)IssueDate.Year);
                result.OwnerOrgDimId         = dimBO.GetOwnerOrgDim(session, OwnerOrgId);
                //result.CreditSum = 0;
                //result.DebitSum = 0;
                //result.BeginCreditBalance = 0;
                //result.BeginDebitBalance = 0;
                //result.EndCreditBalance = 0;
                //result.EndDebitBalance = 0;

                if (result.FinancialAccountDimId == null || result.MonthDimId == null || result.YearDimId == null || result.OwnerOrgDimId == null)
                {
                    return(null);
                }
                result.Save();
            }
            catch (Exception)
            {
                return(null);
            }

            return(result);
        }
Beispiel #5
0
        public void CreateDiaryJournalDetail(Session session, DiaryJournalTemplate diaryJournal, string accountCode, char debitOrCredit)
        {
            try
            {
                Util            util         = new Util();
                ETLAccountingBO accountingBO = new ETLAccountingBO();

                DiaryJournal_Fact   Fact      = GetDiaryJournalFact(session, diaryJournal.OwnerOrgId, diaryJournal.IssueDate, accountCode);
                DiaryJournal_Detail newDetail = new DiaryJournal_Detail(session);
                if (Fact == null)
                {
                    Fact = CreateDiaryJournalFact(session, diaryJournal.OwnerOrgId, diaryJournal.IssueDate, diaryJournal, accountCode);
                    if (Fact == null)
                    {
                        return;
                    }
                }
                CorrespondFinancialAccountDim correspondFinancialAccountDim = util.GetXpoObjectByFieldName <CorrespondFinancialAccountDim, string>(session, "Code", diaryJournal.CorrespondFinancialAccountDimCode, BinaryOperatorType.Equal);
                FinancialAccountDim           financialAccountDim           = util.GetXpoObjectByFieldName <FinancialAccountDim, string>(session, "Code", accountCode, BinaryOperatorType.Equal);
                FinancialTransactionDim       financialTransactionDim       = util.GetXpoObjectByFieldName <FinancialTransactionDim, Guid>(session, "RefId", diaryJournal.TransactionId, BinaryOperatorType.Equal);
                CurrencyDim currencyDim = util.GetXpoObjectByFieldName <CurrencyDim, string>(session, "Code", diaryJournal.CurrencyDimCode, BinaryOperatorType.Equal);
                if (financialTransactionDim == null)
                {
                    financialTransactionDim = accountingBO.CreateFinancialTransactionDim(session, diaryJournal.TransactionId);
                    if (financialTransactionDim == null)
                    {
                        return;
                    }
                }
                if (financialAccountDim == null)
                {
                    financialAccountDim = accountingBO.CreateFinancialAccountDim(session, accountCode);
                }
                if (correspondFinancialAccountDim == null)
                {
                    correspondFinancialAccountDim = accountingBO.CreateCorrespondFinancialAccountDim(session, diaryJournal.CorrespondFinancialAccountDimCode);
                }
                if (currencyDim == null)
                {
                    currencyDim = accountingBO.CreateCurrencyDim(session, diaryJournal.CurrencyDimCode);
                }

                Fact.Save();
                if (correspondFinancialAccountDim.Code == "131")
                {
                    newDetail.Credit = diaryJournal.Credit;
                }

                if (correspondFinancialAccountDim != null)
                {
                    if (correspondFinancialAccountDim.Code == "")
                    {
                        if (debitOrCredit == 'C')
                        {
                            newDetail.Credit = diaryJournal.Credit;
                        }
                        else
                        {
                            newDetail.Debit = diaryJournal.Debit;
                        }
                        newDetail.FinancialAccountDimId = financialAccountDim;
                    }
                    else
                    {
                        if (debitOrCredit == 'C')
                        {
                            newDetail.Debit = diaryJournal.Debit;
                        }
                        else
                        {
                            newDetail.Credit = diaryJournal.Credit;
                        }
                        newDetail.CorrespondFinancialAccountDimId = correspondFinancialAccountDim;
                    }
                }

                newDetail.CurrencyDimId             = currencyDim;
                newDetail.DiaryJournal_FactId       = Fact;
                newDetail.FinancialTransactionDimId = financialTransactionDim;
                newDetail.Save();
            }
            catch (Exception)
            {
                return;
            }
        }