Exemplo n.º 1
0
 public DiaryJournal_Detail get_DiaryJournal_Detail(Session session, int DiaryJournal_DetailId)
 {
     try
     {
         DiaryJournal_Detail DJD = session.FindObject <DiaryJournal_Detail>(
             CriteriaOperator.And(
                 new BinaryOperator("DiaryJournal_DetailId", DiaryJournal_DetailId, BinaryOperatorType.Equal)
                 ));
         if (DJD == null)
         {
             return(null);
         }
         return(DJD);
     }
     catch (Exception) { throw; }
 }
Exemplo n.º 2
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;
            }
        }