示例#1
0
        public void LoadData()
        {
            WebModule.Accounting.Report.GeneralLedger generalLedger = new WebModule.Accounting.Report.GeneralLedger();
            try
            {
                #region Parametter
                string account = this.GeneralLedgerAcc.Get("account_id").ToString();
                int    month   = int.Parse(this.GeneralLedgerMonth.Get("month_id").ToString());
                int    year    = int.Parse(this.GeneralLedgerYear.Get("year_id").ToString());
                string asset   = "VND"; //chua su dung gia tri nay neu co
                #endregion

                #region get value
                FinancialAccountDim FAD = BO.get_FinancialAccountDim(session, account, Utility.Constant.ROWSTATUS_ACTIVE);

                MonthDim MD = BO.get_MonthDimId(session, month.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                YearDim YD = BO.get_YearDimId(session, year.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                if (FAD != null && YD != null)
                {
                    FinancialGeneralLedgerByYear_Fact fgly = BO.get_FinancialGeneralLedgerByYear_Fact_1(session, FAD.FinancialAccountDimId, YD.YearDimId, Utility.Constant.ROWSTATUS_ACTIVE);
                    if (fgly != null)
                    {
                        #endregion

                        #region gan label
                        generalLedger.lblYear.Text     = year.ToString();
                        generalLedger.lbl_Account.Text = account;
                        if (fgly.BeginDebitBalance > 0)
                        {
                            generalLedger.lbl_beginDebit.Text = fgly.BeginDebitBalance.ToString("#,#");
                        }
                        else
                        {
                            generalLedger.lbl_beginDebit.Text = "0";
                        }
                        if (fgly.BeginCreditBalance > 0)
                        {
                            generalLedger.lbl_beginCredit.Text = fgly.BeginCreditBalance.ToString("#,#");
                        }
                        else
                        {
                            generalLedger.lbl_beginCredit.Text = "0";
                        }
                        #endregion

                        #region GridView_header va DT_header
                        GridView_header(FAD.FinancialAccountDimId);
                        DataTable dt = DT_header();
                        #endregion

                        #region do du lieu vao DataTable
                        DT_RowGetValue(dt, FAD.FinancialAccountDimId, YD.YearDimId, fgly.BeginCreditBalance, fgly.BeginDebitBalance);

                        #endregion

                        #region Bindata vao Gridview
                        xGridView.DataSource = dt;
                        xGridView.DataBind();
                        #endregion
                    }
                }
            }
            catch { }

            #region xuat report
            ASPxGridViewExporter1.GridViewID             = "xGridView";
            generalLedger.printableCC.PrintableComponent = new PrintableComponentLinkBase()
            {
                Component = ASPxGridViewExporter1
            };
            ReportViewerGLedger.Report = generalLedger;
            #endregion
        }
示例#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;
            }
        }
示例#3
0
        public void Gridview_header(int FinancialAccountDimId, int OwnerOrgDimId, int MonthDimId, int YearDimId)
        {
            try
            {
                GridViewColumn         column = new GridViewBandColumn();
                GridViewBandColumn     bandColumn;
                GridViewDataTextColumn GVTC;
                FinancialAccountDim    FAD = session.GetObjectByKey <FinancialAccountDim>(FinancialAccountDimId);
                if (FAD != null)
                {
                    GVTC = new GridViewDataTextColumn {
                        FieldName = "STT", Caption = "Số TT"
                    };
                    xGridView.Columns.Add(GVTC);

                    GVTC = new GridViewDataTextColumn {
                        FieldName = "Description", Caption = "Diễn giải"
                    };
                    xGridView.Columns.Add(GVTC);

                    GVTC = new GridViewDataTextColumn {
                        FieldName = "BeginBalance", Caption = "Số dư đầu tháng"
                    };
                    GVTC.PropertiesEdit.DisplayFormatString = ("#,#");
                    xGridView.Columns.Add(GVTC);

                    #region column hoa don
                    bandColumn = new GridViewBandColumn("Hóa đơn");
                    GVTC       = new GridViewDataTextColumn {
                        FieldName = "LegalInvoiceCode", Caption = "Số hiệu"
                    };
                    bandColumn.Columns.Add(GVTC);
                    GVTC = new GridViewDataTextColumn {
                        FieldName = "LegalInvoiceIssuedDate", Caption = "Ngày Tháng"
                    };
                    bandColumn.Columns.Add(GVTC);
                    xGridView.Columns.Add(bandColumn);
                    #endregion

                    #region column phieu nhap
                    bandColumn = new GridViewBandColumn("Phiếu nhập");
                    GVTC       = new GridViewDataTextColumn {
                        FieldName = "InvoiceCode", Caption = "Số hiệu"
                    };
                    bandColumn.Columns.Add(GVTC);
                    GVTC = new GridViewDataTextColumn {
                        FieldName = "InvoiceIssuedDate", Caption = "Ngày Tháng"
                    };
                    bandColumn.Columns.Add(GVTC);
                    xGridView.Columns.Add(bandColumn);
                    #endregion

                    #region danh sach cot tai khoan ghi no
                    bandColumn = new GridViewBandColumn("Ghi Có TK " + FAD.Code + " ghi Nợ các tài khoản");

                    GridViewBandColumn band_Column;
                    foreach (DataColumn dc in DT_Credit151(FinancialAccountDimId, OwnerOrgDimId, MonthDimId, YearDimId).Columns)
                    {
                        switch (dc.ColumnName.Substring(0, 3))
                        {
                        case "152":
                            band_Column = new GridViewBandColumn(dc.ColumnName);
                            GVTC        = new GridViewDataTextColumn {
                                FieldName = "GTT", Caption = "Giá TT"
                            };
                            GVTC.PropertiesEdit.DisplayFormatString = "#,#";
                            band_Column.Columns.Add(GVTC);
                            GVTC = new GridViewDataTextColumn {
                                FieldName = "GHT", Caption = "Giá HT"
                            };
                            GVTC.PropertiesEdit.DisplayFormatString = "#,#";
                            band_Column.Columns.Add(GVTC);
                            bandColumn.Columns.Add(band_Column);
                            break;

                        case "153":
                            band_Column = new GridViewBandColumn(dc.ColumnName);
                            GVTC        = new GridViewDataTextColumn {
                                FieldName = "GTT", Caption = "Giá TT"
                            };
                            GVTC.PropertiesEdit.DisplayFormatString = "#,#";
                            band_Column.Columns.Add(GVTC);
                            GVTC = new GridViewDataTextColumn {
                                FieldName = "GHT", Caption = "Giá HT"
                            };
                            GVTC.PropertiesEdit.DisplayFormatString = "#,#";
                            band_Column.Columns.Add(GVTC);
                            bandColumn.Columns.Add(band_Column);
                            break;

                        default:
                            if (!dc.ColumnName.Equals("NAAN_DEFAULT"))
                            {
                                GVTC = new GridViewDataTextColumn {
                                    FieldName = dc.ColumnName
                                };
                                GVTC.PropertiesEdit.DisplayFormatString = "#,#";
                                bandColumn.Columns.Add(GVTC);
                            }
                            break;
                        }
                    }

                    GVTC = new GridViewDataTextColumn {
                        FieldName = "congco", Caption = "Cộng Có Tk " + FAD.Code
                    };
                    GVTC.PropertiesEdit.DisplayFormatString = "#,#";
                    bandColumn.Columns.Add(GVTC);
                    xGridView.Columns.Add(bandColumn);
                    #endregion

                    GVTC = new GridViewDataTextColumn {
                        FieldName = "EndBalance", Caption = "Số dư cuối tháng"
                    };
                    GVTC.PropertiesEdit.DisplayFormatString = "#,#";
                    xGridView.Columns.Add(GVTC);
                }
            }
            catch (Exception) { throw; }
        }
示例#4
0
        public void load_data()
        {
            WebModule.Accounting.Report.S04b4_DN s04b4_dn = new Report.S04b4_DN();

            #region tham số truyền
            int    month = Int32.Parse(this.hS04b4DN_month.Get("month_id").ToString());
            int    year  = Int32.Parse(this.hS04b4DN_year.Get("year_id").ToString());
            string owner = "QUASAPHARCO";
            //string asset = "";
            #endregion
            s04b4_dn.xrMonth.Text = month.ToString();
            s04b4_dn.xrYear.Text  = year.ToString();

            #region object
            MonthDim    md  = session.FindObject <MonthDim>(CriteriaOperator.Parse(String.Format("Name='{0}'", month)));
            YearDim     yd  = session.FindObject <YearDim>(CriteriaOperator.Parse(String.Format("Name='{0}'", year)));
            OwnerOrgDim ood = session.FindObject <OwnerOrgDim>(CriteriaOperator.Parse(String.Format("Code='{0}'",
                                                                                                    owner)));
            int CorrespondFinancialAccountDimId_default = CorrespondFinancialAccountDim.GetDefault(session,
                                                                                                   CorrespondFinancialAccountDimEnum.NAAN_DEFAULT).CorrespondFinancialAccountDimId;
            FinancialSalesOrManufactureExpenseSummary_Fact FinancialFact_General = null;
            #endregion

            #region header và table báo cáo
            grid_header();
            DataTable datatable = table_pri();
            #endregion

            #region all row
            List <string> all_row_f_c = new List <string>();
            if (md != null && yd != null && ood != null)
            {
                // chung
                FinancialFact_General =
                    session.FindObject <FinancialSalesOrManufactureExpenseSummary_Fact>(
                        CriteriaOperator.Parse(String.Format("MonthDimId='{0}' AND YearDimId='{1}' AND "
                                                             + "OwnerOrgDimId='{2}' AND RowStatus='1'",
                                                             md.MonthDimId,
                                                             yd.YearDimId,
                                                             ood.OwnerOrgDimId)));
                // f & c
                all_row_f_c.AddRange(support_find_row_TK(FinancialFact_General, "154"));
                all_row_f_c.AddRange(support_find_row_TK(FinancialFact_General, "621"));
                all_row_f_c.AddRange(support_find_row_TK(FinancialFact_General, "622"));
                all_row_f_c.AddRange(support_find_row_TK(FinancialFact_General, "623"));
                all_row_f_c.AddRange(support_find_row_TK(FinancialFact_General, "627"));
                all_row_f_c.AddRange(support_find_row_TK(FinancialFact_General, "631"));
                //
            }
            #endregion

            #region đổ dữ liệu



            int STTu = 1;
            // từng dòng
            foreach (string each_row in all_row_f_c)
            {
                #region
                FinancialAccountDim fFinancialAccountDim = session.FindObject <FinancialAccountDim>(
                    CriteriaOperator.Parse(String.Format("Code='{0}'", each_row.Substring(0, 3))));
                //
                DataRow dr = datatable.NewRow();
                if (each_row == "154" || each_row == "621" || each_row == "622" || each_row == "623" ||
                    each_row == "627" || each_row == "631")
                {
                    dr["stt"] = STTu++;
                }

                FinancialAccountDim get_Description = session.FindObject <FinancialAccountDim>(
                    CriteriaOperator.Parse(String.Format("Code='{0}'", each_row)));
                if (each_row == "154" || each_row == "621" || each_row == "622" || each_row == "623" ||
                    each_row == "627" || each_row == "631")
                {
                    dr["tk_no"] = String.Format("TK {0} - {1}", each_row, get_Description.Description);
                }
                else
                {
                    dr["tk_no"] = get_Description.Description;
                }
                #endregion
                double sum_CPTT = 0;
                // từng cột
                foreach (string each_column in list_header())
                {
                    #region
                    int TK_column_CorrespondFinancialAccountDimId = session.FindObject <CorrespondFinancialAccountDim>(
                        CriteriaOperator.Parse(String.Format("Code='{0}'", each_column))).CorrespondFinancialAccountDimId;
                    ////
                    if (md != null && yd != null && ood != null)
                    {
                        // only
                        FinancialFact_General =
                            session.FindObject <FinancialSalesOrManufactureExpenseSummary_Fact>(
                                CriteriaOperator.Parse(String.Format("MonthDimId='{0}' AND YearDimId='{1}' AND "
                                                                     + "OwnerOrgDimId='{2}' AND RowStatus='1'",
                                                                     md.MonthDimId,
                                                                     yd.YearDimId,
                                                                     ood.OwnerOrgDimId)));



                        if (FinancialFact_General != null && fFinancialAccountDim != null)
                        {
                            SalesOrManufactureExpenseByGroup SalesByGroup = session.FindObject <
                                SalesOrManufactureExpenseByGroup>(CriteriaOperator.Parse(
                                                                      String.Format("FinancialSalesOrManufactureExpenseSummary_FactId='{0}' AND "
                                                                                    + "FinancialAccountDimId='{1}' AND RowStatus='1'",
                                                                                    FinancialFact_General.FinancialSalesOrManufactureExpenseSummary_FactId,
                                                                                    fFinancialAccountDim.FinancialAccountDimId
                                                                                    )));
                            if (SalesByGroup != null)
                            {
                                //tìm tập hợp của tài khoản cha, con với từng tk header
                                XPCollection <FinancialSalesOrManufactureExpenseDetail> all_detail =
                                    new XPCollection <FinancialSalesOrManufactureExpenseDetail>(session,
                                                                                                CriteriaOperator.Parse(String.Format("SalesOrManufactureExpenseByGroupId='{0}' AND "
                                                                                                                                     + "CorrespondFinancialAccountDimId='{1}' AND "
                                                                                                                                     + "Credit>0 AND "
                                                                                                                                     + "RowStatus='1'",
                                                                                                                                     SalesByGroup.SalesOrManufactureExpenseByGroupId,
                                                                                                                                     TK_column_CorrespondFinancialAccountDimId
                                                                                                                                     )));
                                if (all_detail.Count != 0)
                                {
                                    if (each_row == "154" || each_row == "621" || each_row == "622" || each_row == "623" ||
                                        each_row == "627" || each_row == "631")
                                    {
                                        double sum_fFinancialAccountDim = 0;
                                        foreach (FinancialSalesOrManufactureExpenseDetail each_detail in all_detail)
                                        {
                                            // tổng
                                            sum_fFinancialAccountDim += (double)each_detail.Credit;
                                            //chi phí thực tế
                                            sum_CPTT += (double)each_detail.Credit;
                                        }
                                        dr[each_column] = sum_fFinancialAccountDim;
                                    }
                                    else
                                    {
                                        double cell = 0;
                                        foreach (FinancialSalesOrManufactureExpenseDetail each_detail in all_detail)
                                        {
                                            if (each_row == each_detail.FinancialAccountDimId.Code)
                                            {
                                                cell += (double)each_detail.Credit;
                                                //chi phí thực tế
                                                sum_CPTT += (double)each_detail.Credit;
                                            }
                                        }
                                        dr[each_column] = cell;
                                    }
                                }

                                if (each_row == "154" || each_row == "621" || each_row == "622" || each_row == "623" ||
                                    each_row == "627" || each_row == "631")
                                {
                                    dr["cong_tt"] = SalesByGroup.SumExpense;
                                }
                                else
                                {
                                    dr["cong_tt"] = sum_CPTT;
                                }
                            }
                        }
                    }
                    ////
                    #endregion
                }
                datatable.Rows.Add(dr);
            }



            #endregion

            #region dòng cộng
            DataRow dr_c = datatable.NewRow();
            dr_c["tk_no"] = "CỘNG";
            List <string> all_column = list_header();
            all_column.Add("cong_tt");
            foreach (string each_column in all_column)
            {
                double sum = 0;
                try
                {
                    sum += (from DataRow dr1 in datatable.Rows where dr1["stt"].Equals("1") select(double) dr1[each_column]).FirstOrDefault();
                }
                catch { }
                try
                {
                    sum += (from DataRow dr1 in datatable.Rows where dr1["stt"].Equals("2") select(double) dr1[each_column]).FirstOrDefault();
                }
                catch
                { }
                try
                {
                    sum += (from DataRow dr1 in datatable.Rows where dr1["stt"].Equals("3") select(double) dr1[each_column]).FirstOrDefault();
                }
                catch
                { }
                try
                {
                    sum += (from DataRow dr1 in datatable.Rows where dr1["stt"].Equals("4") select(double) dr1[each_column]).FirstOrDefault();
                }
                catch
                { }
                try
                {
                    sum += (from DataRow dr1 in datatable.Rows where dr1["stt"].Equals("5") select(double) dr1[each_column]).FirstOrDefault();
                }
                catch
                { }
                try
                {
                    sum += (from DataRow dr1 in datatable.Rows where dr1["stt"].Equals("6") select(double) dr1[each_column]).FirstOrDefault();
                }
                catch
                { }
                dr_c[each_column] = sum;
            }
            datatable.Rows.Add(dr_c);
            #endregion

            #region out gridview
            GridView_S04b4DN.DataSource = datatable;
            GridView_S04b4DN.DataBind();
            #endregion

            #region export report
            s04b4_dn.printableCC_S04b4DN.PrintableComponent = new PrintableComponentLinkBase()
            {
                Component = GridViewExporter_S04b4DN
            };
            ReportViewer_S04b4DN.Report = s04b4_dn;
            #endregion
        }
示例#5
0
        private double SumAcc(Session session, string CorrANDFnanicialACC, int FinancialTransactionDimId, int DiaryJournal_FactId, bool CreditOrDebit)
        {
            double sum = 0;

            if (!CorrANDFnanicialACC.Equals("311") ||
                !CorrANDFnanicialACC.Equals("315") ||
                !CorrANDFnanicialACC.Equals("341") ||
                !CorrANDFnanicialACC.Equals("342") ||
                !CorrANDFnanicialACC.Equals("343"))
            {
                CorrespondFinancialAccountDim corr = BO.get_CorrespondFinancialAccountDim(session, CorrANDFnanicialACC, Utility.Constant.ROWSTATUS_ACTIVE);
                if (corr != null)
                {
                    if (corr != null)
                    {
                        XPCollection <DiaryJournal_Detail> DJD = BO.get_Xp_DiaryJournal_Detail_6(session, corr.CorrespondFinancialAccountDimId, FinancialTransactionDimId, DiaryJournal_FactId);
                        if (DJD != null)
                        {
                            foreach (DiaryJournal_Detail djd in DJD)
                            {
                                if (CreditOrDebit == true && djd.Credit > 0)
                                {
                                    sum += djd.Credit;
                                }
                                else if (CreditOrDebit == false && djd.Debit > 0)
                                {
                                    sum += djd.Debit;
                                }
                            }
                        }
                    }
                }
            }
            if (CorrANDFnanicialACC.Equals("311") ||
                CorrANDFnanicialACC.Equals("315") ||
                CorrANDFnanicialACC.Equals("341") ||
                CorrANDFnanicialACC.Equals("342") ||
                CorrANDFnanicialACC.Equals("343"))
            {
                FinancialAccountDim FAD = BO.get_FinancialAccountDim(session, CorrANDFnanicialACC, Utility.Constant.ROWSTATUS_ACTIVE);

                {
                    XPCollection <DiaryJournal_Detail> DJD = BO.get_Xp_DiaryJournal_Detail_5(session, FAD.FinancialAccountDimId, FinancialTransactionDimId, DiaryJournal_FactId);
                    if (DJD != null)
                    {
                        foreach (DiaryJournal_Detail djd in DJD)
                        {
                            if (CreditOrDebit == true && djd.Credit > 0)
                            {
                                sum += djd.Credit;
                            }
                            else if (CreditOrDebit == false && djd.Debit > 0)
                            {
                                sum += djd.Debit;
                            }
                        }
                    }
                }
            }

            return(sum);
        }
示例#6
0
        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;
            }
        }
示例#7
0
        public void load_data()
        {
            WebModule.Accounting.Report.S04a4_DN S04a4_DN = new WebModule.Accounting.Report.S04a4_DN();
            try
            {
                #region parametter
                string account = this.hS04a4dnAcc.Get("account_id").ToString();
                int    month   = Int32.Parse(this.hS04a4dnMonth.Get("month_id").ToString());
                int    year    = Int32.Parse(this.hS04a4dnYear.Get("year_id").ToString());
                string owner   = this.hS04a4dnOwnerOrg.Get("owner_id").ToString();
                string asset   = "VND";//chua su dung gia tri nay neu co t

                int lastmonth = 0;
                int lastyear  = year;

                if (month == 1)
                {
                    lastmonth = 12;
                    lastyear  = year - 1;
                }
                else
                {
                    lastmonth = month - 1;
                }

                #endregion

                #region get Value
                FinancialAccountDim FAD = BO.get_FinancialAccountDim(session, account, Utility.Constant.ROWSTATUS_ACTIVE);

                MonthDim MD = BO.get_MonthDimId(session, month.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                YearDim YD = BO.get_YearDimId(session, year.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                //OwnerOrgDim OOD = BO.get_OwnerOrgDimId(session, owner, Utility.Constant.ROWSTATUS_ACTIVE);
                #endregion
                if (FAD == null || MD == null || YD == null)  //|| OOD == null)
                {
                    return;
                }
                #region gan label
                S04a4_DN.lbl_month.Text = month.ToString();
                S04a4_DN.lbl_year.Text  = year.ToString();
                S04a4_DN.lbl_tk.Text    = "Ghi Có các tài khoản " + account;
                //DiaryJournal_Fact djf = BO.get_DiaryJournal_Fact_1(session, FAD.FinancialAccountDimId, OOD.OwnerOrgDimId, MD.MonthDimId, YD.YearDimId);
                //if (djf != null && djf.BeginCreditBalance > 0) { S04a4_DN.lbl_BeginCreditBalance.Text = djf.BeginCreditBalance.ToString("#,#"); } else { S04a4_DN.lbl_BeginCreditBalance.Text = djf.BeginCreditBalance.ToString(); }
                //if (djf != null && djf.EndCreditBalance > 0) { S04a4_DN.lbl_EndCreditBalance.Text = djf.EndCreditBalance.ToString("#,#"); } else { S04a4_DN.lbl_EndCreditBalance.Text = djf.EndCreditBalance.ToString(); }

                double beginBalance = 0;
                double endBalance   = 0;

                #region begin balance
                string sql = "" +
                             "select sum(beginbalance) as beginbalance " +
                             "from " +
                             "(select distinct d.IssueDate, -b.Credit as beginbalance, e.Code, d.FinancialTransactionDimId " +
                             "from DiaryJournal_Fact a, " +
                             "DiaryJournal_Detail b, " +
                             "FinancialAccountDim c, " +
                             "FinancialTransactionDim d, " +
                             "CorrespondFinancialAccountDim e " +
                             "where a.DiaryJournal_FactId = b.DiaryJournal_FactId " +
                             "and a.FinancialAccountDimId = c.FinancialAccountDimId " +
                             "and b.FinancialTransactionDimId = d.FinancialTransactionDimId " +
                             "and b.CorrespondFinancialAccountDimId = e.CorrespondFinancialAccountDimId " +
                             "and c.Code like '" + account + "%' " +
                             "and (month(d.IssueDate) <= " + lastmonth.ToString() + " and year(d.IssueDate) =  " + lastyear.ToString() + " ) " +
                             "and (b.Credit > 0) " +
                             "and (len(e.Code) > 0 and e.Code != 'NAAN_DEFAULT')" +
                             "and (b.FinancialAccountDimId is null) " +
                             "and e.Code not in ('1','2','3','4','5','6','7','8') " +
                             "union all " +
                             "select distinct d.IssueDate, b.Debit as beginbalance, e.Name, d.FinancialTransactionDimId " +
                             "from DiaryJournal_Fact a, " +
                             "DiaryJournal_Detail b, " +
                             "FinancialAccountDim c, " +
                             "FinancialTransactionDim d, " +
                             "CorrespondFinancialAccountDim e " +
                             "where a.DiaryJournal_FactId = b.DiaryJournal_FactId " +
                             "and a.FinancialAccountDimId = c.FinancialAccountDimId " +
                             "and b.FinancialTransactionDimId = d.FinancialTransactionDimId " +
                             "and b.CorrespondFinancialAccountDimId = e.CorrespondFinancialAccountDimId " +
                             "and c.Code like '" + account + "%' " +
                             "and (month(d.IssueDate) <= " + lastmonth.ToString() + " and year(d.IssueDate) =  " + lastyear.ToString() + " ) " +
                             "and (b.Debit > 0) " +
                             "and (len(e.Code) > 0 and e.Code != 'NAAN_DEFAULT')" +
                             "and (b.FinancialAccountDimId is null) " +
                             "and e.Code not in ('1','2','3','4','5','6','7','8') " +
                             "union all " +
                             "select null as IssueDate, b.Debit as beginbalance, null as Name, null as FinancialTransactionDimId " +
                             "from BalanceForwardTransaction a, GeneralJournal b, " +
                             "Account c, AccountingPeriod d, [Transaction] e " +
                             "where a.TransactionId = b.TransactionId " +
                             "and b.AccountId = c.AccountId " +
                             "and a.TransactionId = e.TransactionId " +
                             "and d.AccountingPeriodId = e.AccountingPeriodId " +
                             "and b.Debit > 0 " +
                             "and c.Code like '" + account + "%' " +
                             "and (month(d.FromDateTime) = 1" + " and year(d.FromDateTime) = " + year.ToString() + ") " +
                             ") aa ";

                SelectedData seletectedData = session.ExecuteQuery(sql);

                foreach (var row in seletectedData.ResultSet)
                {
                    foreach (var col in row.Rows)
                    {
                        if (col.Values[0] != null)
                        {
                            S04a4_DN.lbl_BeginCreditBalance.Text = String.Format("{0:#,#}", col.Values[0]);
                        }
                    }
                }
                #endregion
                #region endBalance
                sql = "" +
                      "select sum(beginbalance) as beginbalance " +
                      "from " +
                      "(select distinct d.IssueDate, -b.Credit as beginbalance, e.Code, d.FinancialTransactionDimId " +
                      "from DiaryJournal_Fact a, " +
                      "DiaryJournal_Detail b, " +
                      "FinancialAccountDim c, " +
                      "FinancialTransactionDim d, " +
                      "CorrespondFinancialAccountDim e " +
                      "where a.DiaryJournal_FactId = b.DiaryJournal_FactId " +
                      "and a.FinancialAccountDimId = c.FinancialAccountDimId " +
                      "and b.FinancialTransactionDimId = d.FinancialTransactionDimId " +
                      "and b.CorrespondFinancialAccountDimId = e.CorrespondFinancialAccountDimId " +
                      "and c.Code like '" + account + "%' " +
                      "and (month(d.IssueDate) <= " + month.ToString() + " and year(d.IssueDate) =  " + year.ToString() + " ) " +
                      "and (b.Credit > 0) " +
                      "and (len(e.Code) > 0 and e.Code != 'NAAN_DEFAULT')" +
                      "and (b.FinancialAccountDimId is null) " +
                      "and e.Code not in ('1','2','3','4','5','6','7','8') " +
                      "union all " +
                      "select distinct d.IssueDate, b.Debit as beginbalance, e.Name, d.FinancialTransactionDimId " +
                      "from DiaryJournal_Fact a, " +
                      "DiaryJournal_Detail b, " +
                      "FinancialAccountDim c, " +
                      "FinancialTransactionDim d, " +
                      "CorrespondFinancialAccountDim e " +
                      "where a.DiaryJournal_FactId = b.DiaryJournal_FactId " +
                      "and a.FinancialAccountDimId = c.FinancialAccountDimId " +
                      "and b.FinancialTransactionDimId = d.FinancialTransactionDimId " +
                      "and b.CorrespondFinancialAccountDimId = e.CorrespondFinancialAccountDimId " +
                      "and c.Code like '" + account + "%' " +
                      "and (month(d.IssueDate) <= " + month.ToString() + " and year(d.IssueDate) =  " + year.ToString() + " ) " +
                      "and (b.Debit > 0) " +
                      "and (len(e.Code) > 0 and e.Code != 'NAAN_DEFAULT')" +
                      "and (b.FinancialAccountDimId is null) " +
                      "and e.Code not in ('1','2','3','4','5','6','7','8') " +
                      "union all " +
                      "select null as IssueDate, b.Debit as beginbalance, null as Name, null as FinancialTransactionDimId " +
                      "from BalanceForwardTransaction a, GeneralJournal b, " +
                      "Account c, AccountingPeriod d, [Transaction] e " +
                      "where a.TransactionId = b.TransactionId " +
                      "and b.AccountId = c.AccountId " +
                      "and a.TransactionId = e.TransactionId " +
                      "and d.AccountingPeriodId = e.AccountingPeriodId " +
                      "and b.Debit > 0 " +
                      "and c.Code like '" + account + "%' " +
                      "and (month(d.FromDateTime) = 1" + " and year(d.FromDateTime) = " + year.ToString() + ") " +
                      ") aa ";

                seletectedData = session.ExecuteQuery(sql);

                foreach (var row in seletectedData.ResultSet)
                {
                    foreach (var col in row.Rows)
                    {
                        if (col.Values[0] != null)
                        {
                            S04a4_DN.lbl_EndCreditBalance.Text = String.Format("{0:#,#}", col.Values[0]);
                        }
                    }
                }
                #endregion

                #endregion

                #region GridView header và table báo cáo
                GridView_header(FAD.FinancialAccountDimId, MD.MonthDimId, YD.YearDimId);          //, OOD.OwnerOrgDimId
                DataTable dt = DT_Header(FAD.FinancialAccountDimId, MD.MonthDimId, YD.YearDimId); //, OOD.OwnerOrgDimId
                #endregion

                #region tao dong STT ngang cho tung cot
                DT_STT(dt);
                #endregion

                #region do du lieu vao DataTable
                DT_rowgetvalue(dt, FAD.FinancialAccountDimId, MD.MonthDimId, YD.YearDimId); //, OOD.OwnerOrgDimId
                #endregion

                #region Binđât vao Gridview
                xGridView.DataSource = dt;
                xGridView.DataBind();
                #endregion
            }
            catch { }

            #region xuat report
            GridViewExporter.GridViewID         = "xGridView";
            S04a4_DN.pccData.PrintableComponent = new PrintableComponentLinkBase()
            {
                Component = GridViewExporter
            };
            S04a4dnReportViewer.Report = S04a4_DN;
            #endregion
        }
示例#8
0
        public DataTable DT_getvalue(int FinancialAccountDimId, int MonthDimId, int YearDimId) //, int OwnerOrgDimId
        {
            try
            {
                double stt = 1;
                FinancialAccountDim fad       = BO.get_FinancialAccountDim_1(session, FinancialAccountDimId, Utility.Constant.ROWSTATUS_ACTIVE);
                DataTable           dt        = DT_Header(FinancialAccountDimId, MonthDimId, YearDimId);              //, OwnerOrgDimId
                DataTable           dt_xp_all = DT_Xp_all(FinancialAccountDimId, MonthDimId, YearDimId, true, false); //, OwnerOrgDimId

                if (dt_xp_all != null && dt != null)
                {
                    foreach (DataColumn dc_all in dt_xp_all.Columns)
                    {
                        DataTable DT_xp_ft = DT_xp_FT(FinancialAccountDimId, int.Parse(dc_all.ColumnName.ToString()));


                        if (DT_xp_ft != null)
                        {
                            foreach (DataColumn dtxpft in DT_xp_ft.Columns)
                            {
                                XPCollection <DiaryJournal_Detail> DJD_FT = BO.get_xp_DiaryJournal_Detail_4(session, int.Parse(dtxpft.ColumnName.ToString()), int.Parse(dc_all.ColumnName.ToString()));
                                if (DJD_FT != null)
                                {
                                    DataRow dr = dt.NewRow();
                                    foreach (DataColumn dc in dt.Columns)
                                    {
                                        int flagACC = 0;
                                        foreach (DiaryJournal_Detail DJD in DJD_FT)
                                        {
                                            #region ghi tk no 331
                                            if (dc.ColumnName.Equals("STT"))
                                            {
                                                dr[dc.ColumnName] = stt;
                                            }
                                            if (dc.ColumnName.Equals("sohieu"))
                                            {
                                                if (DJD.Credit > 0 && DJD.FinancialAccountDimId != null)
                                                {
                                                    dr[dc.ColumnName] = DJD.FinancialTransactionDimId.Name;
                                                }
                                            }
                                            if (dc.ColumnName.Equals("ngaythang"))
                                            {
                                                if (DJD.Credit > 0 && DJD.FinancialAccountDimId != null)
                                                {
                                                    dr[dc.ColumnName] = String.Format("{0:d}", DJD.FinancialTransactionDimId.IssueDate);
                                                }
                                            }
                                            if (dc.ColumnName.Equals("diengiai"))
                                            {
                                                if (DJD.Credit > 0 && DJD.FinancialAccountDimId != null)
                                                {
                                                    dr[dc.ColumnName] = DJD.FinancialTransactionDimId.Description;
                                                }
                                            }
                                            try
                                            {
                                                { if (dc.ColumnName.Equals(DJD.CorrespondFinancialAccountDimId.Code))
                                                  {
                                                      if (DJD.Debit > 0 && DJD.CorrespondFinancialAccountDimId != null)
                                                      {
                                                          dr[dc.ColumnName] = SumAcc(session, DJD.CorrespondFinancialAccountDimId.Code, DJD.FinancialTransactionDimId.FinancialTransactionDimId, DJD.DiaryJournal_FactId.DiaryJournal_FactId, false);
                                                      }
                                                      flagACC++;
                                                  }
                                                }
                                            }
                                            catch { }
                                            if (dc.ColumnName.Equals("congco"))
                                            {
                                                if (DJD.Credit > 0 && DJD.CorrespondFinancialAccountDimId == null)
                                                {
                                                    dr[dc.ColumnName] = SumAcc(session, fad.Code, DJD.FinancialTransactionDimId.FinancialTransactionDimId, DJD.DiaryJournal_FactId.DiaryJournal_FactId, true);
                                                }
                                            }
                                            #endregion

                                            #region ghi tk co 331
                                            if (dc.ColumnName.Equals("STT_L"))
                                            {
                                                dr[dc.ColumnName] = stt;
                                            }
                                            if (dc.ColumnName.Equals("sohieu_L"))
                                            {
                                                if (DJD.Debit > 0 && DJD.FinancialAccountDimId != null)
                                                {
                                                    dr[dc.ColumnName] = DJD.FinancialTransactionDimId.Name;
                                                }
                                            }
                                            if (dc.ColumnName.Equals("ngaythang_L"))
                                            {
                                                if (DJD.Debit > 0 && DJD.FinancialAccountDimId != null)
                                                {
                                                    dr[dc.ColumnName] = String.Format("{0:d}", DJD.FinancialTransactionDimId.IssueDate);
                                                }
                                            }
                                            try
                                            {
                                                if (dc.ColumnName.ToString().Replace("_L", "").Equals(DJD.CorrespondFinancialAccountDimId.Code))
                                                {
                                                    int flag = 0;
                                                    XPCollection <DiaryJournal_Detail> DJD_xp = BO.get_Xp_DiaryJournal_Detail_7(session, DJD.CorrespondFinancialAccountDimId.CorrespondFinancialAccountDimId, DJD.DiaryJournal_FactId.DiaryJournal_FactId);
                                                    if (DJD_xp != null)
                                                    {
                                                        if (DJD_xp.Count > 1)
                                                        {
                                                            foreach (DiaryJournal_Detail djd in DJD_xp)
                                                            {
                                                                flag++;
                                                            }
                                                        }

                                                        if (DJD.Credit > 0 && DJD.CorrespondFinancialAccountDimId != null && flag > 1)
                                                        {
                                                            for (int b = 1; b <= flag; b++)
                                                            {
                                                                if (b > 1 && flagACC == 0)
                                                                {
                                                                    dr[dc.ColumnName] = SumAcc(session, DJD.CorrespondFinancialAccountDimId.Code, DJD.FinancialTransactionDimId.FinancialTransactionDimId, DJD.DiaryJournal_FactId.DiaryJournal_FactId, true);
                                                                }
                                                            }
                                                        }

                                                        if (DJD_xp.Count == 1 && DJD.Credit > 0 && DJD.CorrespondFinancialAccountDimId != null)
                                                        {
                                                            dr[dc.ColumnName] = SumAcc(session, DJD.CorrespondFinancialAccountDimId.Code, DJD.FinancialTransactionDimId.FinancialTransactionDimId, DJD.DiaryJournal_FactId.DiaryJournal_FactId, true);
                                                        }
                                                    }
                                                }
                                            }
                                            catch { }
                                            if (dc.ColumnName.Equals("congno"))
                                            {
                                                if (DJD.Debit > 0 && DJD.CorrespondFinancialAccountDimId == null)
                                                {
                                                    dr[dc.ColumnName] = SumAcc(session, fad.Code, DJD.FinancialTransactionDimId.FinancialTransactionDimId, DJD.DiaryJournal_FactId.DiaryJournal_FactId, false);
                                                }
                                            }
                                            #endregion
                                        }
                                    }
                                    dt.Rows.Add(dr);
                                    stt++;
                                }
                            }
                        }
                    }
                }
                return(dt);
            }
            catch (Exception) { return(null); }
        }
        public void CreateFinancialSalesOrManufacturerExpenseDetail(
            Session session,
            ETL_SalesOrManufacturerExpenseDetail Detail,
            string MainAccountCode, string HighestAccountCode)
        {
            try
            {
                if (Detail == null ||
                    MainAccountCode.Equals(string.Empty) ||
                    Detail.OwnerOrgId.Equals(Guid.Empty) ||
                    Detail.IssueDate == null)
                {
                    return;
                }

                #region prepare Summary header data
                Util            util         = new Util();
                ETLAccountingBO accountingBO = new ETLAccountingBO();
                FinancialSalesOrManufactureExpenseSummary_Fact summary =
                    GetFinancialSalesOrManufactureExpenseSummary(
                        session,
                        Detail.OwnerOrgId,
                        Detail.IssueDate);

                FinancialSalesOrManufactureExpenseDetail newDetail = new FinancialSalesOrManufactureExpenseDetail(session);
                if (summary == null)
                {
                    summary =
                        CreateFinancialSalesOrManufactureExpenseSummary(
                            session,
                            Detail.OwnerOrgId,
                            Detail.IssueDate,
                            Detail.IsBalanceForward);
                    if (summary == null)
                    {
                        return;
                    }
                }
                #endregion

                #region prepare group data
                CorrespondFinancialAccountDim correspondFinancialAccountDim = null;
                FinancialAccountDim           financialAccountDim           = null;
                FinancialAccountDim           GroupAccountDim = null;

                if (!HighestAccountCode.Equals(string.Empty))
                {
                    GroupAccountDim = util.GetXpoObjectByFieldName <FinancialAccountDim, string>(
                        session,
                        "Code",
                        HighestAccountCode,
                        BinaryOperatorType.Equal);
                }

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

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

                if (GroupAccountDim == null && !HighestAccountCode.Equals(string.Empty))
                {
                    GroupAccountDim = accountingBO.CreateFinancialAccountDim(session, HighestAccountCode);
                }


                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);
                }

                SalesOrManufactureExpenseByGroup group =
                    GetSalesOrManufactureExpenseByGroup(
                        session,
                        summary.FinancialSalesOrManufactureExpenseSummary_FactId,
                        HighestAccountCode);

                if (group == null)
                {
                    group = CreateSalesOrManufactureExpenseByGroup(
                        session,
                        summary.FinancialSalesOrManufactureExpenseSummary_FactId,
                        HighestAccountCode);

                    if (group == null)
                    {
                        return;
                    }
                }

                #endregion

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

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

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

                if (financialTransactionDim == null)
                {
                    financialTransactionDim = accountingBO.CreateFinancialTransactionDim(session, Detail.TransactionId);
                    if (financialTransactionDim == null)
                    {
                        return;
                    }
                }
                newDetail.Credit                             = Detail.Credit;
                newDetail.Debit                              = Detail.Debit;
                newDetail.CurrencyDimId                      = currencyDim;
                newDetail.FinancialTransactionDimId          = financialTransactionDim;
                newDetail.FinancialAccountDimId              = financialAccountDim;
                newDetail.CorrespondFinancialAccountDimId    = correspondFinancialAccountDim;
                newDetail.SalesOrManufactureExpenseByGroupId = group;
                CorrespondFinancialAccountDim defaultCorrespondindAcc = CorrespondFinancialAccountDim.GetDefault(session, CorrespondFinancialAccountDimEnum.NAAN_DEFAULT);
                FinancialAccountDim           defaultFinancialAcc     = FinancialAccountDim.GetDefault(session, FinancialAccountDimEnum.NAAN_DEFAULT);

                if (newDetail.FinancialAccountDimId == null)
                {
                    newDetail.FinancialAccountDimId = defaultFinancialAcc;
                }
                if (newDetail.CorrespondFinancialAccountDimId == null)
                {
                    newDetail.CorrespondFinancialAccountDimId = defaultCorrespondindAcc;
                }

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

                if (Detail.IsBalanceForward)
                {
                    group.SumExpense = Detail.Credit;
                }
                else
                {
                    group.SumExpense = group.FinancialSalesOrManufactureExpenseDetails.Where(i => i.RowStatus >= 1 && i.Debit > 0).
                                       Sum(r => r.Debit);
                    group.Save();
                }

                group.Save();
                summary.Save();
            }
            catch (Exception)
            {
                return;
            }
        }
示例#10
0
        public void GridView_header(int FinancialAccountDimId, int MonthDimId, int YearDimId)//, int OwnerOrgDimId
        {
            try
            {
                GridViewBandColumn     bandColumn = new GridViewBandColumn();
                GridViewDataTextColumn GVDTC      = new GridViewDataTextColumn();
                FinancialAccountDim    FAD        = session.GetObjectByKey <FinancialAccountDim>(FinancialAccountDimId);
                if (FAD != null)
                {
                    #region ghi Co tk 311
                    GVDTC = new GridViewDataTextColumn {
                        FieldName = "STT", Caption = "Số TT"
                    };
                    xGridView.Columns.Add(GVDTC);

                    bandColumn = new GridViewBandColumn("Chứng Từ");
                    GVDTC      = new GridViewDataTextColumn {
                        FieldName = "sohieu", Caption = "Số Hiệu"
                    };
                    bandColumn.Columns.Add(GVDTC);
                    GVDTC = new GridViewDataTextColumn {
                        FieldName = "ngaythang", Caption = "Ngày Tháng"
                    };
                    bandColumn.Columns.Add(GVDTC);
                    xGridView.Columns.Add(bandColumn);

                    GVDTC = new GridViewDataTextColumn {
                        FieldName = "diengiai", Caption = "Diễn giải"
                    };
                    xGridView.Columns.Add(GVDTC);

                    bandColumn = new GridViewBandColumn("Ghi Có TK " + FAD.Code + ", ghi Nợ các TK");
                    foreach (DataColumn dc in DT_ListAcc_CreditOrDebit(FinancialAccountDimId, MonthDimId, YearDimId, false).Columns) //, OwnerOrgDimId
                    {
                        GVDTC = new GridViewDataTextColumn {
                            FieldName = dc.ColumnName
                        };
                        GVDTC.PropertiesEdit.DisplayFormatString = "#,#";
                        bandColumn.Columns.Add(GVDTC);
                    }
                    GVDTC = new GridViewDataTextColumn {
                        FieldName = "congco", Caption = "Cộng Có TK " + FAD.Code
                    };
                    GVDTC.PropertiesEdit.DisplayFormatString = "#,#";
                    bandColumn.Columns.Add(GVDTC);
                    xGridView.Columns.Add(bandColumn);
                    #endregion

                    #region ghi No tk 311
                    GVDTC = new GridViewDataTextColumn {
                        FieldName = "STT_L", Caption = "Số TT"
                    };
                    xGridView.Columns.Add(GVDTC);

                    bandColumn = new GridViewBandColumn("Chứng Từ");
                    GVDTC      = new GridViewDataTextColumn {
                        FieldName = "sohieu_L", Caption = "Số Hiệu"
                    };
                    bandColumn.Columns.Add(GVDTC);
                    GVDTC = new GridViewDataTextColumn {
                        FieldName = "ngaythang_L", Caption = "Ngày Tháng"
                    };
                    bandColumn.Columns.Add(GVDTC);
                    xGridView.Columns.Add(bandColumn);

                    bandColumn = new GridViewBandColumn("Ghi Nợ TK " + FAD.Code + ", ghi Có các TK");
                    foreach (DataColumn dc in DT_ListAcc_CreditOrDebit(FinancialAccountDimId, MonthDimId, YearDimId, true).Columns) //, OwnerOrgDimId
                    {
                        GVDTC = new GridViewDataTextColumn {
                            FieldName = dc.ColumnName + "_L", Caption = dc.ColumnName
                        };
                        GVDTC.PropertiesEdit.DisplayFormatString = "#,#";
                        bandColumn.Columns.Add(GVDTC);
                    }
                    GVDTC = new GridViewDataTextColumn {
                        FieldName = "congno", Caption = "Cộng Nợ TK " + FAD.Code
                    };
                    GVDTC.PropertiesEdit.DisplayFormatString = "#,#";
                    bandColumn.Columns.Add(GVDTC);
                    xGridView.Columns.Add(bandColumn);
                    #endregion
                }
            }
            catch { }
        }
示例#11
0
        public void CreateFinancialSupplierLiabilityDetail(
            Session session,
            ETL_FinnancialSupplierLiabilityDetail 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();
                FinancialSupplierLiabilitySummary_Fact Fact      = GetFinnancialSupplierLiabilitySummaryFact(session, Detail.OwnerOrgId, Detail.SupplierId, Detail.IssueDate, MainAccountCode);
                FinancialSupplierLiabilityDetail       newDetail = new FinancialSupplierLiabilityDetail(session);
                if (Fact == null)
                {
                    Fact = CreateFinnancialSupplierLiabilitySummaryFact(session, Detail.OwnerOrgId, Detail.SupplierId, Detail.IssueDate, MainAccountCode, Detail.IsBalanceForward);
                    if (Fact == null)
                    {
                        return;
                    }
                }

                var date = new DateTime(Detail.IssueDate.Year, Detail.IssueDate.Month, 1);
                FinancialSupplierLiabilitySummary_Fact previousSummary = GetFinnancialSupplierLiabilitySummaryFact(session,
                                                                                                                   Detail.OwnerOrgId, Detail.SupplierId, date.AddMonths(-1), MainAccountCode);

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

                /*2014/02/22 Duc.Vo MOD START*/
                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);
                }
                /*2014/02/22 Duc.Vo MOD END*/

                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;
                    }
                }
                /*2014/02/22 Duc.Vo INS START*/
                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.FinancialSupplierLiabilitySummary_FactId = Fact;
                newDetail.FinancialTransactionDimId = financialTransactionDim;
                /*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.FinancialSupplierLiabilityDetails.Where(i => i.RowStatus == 1 &&
                                                                                  i.Credit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(d => d.Credit);

                    Fact.DebitSum = Fact.FinancialSupplierLiabilityDetails.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;
            }
        }
示例#12
0
        public void LoadData()
        {
            WebModule.Accounting.Report.S04b11_DN s04b11_dn = new WebModule.Accounting.Report.S04b11_DN();
            try
            {
                string FinancialAccountDim_Code = "131";
                int    MonthDim    = int.Parse(this.hs04b11dnMonth.Get("month_Name").ToString());
                int    YearDim     = int.Parse(this.hs04b11dnYear.Get("year_Name").ToString());
                string OwnerOrgDim = "QUASAPHARCO";

                #region get_value
                FinancialAccountDim FAD = BO.get_FinancialAccountDimId(session, FinancialAccountDim_Code, Utility.Constant.ROWSTATUS_ACTIVE);

                MonthDim MD = BO.get_MonthDimId(session, MonthDim.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                YearDim YD = BO.get_YearDimId(session, YearDim.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                OwnerOrgDim OOD = BO.get_OwnerOrgDimId(session, OwnerOrgDim, Utility.Constant.ROWSTATUS_ACTIVE);
                #endregion

                if (MD == null || YD == null || OOD == null)
                {
                    return;
                }

                if (int.Parse(MD.Name.ToString()) < 10)
                {
                    s04b11_dn.lbthang.Text = "0" + MD.Name;
                }
                s04b11_dn.lbthang.Text = MD.Name;
                s04b11_dn.lbnam.Text   = YD.Name;


                #region tao header
                gridview_header(FAD.FinancialAccountDimId, OOD.OwnerOrgDimId, MD.MonthDimId, YD.YearDimId);
                DataTable dt = DT_Header(FAD.FinancialAccountDimId, OOD.OwnerOrgDimId, MD.MonthDimId, YD.YearDimId);
                #endregion

                #region dòng STT cột
                DT_STT(dt);
                #endregion

                #region do du lieu
                DT_getRowValue(dt, FAD.FinancialAccountDimId, OOD.OwnerOrgDimId, MD.MonthDimId, YD.YearDimId);
                //DT_getvalue(FAD.FinancialAccountDimId, OOD.OwnerOrgDimId, MD.MonthDimId, YD.YearDimId);
                #endregion

                #region bind data vào gridview
                xGridView.DataSource = dt;
                xGridView.DataBind();
                #endregion
            }
            catch { }

            #region xuất report
            xGridViewExporter.GridViewID             = "xGridView";
            s04b11_dn.printableCC.PrintableComponent = new PrintableComponentLinkBase()
            {
                Component = xGridViewExporter
            };
            ReportViewerS04b11.Report = s04b11_dn;
            #endregion
        }
示例#13
0
        public void load_data()
        {
            WebModule.Accounting.Report.S11_DN s11_dn = new Report.S11_DN();

            #region tham số truyền
            int    month    = Int32.Parse(this.hS11DN_month.Get("month_id").ToString());
            int    year     = Int32.Parse(this.hS11DN_year.Get("year_id").ToString());
            string owner    = "QUASAPHARCO";
            string fAccount = this.hS11dnAccount.Get("account_id").ToString();
            //string asset = "";
            short rowstatus = Utility.Constant.ROWSTATUS_ACTIVE;
            #endregion

            #region display report
            s11_dn.xrTaiKhoan.Text = String.Format("Tài khoản: {0}", fAccount);
            s11_dn.xrTime.Text     = String.Format("Tháng {0} năm {1}", month, year);
            #endregion

            try
            {
                #region object
                MonthDim md = session.FindObject <MonthDim>(CriteriaOperator.Parse(
                                                                String.Format("Name='{0}' AND RowStatus='{1}'", month, rowstatus)));
                YearDim yd = session.FindObject <YearDim>(CriteriaOperator.Parse(
                                                              String.Format("Name='{0}' AND RowStatus='{1}'", year, rowstatus)));
                OwnerOrgDim ood = session.FindObject <OwnerOrgDim>(CriteriaOperator.Parse(
                                                                       String.Format("Code='{0}' AND RowStatus='{1}'", owner, rowstatus)));
                FinancialAccountDim accountDim = session.FindObject <FinancialAccountDim>(CriteriaOperator.Parse(
                                                                                              String.Format("Code='{0}' AND RowStatus='{1}'", fAccount, rowstatus)));
                XPCollection <FinancialItemInventorySummary_Fact> Summary_Fact;
                #endregion


                #region header và table báo cáo
                grid_header();
                DataTable datatable = table_pri();
                #endregion

                #region list hàng hóa
                List <string> items = new List <string>();
                if (md != null && yd != null && ood != null && accountDim != null)
                {
                    Summary_Fact =
                        new XPCollection <FinancialItemInventorySummary_Fact>(session, CriteriaOperator.Parse(
                                                                                  String.Format("MonthDimId='{0}' AND "
                                                                                                + "YearDimId='{1}' AND "
                                                                                                + "OwnerOrgDimId='{2}' AND "
                                                                                                + "RowStatus='{3}' AND "
                                                                                                + "FinancialAccountDimId='{4}'",
                                                                                                md.MonthDimId,
                                                                                                yd.YearDimId,
                                                                                                ood.OwnerOrgDimId,
                                                                                                rowstatus,
                                                                                                accountDim.FinancialAccountDimId
                                                                                                )));
                    if (Summary_Fact.Count != 0)
                    {
                        foreach (FinancialItemInventorySummary_Fact each_Fact in Summary_Fact)
                        {
                            if (!items.Contains(String.Format("{0}|{1}", each_Fact.ItemDimId.Code, each_Fact.UnitDimId.Code)))
                            {
                                items.Add(String.Format("{0}|{1}", each_Fact.ItemDimId.Code, each_Fact.UnitDimId.Code));
                            }
                        }
                    }
                }
                #endregion

                #region đổ dữ liệu
                DataRow dr;
                // từng dòng
                int STT = 1;
                foreach (string item in items)
                {
                    string itemCode = item.Split('|')[0];
                    string unitCode = item.Split('|')[1];

                    ItemDim itemDim = session.FindObject <ItemDim>(CriteriaOperator.Parse(
                                                                       String.Format("Code='{0}'", itemCode)));
                    UnitDim unitDim = session.FindObject <UnitDim>(CriteriaOperator.Parse(
                                                                       String.Format("Code='{0}'", unitCode)));

                    dr        = datatable.NewRow();
                    dr["stt"] = STT++;
                    dr["ten"] = String.Format("{0} ({1})", itemDim.Name, unitDim.Name);

                    if (md != null && yd != null && ood != null && itemDim != null && unitDim != null && accountDim != null)
                    {
                        Summary_Fact =
                            new XPCollection <FinancialItemInventorySummary_Fact>(session, CriteriaOperator.Parse(
                                                                                      String.Format("MonthDimId='{0}' AND "
                                                                                                    + "YearDimId='{1}' AND "
                                                                                                    + "OwnerOrgDimId='{2}' AND "
                                                                                                    + "RowStatus='{3}' AND "
                                                                                                    + "ItemDimId='{4}' AND "
                                                                                                    + "UnitDimId='{5}' AND "
                                                                                                    + "FinancialAccountDimId='{6}'",
                                                                                                    md.MonthDimId,
                                                                                                    yd.YearDimId,
                                                                                                    ood.OwnerOrgDimId,
                                                                                                    rowstatus,
                                                                                                    itemDim.ItemDimId,
                                                                                                    unitDim.UnitDimId,
                                                                                                    accountDim.FinancialAccountDimId
                                                                                                    )));
                        if (Summary_Fact.Count != 0)
                        {
                            double debit_sum = 0, credit_sum = 0, begin = 0, end = 0;
                            foreach (FinancialItemInventorySummary_Fact each_fact in Summary_Fact)
                            {
                                begin      += (double)each_fact.BeginDebitBalance;
                                debit_sum  += (double)each_fact.DebitSum;
                                credit_sum += (double)each_fact.CreditSum;
                                end        += (double)each_fact.EndDebitBalance;
                            }


                            dr["ton_dau"]  = begin;
                            dr["nhap"]     = debit_sum;
                            dr["xuat"]     = credit_sum;
                            dr["ton_cuoi"] = end;
                        }
                    }
                    datatable.Rows.Add(dr);
                }
                #endregion

                #region dòng cộng
                dr        = datatable.NewRow();
                dr["ten"] = "Cộng";

                int column_count = datatable.Columns.Count - 1;
                int row_count    = datatable.Rows.Count - 1;
                for (int c = 2; c <= column_count; c++)
                {
                    double sumT = 0;
                    for (int r = 1; r <= row_count; r++)
                    {
                        double tt;
                        double.TryParse(datatable.Rows[r][c].ToString(), out tt);
                        sumT += tt;
                    }
                    dr[datatable.Columns[c]] = sumT;
                }
                datatable.Rows.Add(dr);
                #endregion

                #region out gridview
                GridView_S11DN.DataSource = datatable;
                GridView_S11DN.DataBind();
                #endregion
            }
            catch { }

            #region export report
            s11_dn.printableCC_S11DN.PrintableComponent = new PrintableComponentLinkBase()
            {
                Component = GridViewExporter_S11DN
            };
            ReportViewer_S11DN.Report = s11_dn;
            #endregion
        }
示例#14
0
文件: S10-DN.ascx.cs 项目: ewin66/dev
        public void Load_Data()
        {
            WebModule.Accounting.Report.S10_DN s10dn = new WebModule.Accounting.Report.S10_DN();
            try
            {
                #region Parameter
                string account   = this.hs10dnAcc.Get("account_id").ToString();
                int    month     = int.Parse(this.hs10dnMonth.Get("month_id").ToString());
                int    year      = int.Parse(this.hs10dnYear.Get("year_id").ToString());
                string unitDim   = this.hs10dnUnitDim.Get("unit_id").ToString();
                string item      = this.hs10dnItem.Get("Item_id").ToString();
                string inventory = this.hs10dnInventory.Get("Inventory_id").ToString();
                string OwnerOrg  = "QUASAPHARCO";
                #endregion

                #region Select *
                FinancialAccountDim FAD = BO.get_FinancialAccountDim(session, account, Utility.Constant.ROWSTATUS_ACTIVE);

                MonthDim MD = BO.get_MonthDim(session, month.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                YearDim YD = BO.get_YearDim(session, year.ToString(), Utility.Constant.ROWSTATUS_ACTIVE);

                ItemDim ID = BO.get_ItemDim_1(session, item, Utility.Constant.ROWSTATUS_ACTIVE);

                InventoryDim InDim = BO.get_InventoryDim_1(session, inventory, Utility.Constant.ROWSTATUS_ACTIVE);

                UnitDim UD = BO.get_UnitDim(session, unitDim, Utility.Constant.ROWSTATUS_ACTIVE);

                OwnerOrgDim OOD = BO.get_OwnerOrgDim(session, OwnerOrg, Utility.Constant.ROWSTATUS_ACTIVE);

                #endregion

                #region label
                s10dn.lbl_Inventory.Text = inventory;
                s10dn.lbl_Item.Text      = item;
                s10dn.lbl_year.Text      = year.ToString();
                s10dn.lbl_account.Text   = account;
                s10dn.lbl_unitDim.Text   = unitDim;
                #endregion

                #region GridView_header vao DataTable
                GridView_header();
                DataTable dt = DT_header();
                #endregion

                if (FAD == null || MD == null || YD == null || ID == null || InDim == null || UD == null || OOD == null)
                {
                    return;
                }

                #region do du lieu vao DataTable
                DT_rowgetvalue(dt, FAD.FinancialAccountDimId, InDim.InventoryDimId, OOD.OwnerOrgDimId, ID.ItemDimId, MD.MonthDimId, YD.YearDimId, UD.UnitDimId);
                #endregion

                #region do du lieu vao DataTable
                xGridView.DataSource = dt;
                xGridView.DataBind();
                #endregion
            }
            catch { }

            #region xuat Report
            xGridViewExporter.GridViewID         = "xGridView";
            s10dn.printableCC.PrintableComponent = new PrintableComponentLinkBase()
            {
                Component = xGridViewExporter
            };
            ReportViewerS10.Report = s10dn;
            #endregion
        }
示例#15
0
        public void CreateFinancialOnTheWayBuyingGoodDetail(Session session, ETL_FinancialOnTheWayBuyingGoodDetail Detail, string MainAccountCode)
        {
            try
            {
                if (Detail == null ||
                    MainAccountCode.Equals(string.Empty) ||
                    Detail.PurchaseInvoiceId.Equals(Guid.Empty) ||
                    Detail.InputInventoryCommandId.Equals(Guid.Empty) ||
                    Detail.OwnerOrgId.Equals(Guid.Empty) ||
                    Detail.IssueDate == null)
                {
                    return;
                }

                //bool flgNewSummary = false;
                Util util = new Util();
                CorrespondFinancialAccountDim defaultCorrespondindAcc = CorrespondFinancialAccountDim.GetDefault(session, CorrespondFinancialAccountDimEnum.NAAN_DEFAULT);
                FinancialAccountDim           defaultFinancialAcc     = FinancialAccountDim.GetDefault(session, FinancialAccountDimEnum.NAAN_DEFAULT);
                ETLAccountingBO accountingBO = new ETLAccountingBO();
                FinancialOnTheWayBuyingGoodSummary summary   = GetFinancialOnTheWayBuyingGoodSummary(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode);
                FinancialOnTheWayBuyingGoodDetail  newDetail = new FinancialOnTheWayBuyingGoodDetail(session);
                if (summary == null)
                {
                    summary = CreateFinancialOnTheWayBuyingGoodSummary(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode);
                    if (summary == null)
                    {
                        return;
                    }
                }
                else
                {
                    var date = new DateTime(Detail.IssueDate.Year, Detail.IssueDate.Month, 1);
                    FinancialOnTheWayBuyingGoodSummary previousSummary = GetFinancialOnTheWayBuyingGoodSummary(session,
                                                                                                               Detail.OwnerOrgId, date.AddMonths(-1), MainAccountCode);

                    if (previousSummary != null)
                    {
                        summary.BeginBalance = previousSummary.EndBalance;
                    }
                }
                /*2014/02/22 Duc.Vo MOD START*/
                CorrespondFinancialAccountDim correspondFinancialAccountDim = null;
                FinancialAccountDim           financialAccountDim           = null;
                InventoryCommand InputCommand = null;
                NAS.DAL.Invoice.PurchaseInvoice PurchaseInvoice = 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);
                }

                if (!Detail.InputInventoryCommandId.Equals(Guid.Empty))
                {
                    InputCommand = util.GetXpoObjectByFieldName <InventoryCommand, Guid>(session, "InventoryCommandId", Detail.InputInventoryCommandId, BinaryOperatorType.Equal);
                    if (InputCommand == null)
                    {
                        return;
                    }
                }
                if (!Detail.PurchaseInvoiceId.Equals(Guid.Empty))
                {
                    PurchaseInvoice = util.GetXpoObjectByFieldName <NAS.DAL.Invoice.PurchaseInvoice, Guid>(session, "BillId", Detail.PurchaseInvoiceId, BinaryOperatorType.Equal);
                    if (PurchaseInvoice == null)
                    {
                        return;
                    }
                }

                OnTheWayBuyingGoodArtifact artifact = GetOnTheWayBuyingGoodArtifact(
                    session,
                    summary.FinancialOnTheWayBuyingGoodSummaryId,
                    PurchaseInvoice.BillId,
                    InputCommand.InventoryCommandId);

                if (artifact == null)
                {
                    artifact = CreateOnTheWayBuyingGoodArtifact(
                        session,
                        summary.FinancialOnTheWayBuyingGoodSummaryId,
                        PurchaseInvoice.BillId,
                        InputCommand.InventoryCommandId);

                    if (artifact == null)
                    {
                        return;
                    }
                }

                /*2014/02/22 Duc.Vo INS START*/
                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);
                }

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

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

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

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

                newDetail.CorrespondFinancialAccountDimId = correspondFinancialAccountDim;
                newDetail.Credit                       = Detail.Credit;
                newDetail.Debit                        = Detail.Debit;
                newDetail.ActuaPrice                   = Detail.ActualPrice;
                newDetail.BookingPrice                 = Detail.BookedPrice;
                newDetail.FinancialAccountDimId        = financialAccountDim;
                newDetail.OnTheWayBuyingGoodArtifactId = artifact;
                newDetail.FinancialTransactionDimId    = financialTransactionDim;
                newDetail.CurrencyDimId                = currencyDim;
                /*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)
                {
                    summary.BeginBalance = summary.EndBalance = (decimal)Detail.Debit;
                    summary.CreditSum    = summary.DebitSum = 0;
                }
                else
                {
                    CorrespondFinancialAccountDim defaultAccDim = CorrespondFinancialAccountDim.GetDefault(session, CorrespondFinancialAccountDimEnum.NAAN_DEFAULT);
                    summary.CreditSum = (decimal)summary.OnTheWayBuyingGoodArtifacts.SelectMany(t => t.FinancialOnTheWayBuyingGoodDetails).
                                        Where(i => i.RowStatus == 1 &&
                                              i.Credit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(i => i.Credit);

                    summary.DebitSum = (decimal)summary.OnTheWayBuyingGoodArtifacts.SelectMany(t => t.FinancialOnTheWayBuyingGoodDetails).
                                       Where(i => i.RowStatus == 1 &&
                                             i.Debit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(i => i.Debit);

                    summary.BeginBalance = summary.BeginBalance + summary.DebitSum - summary.CreditSum;
                }

                summary.Save();
            }
            catch (Exception)
            {
                return;
            }
        }