Example #1
0
        public static void LockJournalVoucher(GLJournalVouchersInfo voucher)
        {
            if (voucher.GLJournalVoucherID == Guid.Empty)
            {
                return;
            }

            voucher.LockStatus = ABCCommon.ABCConstString.LockStatusLocked;
            new GLJournalVouchersController().UpdateObject(voucher);

            GLJournalEntrysController entryCtrl = new GLJournalEntrysController();
            List <Guid> lstAccounts             = new List <Guid>();

            foreach (GLJournalEntrysInfo entry in new GLJournalEntrysController().GetListByForeignKey("FK_GLJournalVoucherID", voucher.GLJournalVoucherID))
            {
                InvalidateJournalEntry(entry, voucher);

                entry.LockStatus  = ABCCommon.ABCConstString.LockStatusLocked;
                entry.JournalDate = voucher.JournalDate;
                entryCtrl.UpdateObject(entry);

                if (lstAccounts.Contains(entry.FK_GLAccountID_Debit) == false)
                {
                    lstAccounts.Add(entry.FK_GLAccountID_Debit);
                }
                if (lstAccounts.Contains(entry.FK_GLAccountID_Credit) == false)
                {
                    lstAccounts.Add(entry.FK_GLAccountID_Credit);
                }
            }
            foreach (Guid iAccountID in lstAccounts)
            {
                AccountingProvider.CalculateAccount(iAccountID);
            }
        }
Example #2
0
        public static void ApproveJournalVoucher(GLJournalVouchersInfo voucher)
        {
            if (voucher.GLJournalVoucherID == Guid.Empty)
            {
                return;
            }

            if (voucher.ApprovalStatus == ABCCommon.ABCConstString.ApprovalTypeApproved)
            {
                if (DialogResult.No == ABCHelper.ABCMessageBox.Show("Phiếu kế toán đã được ghi sổ trước đó. Bạn có muốn ghi sổ lại không?", "Ghi sổ", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    return;
                }
            }

            voucher.ApprovalStatus = ABCCommon.ABCConstString.ApprovalTypeApproved;
            new GLJournalVouchersController().UpdateObject(voucher);

            GLJournalEntrysController entryCtrl = new GLJournalEntrysController();
            List <Guid> lstAccounts             = new List <Guid>();

            foreach (GLJournalEntrysInfo entry in entryCtrl.GetListByForeignKey("FK_GLJournalVoucherID", voucher.GLJournalVoucherID))
            {
                InvalidateJournalEntry(entry, voucher);

                entry.ApprovalStatus = ABCCommon.ABCConstString.ApprovalTypeApproved;
                entry.JournalDate    = voucher.JournalDate;
                entryCtrl.UpdateObject(entry);

                if (lstAccounts.Contains(entry.FK_GLAccountID_Debit) == false)
                {
                    lstAccounts.Add(entry.FK_GLAccountID_Debit);
                }
                if (lstAccounts.Contains(entry.FK_GLAccountID_Credit) == false)
                {
                    lstAccounts.Add(entry.FK_GLAccountID_Credit);
                }
            }
            foreach (Guid iAccountID in lstAccounts)
            {
                AccountingProvider.CalculateAccount(iAccountID);
            }
        }
Example #3
0
        public static List <GLJournalEntrysInfo> GetCreditEntrys(GLAccountsInfo accInfo, DateTime?startDate, DateTime?endDate, String strConditionQuery, bool isIncludeChildren)
        {
            String strQuery = String.Format(@"SELECT * FROM GLJournalEntrys WHERE ApprovalStatus='{0}' AND FK_GLAccountID_Credit='{1}' ", ABCCommon.ABCConstString.ApprovalTypeApproved, accInfo.GLAccountID);

            if (startDate.HasValue)
            {
                strQuery += String.Format(@" AND {0}", TimeProvider.GenCompareDateTime("JournalDate", ">=", startDate.Value));
            }
            if (endDate.HasValue)
            {
                strQuery += String.Format(@" AND {0} ", TimeProvider.GenCompareDateTime("JournalDate", "<=", endDate.Value));
            }
            if (String.IsNullOrWhiteSpace(strConditionQuery) == false)
            {
                strQuery += String.Format(@" AND {0} ", strConditionQuery);
            }

            strQuery += String.Format(@" ORDER BY JournalDate ");

            List <BusinessObject> lstResults = new GLJournalEntrysController().GetList(strQuery);

            if (isIncludeChildren)
            {
                GLAccountsController accCtrl = new GLAccountsController();
                DataSet ds = accCtrl.GetDataSetByForeignKey("FK_GLAccountID", accInfo.GLAccountID);
                if (ds != null && ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        GLAccountsInfo accChildInfo = accCtrl.GetObjectFromDataRow(dr) as GLAccountsInfo;
                        if (accChildInfo != null)
                        {
                            lstResults.AddRange(GetCreditEntrys(accChildInfo, startDate, endDate, strConditionQuery, true));
                        }
                    }
                }
            }

            return(lstResults.ConvertAll <GLJournalEntrysInfo>(delegate(BusinessObject item) { return (GLJournalEntrysInfo)item; }));
        }
Example #4
0
        public static void PostBenifitCalculation(GLBenifitCalcsInfo mainObject)
        {
            if (mainObject.FK_GEPeriodID.HasValue == false || mainObject.GLBenifitCalcID == Guid.Empty)
            {
                return;
            }

            if (AccountingProvider.GetAccountID("911") == Guid.Empty)
            {
                return;
            }

            if (mainObject.FK_GLJournalVoucherID != Guid.Empty)
            {
                new GLJournalEntrysController().RealDeleteObjectsByFK("FK_GLJournalVoucherID", mainObject.FK_GLJournalVoucherID.Value);
                Guid iID = mainObject.FK_GLJournalVoucherID.Value;
                mainObject.FK_GLJournalVoucherID = null;
                new GLBenifitCalcsController().UpdateObject(mainObject);
                new GLJournalVouchersController().RealDeleteObject(iID);
            }

            DateTime startDate = PeriodProvider.GetFirstDay(mainObject.FK_GEPeriodID.Value);
            DateTime endDate   = PeriodProvider.GetLastDay(mainObject.FK_GEPeriodID.Value);

            #region Voucher
            GLJournalVouchersController voucherCtrl = new GLJournalVouchersController();
            GLJournalVouchersInfo       voucher     = new GLJournalVouchersInfo();
            BusinessObjectHelper.CopyObject(mainObject, voucher, false);

            //voucher.FK_GLVoucherTypeID="BenifitCalc";
            voucher.ERPVoucherID        = mainObject.GLBenifitCalcID;
            voucher.ERPVoucherTableName = "GLBenifitCalcs";
            voucher.JournalDate         = endDate;

            voucher.ApprovalStatus = ABCCommon.ABCConstString.ApprovalTypeApproved;

            voucher.Remark = String.Format("Xác định kết quả kinh doanh tháng {0}/{1}", startDate.Month, startDate.Year);

            voucherCtrl.CreateObject(voucher);

            mainObject.FK_GLJournalVoucherID = voucher.GLJournalVoucherID;
            mainObject.ApprovalStatus        = ABCCommon.ABCConstString.ApprovalTypeApproved;
            new GLBenifitCalcsController().UpdateObject(mainObject);
            #endregion

            Guid Acc911ID = AccountingProvider.GetAccountID("911");

            GLJournalEntrysController  entryCtrl = new GLJournalEntrysController();
            List <GLJournalEntrysInfo> lstEntrys = new List <GLJournalEntrysInfo>();

            String strRemark = String.Format(" tháng {0}/{1}", startDate.Month, startDate.Year);


            if (AccountingProvider.GetAccountID("511") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("511"), Acc911ID, true, startDate, endDate, "", "Kết chuyển doanh thu thuần bán hàng" + strRemark));
            }
            if (AccountingProvider.GetAccountID("512") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("512"), Acc911ID, true, startDate, endDate, "", "Kết chuyển doanh thu thuần bán hàng nội bộ" + strRemark));
            }

            if (AccountingProvider.GetAccountID("632") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("632"), Acc911ID, true, startDate, endDate, "", "Kết chuyển giá vốn hàng bán" + strRemark));
            }

            if (AccountingProvider.GetAccountID("515") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("515"), Acc911ID, true, startDate, endDate, "", "Kết chuyển doanh thu hoạt động tài chính" + strRemark));
            }

            if (AccountingProvider.GetAccountID("635") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("635"), Acc911ID, true, startDate, endDate, "", "Kết chuyển chi phí tài chính" + strRemark));
            }

            if (AccountingProvider.GetAccountID("641") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("641"), Acc911ID, true, startDate, endDate, "", "Kết chuyển chi phí bán hàng" + strRemark));
            }

            if (AccountingProvider.GetAccountID("642") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("642"), Acc911ID, true, startDate, endDate, "", "Kết chuyển chi phí quản lý doanh nghiệp" + strRemark));
            }

            if (AccountingProvider.GetAccountID("711") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("711"), Acc911ID, true, startDate, endDate, "", "Kết chuyển thu nhập khác" + strRemark));
            }

            if (AccountingProvider.GetAccountID("811") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("811"), Acc911ID, true, startDate, endDate, "", "Kết chuyển chi phí khác" + strRemark));
            }

            if (AccountingProvider.GetAccountID("8211") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("8211"), Acc911ID, true, startDate, endDate, "", "Kết chuyển chi phí thuế TNDN phải nộp" + strRemark));
            }

            if (AccountingProvider.GetAccountID("8212") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(AccountingProvider.GetAccountID("8212"), Acc911ID, true, startDate, endDate, "", "Kết chuyển chi phí thuế TNDN hoãn lại" + strRemark));
            }

            foreach (GLJournalEntrysInfo entry in lstEntrys)
            {
                if (AccountForReCalcList.Contains(entry.FK_GLAccountID_Debit) == false)
                {
                    AccountForReCalcList.Add(entry.FK_GLAccountID_Debit);
                }
                if (AccountForReCalcList.Contains(entry.FK_GLAccountID_Credit) == false)
                {
                    AccountForReCalcList.Add(entry.FK_GLAccountID_Credit);
                }

                entry.FK_GLJournalVoucherID = voucher.GLJournalVoucherID;
                entry.JournalDate           = endDate;
                entry.ApprovalStatus        = ABCCommon.ABCConstString.ApprovalTypeApproved;
                entryCtrl.CreateObject(entry);
            }

            lstEntrys.Clear();

            if (AccountingProvider.GetAccountID("4212") != Guid.Empty)
            {
                lstEntrys.AddRange(GenerateCloseEntrys(Acc911ID, AccountingProvider.GetAccountID("4212"), true, startDate, endDate, "", "Kết chuyển Lợi Nhuận" + strRemark));
            }
            foreach (GLJournalEntrysInfo entry in lstEntrys)
            {
                if (AccountForReCalcList.Contains(entry.FK_GLAccountID_Debit) == false)
                {
                    AccountForReCalcList.Add(entry.FK_GLAccountID_Debit);
                }
                if (AccountForReCalcList.Contains(entry.FK_GLAccountID_Credit) == false)
                {
                    AccountForReCalcList.Add(entry.FK_GLAccountID_Credit);
                }

                entry.FK_GLJournalVoucherID = voucher.GLJournalVoucherID;
                entry.JournalDate           = endDate;
                entry.ApprovalStatus        = ABCCommon.ABCConstString.ApprovalTypeApproved;
                entryCtrl.CreateObject(entry);
            }

            BenifitCalculationOfPeriod(mainObject);
        }