protected void Page_Load(object sender, EventArgs e) { GoodsInTransitForSaleDetail detail = new GoodsInTransitForSaleDetail(session); detail.Credit = 1; detail.Save(); GoodsInInventoryDetail detail2 = new GoodsInInventoryDetail(session); detail2.Credit = 1; detail2.Save(); // ASPxComboBox1.ItemsRequestedByFilterCondition += new ListEditItemsRequestedByFilterConditionEventHandler(accountCombobox_ItemsRequestedByFilterCondition); // ASPxComboBox1.ItemRequestedByValue += new ListEditItemRequestedByValueEventHandler(accountCombobox_ItemRequestedByValue); }
public void CreateGoodsInInventoryDetail( Session session, ETL_GoodsInInventoryDetail 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(); GoodsInInventorySummary_Fact Fact = GetGoodsInInventorySummaryFact(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode); GoodsInInventoryDetail newDetail = new GoodsInInventoryDetail(session); if (Fact == null) { Fact = CreateGoodsInInventorySummaryFact(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode, Detail.IsBalanceForward); if (Fact == null) { return; } } else { var date = new DateTime(Detail.IssueDate.Year, Detail.IssueDate.Month, 1); GoodsInInventorySummary_Fact previousSummary = GetGoodsInInventorySummaryFact(session, Detail.OwnerOrgId, date.AddMonths(-1), MainAccountCode); if (previousSummary != null) { Fact.BeginCreditBalance = previousSummary.EndCreditBalance; Fact.BeginDebitBalance = previousSummary.EndDebitBalance; } } 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); InventoryCommandDim inventoryCommandDim = null; if (!Detail.ArtifactId.Equals(Guid.Empty)) { inventoryCommandDim = util.GetXpoObjectByFieldName <InventoryCommandDim, Guid>(session, "RefId", Detail.ArtifactId, BinaryOperatorType.Equal); if (inventoryCommandDim == null) { DimBO dimBO = new DimBO(); inventoryCommandDim = dimBO.GetInventoryCommandDim(session, Detail.ArtifactId); } } else { inventoryCommandDim = InventoryCommandDim.GetDefault(session, InventoryCommandDimEnum.UNKNOWN); } 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); } 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.GoodsInInventoryDetails.Where(i => i.RowStatus == 1 && i.Credit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(d => d.Credit); Fact.DebitSum = Fact.GoodsInInventoryDetails.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(); newDetail.CorrespondFinancialAccountDimId = correspondFinancialAccountDim; newDetail.Credit = Detail.Credit; newDetail.Debit = Detail.Debit; newDetail.Quantity = Detail.Quantity; newDetail.CurrencyDimId = currencyDim; newDetail.FinancialAccountDimId = financialAccountDim; newDetail.GoodsInInventorySummary_FacftId = Fact; newDetail.FinancialTransactionDimId = financialTransactionDim; newDetail.InventoryCommandDimId = inventoryCommandDim; if (newDetail.FinancialAccountDimId == null) { newDetail.FinancialAccountDimId = defaultFinancialAcc; } if (newDetail.CorrespondFinancialAccountDimId == null) { newDetail.CorrespondFinancialAccountDimId = defaultCorrespondindAcc; } newDetail.RowStatus = Constant.ROWSTATUS_ACTIVE; newDetail.Save(); } catch (Exception) { return; } }