Esempio n. 1
0
 public FinancialPrepaidExpenseStrategy(Guid transactionId, string accountCode)
 {
     this.fIsRelatedStrategy        = false;
     this.fAccountCode              = accountCode;
     this.fTransactionId            = transactionId;
     this.fFinancialTransactionData = new ETL_FinancialPrepaidExpenseTransaction();
     this.fFinancialTransformData   = new ETL_FinancialPrepaidExpenseTransformData();
 }
Esempio n. 2
0
 public FinancialPrepaidExpenseStrategy()
 {
     this.fIsRelatedStrategy        = false;
     this.fAccountCode              = string.Empty;
     this.fTransactionId            = Guid.Empty;
     this.fFinancialTransactionData = new ETL_FinancialPrepaidExpenseTransaction();
     this.fFinancialTransformData   = new ETL_FinancialPrepaidExpenseTransformData();
 }
Esempio n. 3
0
        protected ETL_FinancialPrepaidExpenseTransformData TransformTransaction
        (
            Session session,
            ETL_FinancialPrepaidExpenseTransaction transaction,
            string AccountCode)
        {
            Util util = new Util();
            ETL_FinancialPrepaidExpenseTransformData result = new ETL_FinancialPrepaidExpenseTransformData();
            Account account = util.GetXpoObjectByFieldName <Account, string>(session, "Code", AccountCode, BinaryOperatorType.Equal);

            if (account == null)
            {
                return(null);
            }
            if (transaction == null)
            {
                return(null);
            }
            ETL_Transaction etlTransaction = transaction;

            string subMainAccount = string.Empty;

            List <ETL_FinancialPrepaidExpenseDetail> detail = new List <ETL_FinancialPrepaidExpenseDetail>();

            try
            {
                ETLAccountingBO           accountingBO      = new ETLAccountingBO();
                FinancialLiabilityBO      liabilityBO       = new FinancialLiabilityBO();
                List <ETL_GeneralJournal> JournalListJoined = JoinJournal(session, etlTransaction.GeneralJournalList);
                List <ETL_GeneralJournal> FinishJournalList = liabilityBO.ClearJournalList(session, JournalListJoined, account.AccountId);
                foreach (ETL_GeneralJournal journal in FinishJournalList)
                {
                    ETL_FinancialPrepaidExpenseDetail temp = new ETL_FinancialPrepaidExpenseDetail();
                    temp.AccountCode           = string.Empty;
                    temp.CorrespondAccountCode = string.Empty;
                    if (accountingBO.IsRelateAccount(session, account.AccountId, journal.AccountId))
                    {
                        temp.AccountCode = subMainAccount = session.GetObjectByKey <Account>(journal.AccountId).Code;
                    }
                    else
                    {
                        temp.CorrespondAccountCode = session.GetObjectByKey <Account>(journal.AccountId).Code;
                    }
                    temp.CurrencyCode     = session.GetObjectByKey <Currency>(journal.CurrencyId).Code;
                    temp.IsBalanceForward = etlTransaction.IsBalanceForward;
                    temp.IssueDate        = etlTransaction.IssuedDate;
                    temp.OwnerOrgId       = etlTransaction.OwnerOrgId;
                    temp.TransactionId    = etlTransaction.TransactionId;
                    temp.Credit           = (decimal)journal.Credit;
                    temp.Debit            = (decimal)journal.Debit;
                    detail.Add(temp);
                }

                result.MainAccountCode = subMainAccount;
                result.ETL_DetailList  = detail;
            }
            catch (Exception)
            {
                return(null);
            }
            return(result);
        }
Esempio n. 4
0
        public ETL_FinancialPrepaidExpenseTransaction ExtractTransaction(Session session, Guid TransactionId, string AccountCode)
        {
            ETL_FinancialPrepaidExpenseTransaction resultTransaction = null;

            try
            {
                bool             Acceptable = false;
                CriteriaOperator criteria_RowStatus
                    = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
                CriteriaOperator criteria_Code = new BinaryOperator("Code", AccountCode, BinaryOperatorType.Equal);
                CriteriaOperator criteria      = CriteriaOperator.And(criteria_Code, criteria_RowStatus);
                Account          account       = session.FindObject <Account>(criteria);

                Organization defaultOrg       = Organization.GetDefault(session, OrganizationEnum.NAAN_DEFAULT);
                Organization currentDeployOrg = Organization.GetDefault(session, OrganizationEnum.QUASAPHARCO);
                Account      defaultAccount   = Account.GetDefault(session, DefaultAccountEnum.NAAN_DEFAULT);
                Transaction  transaction      = session.GetObjectByKey <Transaction>(TransactionId);
                if (transaction == null)
                {
                    return(resultTransaction);
                }

                resultTransaction = new ETL_FinancialPrepaidExpenseTransaction();
                if (currentDeployOrg != null)
                {
                    resultTransaction.OwnerOrgId = currentDeployOrg.OrganizationId;
                }
                else
                {
                    resultTransaction.OwnerOrgId = defaultOrg.OrganizationId;
                }

                resultTransaction.TransactionId      = transaction.TransactionId;
                resultTransaction.Amount             = transaction.Amount;
                resultTransaction.Code               = transaction.Code;
                resultTransaction.CreateDate         = transaction.CreateDate;
                resultTransaction.Description        = transaction.Description;
                resultTransaction.IsBalanceForward   = (transaction is BalanceForwardTransaction);
                resultTransaction.IssuedDate         = transaction.IssueDate;
                resultTransaction.UpdateDate         = transaction.UpdateDate;
                resultTransaction.GeneralJournalList = new List <ETL_GeneralJournal>();

                foreach (GeneralJournal journal
                         in
                         transaction.GeneralJournals.Where(i => i.RowStatus == Constant.ROWSTATUS_BOOKED_ENTRY || i.RowStatus == Constant.ROWSTATUS_ACTIVE))
                {
                    ETL_GeneralJournal tempJournal = new ETL_GeneralJournal();
                    if (journal.AccountId != null)
                    {
                        tempJournal.AccountId = journal.AccountId.AccountId;
                    }
                    else
                    {
                        tempJournal.AccountId = defaultAccount.AccountId;
                    }

                    tempJournal.CreateDate = journal.CreateDate;
                    tempJournal.Credit     = journal.Credit;
                    if (journal.CurrencyId == null)
                    {
                        tempJournal.CurrencyId = CurrencyBO.DefaultCurrency(session).CurrencyId;
                    }
                    else
                    {
                        tempJournal.CurrencyId = journal.CurrencyId.CurrencyId;
                    }
                    tempJournal.Debit            = journal.Debit;
                    tempJournal.Description      = journal.Description;
                    tempJournal.GeneralJournalId = journal.GeneralJournalId;
                    tempJournal.JournalType      = journal.JournalType;
                    resultTransaction.GeneralJournalList.Add(tempJournal);

                    Account tmpAccount       = session.GetObjectByKey <Account>(tempJournal.AccountId);
                    bool    flgIsLeafAccount = tmpAccount.Accounts == null || tmpAccount.Accounts.Count == 0 ? true : false;

                    if (flgIsLeafAccount &&
                        accountingBO.IsRelateAccount(session, account.AccountId, tempJournal.AccountId))
                    {
                        Acceptable = true;
                    }
                }
                if (!Acceptable)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            resultTransaction.AccountCode = AccountCode;
            return(resultTransaction);
        }