示例#1
0
        public void FixInvokedBussinessObjects(Session session, XPCollection <BusinessObject> invokedBussinessObjects)
        {
            if (invokedBussinessObjects == null || invokedBussinessObjects.Count == 0)
            {
                return;
            }

            CriteriaOperator criteria_0 = CriteriaOperator.Parse("not(IsNull(FinancialTransactionDimId))");
            CriteriaOperator criteria_1 = new InOperator("FinancialTransactionDimId.RefId", invokedBussinessObjects.Select(i => i.RefId));
            CriteriaOperator criteria_2 = new BinaryOperator("RowStatus", 0, BinaryOperatorType.Greater);
            CriteriaOperator criteria   = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1, criteria_2);
            CorrespondFinancialAccountDim defaultCorrespondAccDim = CorrespondFinancialAccountDim.GetDefault(session, CorrespondFinancialAccountDimEnum.NAAN_DEFAULT);

            XPCollection <FinancialActualPriceDetail> neededToBeFixList = new XPCollection <FinancialActualPriceDetail>(session, criteria);
            FinancialActualPriceSummary_Fact          fact = null;

            if (neededToBeFixList != null && neededToBeFixList.Count > 0)
            {
                foreach (FinancialActualPriceDetail detail in neededToBeFixList)
                {
                    fact             = detail.FinancialActualPriceSummary_FactId;
                    detail.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                    detail.Save();
                    fact.Save();
                }
            }
        }
示例#2
0
        private FinancialActualPriceSummary_Fact CreateFinancialActualPriceSummaryFact(Session session,
                                                                                       Guid OwnerOrgId,
                                                                                       DateTime IssueDate,
                                                                                       string FinancialAccountCode,
                                                                                       bool IsBalanceForward)
        {
            FinancialActualPriceSummary_Fact result = new FinancialActualPriceSummary_Fact(session);

            try
            {
                ETLAccountingBO accountingBO = new ETLAccountingBO();
                DimBO           dimBO        = new DimBO();
                result.BeginCreditBalance    = 0;
                result.BeginDebitBalance     = 0;
                result.CreditSum             = 0;
                result.DebitSum              = 0;
                result.EndCreditBalance      = 0;
                result.EndDebitBalance       = 0;
                result.CoefficientDiff       = 0;
                result.FinancialAccountDimId = accountingBO.GetFinancialAccountDim(session, FinancialAccountCode);
                result.MonthDimId            = dimBO.GetMonthDim(session, (short)IssueDate.Month);
                result.YearDimId             = dimBO.GetYearDim(session, (short)IssueDate.Year);
                result.OwnerOrgDimId         = dimBO.GetOwnerOrgDim(session, OwnerOrgId);
                result.RowStatus             = Constant.ROWSTATUS_ACTIVE;
                if (result.FinancialAccountDimId == null || result.MonthDimId == null || result.YearDimId == null || result.OwnerOrgDimId == null)
                {
                    return(null);
                }

                var date = new DateTime(IssueDate.Year, IssueDate.Month, 1);
                FinancialActualPriceSummary_Fact previousSummary = GetFinancialActualPriceSummaryFact(session,
                                                                                                      OwnerOrgId, date.AddMonths(-1), FinancialAccountCode);

                if (previousSummary != null)
                {
                    result.BeginDebitBalance  = previousSummary.EndDebitBalance;
                    result.BeginCreditBalance = previousSummary.EndCreditBalance;
                }
                result.Save();
                return(result);
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#3
0
        private void CreateFinancialActualPriceDetail(
            Session session,
            ETL_FinanciaActualPriceDetail Detail,
            string MainAccountCode)
        {
            try
            {
                Util util = new Util();
                CorrespondFinancialAccountDim defaultCorrespondindAcc = CorrespondFinancialAccountDim.GetDefault(session, CorrespondFinancialAccountDimEnum.NAAN_DEFAULT);
                FinancialAccountDim           defaultFinancialAcc     = FinancialAccountDim.GetDefault(session, FinancialAccountDimEnum.NAAN_DEFAULT);
                ETLAccountingBO accountingBO               = new ETLAccountingBO();
                FinancialActualPriceSummary_Fact Fact      = GetFinancialActualPriceSummaryFact(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode);
                FinancialActualPriceDetail       newDetail = new FinancialActualPriceDetail(session);
                if (Fact == null)
                {
                    Fact = CreateFinancialActualPriceSummaryFact(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode, Detail.IsBalanceForward);
                    if (Fact == null)
                    {
                        return;
                    }
                }
                else
                {
                    var date = new DateTime(Detail.IssueDate.Year, Detail.IssueDate.Month, 1);
                    FinancialActualPriceSummary_Fact previousSummary = GetFinancialActualPriceSummaryFact(session,
                                                                                                          Detail.OwnerOrgId, date.AddMonths(-1), MainAccountCode);

                    if (previousSummary != null)
                    {
                        Fact.BeginDebitBalance  = previousSummary.EndDebitBalance;
                        Fact.BeginCreditBalance = previousSummary.EndCreditBalance;
                    }
                }

                CorrespondFinancialAccountDim correspondFinancialAccountDim = null;
                FinancialAccountDim           financialAccountDim           = null;

                if (!Detail.CorrespondAccountCode.Equals(string.Empty))
                {
                    correspondFinancialAccountDim = util.GetXpoObjectByFieldName <CorrespondFinancialAccountDim, string>(session, "Code", Detail.CorrespondAccountCode, BinaryOperatorType.Equal);
                }
                if (!MainAccountCode.Equals(string.Empty))
                {
                    financialAccountDim = util.GetXpoObjectByFieldName <FinancialAccountDim, string>(session, "Code", MainAccountCode, BinaryOperatorType.Equal);
                }

                FinancialTransactionDim financialTransactionDim = util.GetXpoObjectByFieldName <FinancialTransactionDim, Guid>(session, "RefId", Detail.TransactionId, BinaryOperatorType.Equal);

                CurrencyDim currencyDim = util.GetXpoObjectByFieldName <CurrencyDim, string>(session, "Code", Detail.CurrencyCode, BinaryOperatorType.Equal);

                if (financialTransactionDim == null)
                {
                    financialTransactionDim = accountingBO.CreateFinancialTransactionDim(session, Detail.TransactionId);
                    if (financialTransactionDim == null)
                    {
                        return;
                    }
                }

                if (financialAccountDim == null && !MainAccountCode.Equals(string.Empty))
                {
                    financialAccountDim = accountingBO.CreateFinancialAccountDim(session, MainAccountCode);
                }
                if (correspondFinancialAccountDim == null && !Detail.CorrespondAccountCode.Equals(string.Empty))
                {
                    correspondFinancialAccountDim = accountingBO.CreateCorrespondFinancialAccountDim(session, Detail.CorrespondAccountCode);
                }

                if (currencyDim == null && !Detail.CurrencyCode.Equals(string.Empty))
                {
                    currencyDim = accountingBO.CreateCurrencyDim(session, Detail.CurrencyCode);
                }

                newDetail.CorrespondFinancialAccountDimId = correspondFinancialAccountDim;
                newDetail.Credit                             = Detail.Credit;
                newDetail.Debit                              = Detail.Debit;
                newDetail.CurrencyDimId                      = currencyDim;
                newDetail.FinancialAccountDimId              = financialAccountDim;
                newDetail.FinancialTransactionDimId          = financialTransactionDim;
                newDetail.FinancialActualPriceSummary_FactId = Fact;

                /*2014-02-22 ERP-1417 Duc.Vo INS START*/

                if (newDetail.FinancialAccountDimId == null)
                {
                    newDetail.FinancialAccountDimId = defaultFinancialAcc;
                }
                if (newDetail.CorrespondFinancialAccountDimId == null)
                {
                    newDetail.CorrespondFinancialAccountDimId = defaultCorrespondindAcc;
                }
                /*2014-02-22 ERP-1417 Duc.Vo INS END*/

                newDetail.RowStatus = Constant.ROWSTATUS_ACTIVE;
                newDetail.Save();

                if (Detail.IsBalanceForward)
                {
                    Fact.BeginCreditBalance = Fact.EndCreditBalance = Detail.Credit;
                    Fact.BeginDebitBalance  = Fact.EndDebitBalance = Detail.Debit;
                    Fact.CreditSum          = 0;
                    Fact.DebitSum           = 0;
                }
                else
                {
                    Fact.CreditSum = Fact.FinancialActualPriceDetails.Where(i => i.RowStatus == 1 &&
                                                                            i.Credit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(d => d.Credit);

                    Fact.DebitSum = Fact.FinancialActualPriceDetails.Where(i => i.RowStatus == 1 &&
                                                                           i.Debit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(d => d.Debit);

                    Fact.EndCreditBalance = Fact.BeginCreditBalance + Fact.CreditSum - Fact.DebitSum;
                    Fact.EndDebitBalance  = Fact.BeginDebitBalance + Fact.DebitSum - Fact.CreditSum;
                }
                Fact.Save();
            }
            catch (Exception)
            {
                return;
            }
        }