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); } }
public static void DeleteJournalVoucher(GLJournalVouchersInfo voucher) { if (voucher.GLJournalVoucherID == Guid.Empty) { return; } DeleteJournalVoucher(voucher.GLJournalVoucherID); }
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); } }
public static void InvalidateJournalEntry(GLJournalEntrysInfo entry, GLJournalVouchersInfo voucher, BusinessObject objSourceObj) { BusinessObjectHelper.CopyFKFields(objSourceObj, entry, true); BusinessObjectHelper.CopyFKFields(voucher, entry, true); BusinessObjectHelper.CopyField(objSourceObj, entry, "JournalDate", false); BusinessObjectHelper.CopyField(objSourceObj, entry, "Voucher", false); BusinessObjectHelper.CopyField(objSourceObj, entry, "VoucherContent", false); BusinessObjectHelper.CopyField(objSourceObj, entry, "VoucherDate", false); if (String.IsNullOrWhiteSpace(entry.EntryType)) { entry.EntryType = ABCCommon.ABCConstString.EntryTypeERP; } entry.RaiseAmtTot = entry.AmtTot; entry.FK_GLAccountID_RaiseCredit = entry.FK_GLAccountID_Credit; entry.FK_GLAccountID_RaiseDebit = entry.FK_GLAccountID_Debit; InvalidateJournalEntry(entry, voucher); }
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); }
public static void InvalidateJournalEntry(GLJournalEntrysInfo entry, GLJournalVouchersInfo voucher) { if (entry == null) { return; } if (voucher != null) { BusinessObjectHelper.CopyFKFields(voucher, entry, true); entry.FK_GLJournalVoucherID = voucher.GLJournalVoucherID; entry.ApprovalStatus = voucher.ApprovalStatus; entry.JournalDate = voucher.JournalDate; if (String.IsNullOrWhiteSpace(entry.Voucher)) { entry.Voucher = voucher.Voucher; } if (String.IsNullOrWhiteSpace(entry.VoucherContent)) { entry.VoucherContent = voucher.VoucherContent; } if (entry.VoucherDate.HasValue == false) { entry.VoucherDate = voucher.VoucherDate; } } if (entry.EntryType == ABCCommon.ABCConstString.EntryTypeERP) { if (entry.RaiseAmtTot != entry.AmtTot || entry.FK_GLAccountID_RaiseDebit.HasValue == false || entry.FK_GLAccountID_RaiseDebit.Value != entry.FK_GLAccountID_Debit || entry.FK_GLAccountID_RaiseCredit.HasValue == false || entry.FK_GLAccountID_RaiseCredit.Value != entry.FK_GLAccountID_Credit) { entry.EntryType = ABCCommon.ABCConstString.EntryTypeERPModified; } } if (String.IsNullOrWhiteSpace(entry.EntryType)) { entry.EntryType = ABCCommon.ABCConstString.EntryTypeNormal; } #region ObjectDesc entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_ASFixedAssetID", entry.FK_ASFixedAssetID); if (String.IsNullOrWhiteSpace(entry.ObjectDesc)) { entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_HREmployeeID", entry.FK_HREmployeeID); } if (String.IsNullOrWhiteSpace(entry.ObjectDesc)) { entry.ObjectDesc = BusinessObjectHelper.GetNameValue("MAPartners", entry.FK_MAPartnerID); } if (String.IsNullOrWhiteSpace(entry.ObjectDesc)) { entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_GECompanyUnitID", entry.FK_GECompanyUnitID); } if (String.IsNullOrWhiteSpace(entry.ObjectDesc)) { entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_GLMonitorObjectID", entry.FK_GLMonitorObjectID); } if (String.IsNullOrWhiteSpace(entry.ObjectDesc)) { entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_PMProjectID", entry.FK_PMProjectID); } if (String.IsNullOrWhiteSpace(entry.ObjectDesc)) { entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_COCostGroupID", entry.FK_COCostGroupID); } if (String.IsNullOrWhiteSpace(entry.ObjectDesc)) { entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_GEBankAccountID", entry.FK_GEBankAccountID); } #endregion }
public static void InvalidateJournalVoucher(IList <GLJournalEntrysInfo> lstEntrys, GLJournalVouchersInfo voucher) { List <String> lstVouchers = new List <string>(); foreach (GLJournalEntrysInfo entry in lstEntrys) { InvalidateJournalEntry(entry, voucher); if (lstVouchers.Contains(entry.Voucher) == false) { lstVouchers.Add(entry.Voucher); } } #region voucher.Voucher voucher.Voucher = String.Empty; if (String.IsNullOrWhiteSpace(voucher.ERPVoucherNo) == false) { voucher.Voucher = voucher.ERPVoucherNo; } else { foreach (string strVoucherNo in lstVouchers) { if (String.IsNullOrWhiteSpace(voucher.Voucher)) { voucher.Voucher = strVoucherNo; } else { voucher.Voucher += (";" + strVoucherNo); } } } #endregion }