protected override void AfterAdd(DataRow row) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)row; string ObjectName = this.myDisbursementDT.TableName; if (dr.IsNull("DisbId") || dr.DisbId > 0) { dr.DisbId = this.myA.AtMng.PKIDGet(ObjectName, 1); } dr.DisbDate = dr.ActivityRow.ActivityDate;// DateTime.Today; dr.FileID = dr.ActivityRow.FileId; dr.Final = false; dr.Posted = true; dr.OfficeId = this.myA.AtMng.WorkingAsOfficer.OfficeId; dr.Taxed = false; //2017-08-09 JLL IUTIR - 9755 if (!myA.AtMng.WorkingAsOfficer.OfficeRow.IsDefaultTaxRateNull()) { dr.TaxRateId = myA.AtMng.WorkingAsOfficer.OfficeRow.DefaultTaxRate; } //2017-09-20 JLL //validate disbdate on entry, otherwise on ACs older than 6 months, date can be saved if not edited without being validated properly this.BeforeChange(this.myDisbursementDT.Columns["DisbDate"], row); }
protected override void BeforeDelete(DataRow row) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)row; if (dr.Final && !dr.IsIRPIdNull() || dr.OfficeId != this.myA.AtMng.OfficeLoggedOn.OfficeId) { throw new AtriumException(Resources.DisbNoDelete); } }
private void AddDisbursement(atriumDB.DisbursementRow drDisb, int officeId, DateTime disbDate, DateTime srpDate, decimal disbTaxExempt, decimal disbTax, string disbType, string comment) { drDisb.BeginEdit(); drDisb.OfficeId = officeId; drDisb.DisbDate = disbDate; drDisb.DisbTaxExempt = disbTaxExempt; drDisb.DisbTaxable = disbTax; drDisb.DisbType = disbType; drDisb.Comment = comment; drDisb.entryDate = srpDate; drDisb.EndEdit(); }
private void DisbDetailRow(string officeFileNo, DateTime activityDate, DateTime disbDate, CodesDB.DisbursementTypeRow disbTypeR, decimal taxableDisb, decimal nonTaxableDisb, string comment, ref bool encounteredError, int officeId, DateTime srpDate) { if (officeFileNo == "") { officeFileNo = "General Account"; } try { FileManager fmCur = myA.AtMng.GetFile(officeFileNo, officeId); fms.Add(fmCur.CurrentFile.FileId, fmCur); atriumDB.EFileRow drEfile = fmCur.CurrentFile;// fm.EFile.LoadByOfficeFileNum(officeFileNo, officeId); atriumDB.ActivityRow drActivity; if (drEfile != null) { //fmCur.GetActivity().LoadByFileId(drEfile.FileId); drActivity = GetClosestActivity(fmCur, activityDate, officeFileNo, officeId.ToString(), disbTypeR, disbDate, drEfile.FileId.ToString(), ref encounteredError); if (drActivity != null) { atriumDB.DisbursementRow drDisb = (atriumDB.DisbursementRow)fmCur.GetDisbursement().Add(drActivity); AddDisbursement(drDisb, officeId, disbDate, srpDate, nonTaxableDisb, taxableDisb, disbTypeR.DisbursementType, comment); if (drDisb.HasErrors) { WriteErrorLog(officeFileNo, disbTypeR.DisbursementType, disbDate, Resources.CouldNotAddDisbursement + drDisb.RowError); encounteredError = true; } } else { WriteErrorLog(officeFileNo, disbTypeR.DisbursementType, disbDate, Resources.MatchingActivityNotFound); encounteredError = true; } } } catch (Exception x) { WriteErrorLog(officeFileNo, activityDate, disbTypeR.DisbursementType, disbDate, Resources.OfficeFileNumberNotValid + x.Message); encounteredError = true; } }
protected override void BeforeUpdate(DataRow row) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)row; if (!CanEdit(dr)) { throw new AtriumException(atriumBE.Properties.Resources.CACannotEditAnotherOffice); } if (dr.IsDisbDateNull()) { this.BeforeChange(DisbursementFields.DisbDate, dr); } if (dr.IsNull(dr.Table.Columns[DisbursementFields.DisbType])) { this.BeforeChange(DisbursementFields.DisbType, dr); } if (dr.IsDisbTaxableNull() && dr.IsDisbTaxExemptNull()) { throw new RequiredException(DisbursementFields.DisbTaxable); } }
protected override void AfterChange(DataColumn dc, DataRow ddr) { string ObjectName = this.myDisbursementDT.TableName; atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)ddr; switch (dc.ColumnName) { case DisbursementFields.DisbTaxable: case "TaxRateId": if (!dr.Final) { if (dr.IsDisbTaxableNull()) { dr.SetDisbTaxNull(); } else { if (!dr.IsTaxRateIdNull()) { appDB.TaxRateRow taxRateRow = myA.AtMng.DB.TaxRate.FindByTaxRateId(dr.TaxRateId); dr.DisbTax = dr.DisbTaxable * taxRateRow.TaxRate; } else { officeDB.OfficeRow drOffice = this.myA.AtMng.GetOffice(dr.OfficeId).CurrentOffice; dr.DisbTax = dr.DisbTaxable * (drOffice.IsTaxRateNull() ? 0 : drOffice.TaxRate); } dr.DisbTax = Math.Round(dr.DisbTax, 2, MidpointRounding.AwayFromZero); } dr.EndEdit(); } break; default: break; } }
public override bool CanEdit(DataRow ddr) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)ddr; if (dr == null || dr.ActivityRow == null) { return(false); } if (dr.ActivityRow.EFileRow.RowState == DataRowState.Added) { return(true); } if (dr.IsNull("FileId")) { return(true); } if (!myA.IsVirtualFM && dr.FileID != myA.CurrentFile.FileId) { return(false); } if (dr.Final) { return(false); } if (!dr.IsNull("OfficeId") && dr.OfficeId != this.myA.AtMng.WorkingAsOfficer.OfficeId) { return(false); } if (dr.ActivityRow != null && dr.ActivityRow.OfficeId != this.myA.AtMng.WorkingAsOfficer.OfficeId) { return(false); } return(myA.AtMng.SecurityManager.CanUpdate(dr.FileID, atSecurity.SecurityManager.Features.Disbursement) > atSecurity.SecurityManager.LevelPermissions.No | AllowEdit); }
public override bool CanDelete(DataRow row) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)row; bool ok = false; atSecurity.SecurityManager.LevelPermissions perm = myA.AtMng.SecurityManager.CanDelete(dr.FileID, atSecurity.SecurityManager.Features.Disbursement); switch (perm) { case atSecurity.SecurityManager.LevelPermissions.All: ok = true; break; case atSecurity.SecurityManager.LevelPermissions.MyOffice: if (dr.OfficeId == myA.AtMng.OfficerLoggedOn.OfficeId) { ok = true; } break; case atSecurity.SecurityManager.LevelPermissions.No: ok = false; break; default: ok = false; break; } bool canOverride = myA.AtMng.SecurityManager.CanOverride(dr.FileID, atSecurity.SecurityManager.Features.Disbursement) == atSecurity.SecurityManager.ExPermissions.Yes; if (dr.Final && !dr.IsIRPIdNull() && !canOverride) { ok = false; } return(ok); }
private void DisbBulkRow(string officeFileNo, DateTime disbDate, CodesDB.DisbursementTypeRow disbTypeR, decimal taxableDisb, decimal nonTaxableDisb, string comment, ref bool encounteredError, int officeId, DateTime srpDate) { if (!disbTypeR.IsBulk)// disbTypeCode == "CO" || disbTypeCode == "FA" || disbTypeCode == "LD" || disbTypeCode == "PH" || disbTypeCode == "PO" || disbTypeCode == "RM") { if (officeFileNo == "") { officeFileNo = "General Account"; } atriumDB.EFileRow drEfile = null; try { FileManager fmCur = myA.AtMng.GetFile(officeFileNo, officeId); fms.Add(fmCur.CurrentFile.FileId, fmCur); drEfile = fmCur.CurrentFile; if (drEfile != null) { //fmCur.GetActivity().LoadByFileId(drEfile.FileId); //JL: Change to DisbursementType from ACManagement to CodesDB bobo. //string activityQuery = "officeid=" + officeId.ToString() + " and fileid=" + drEfile.FileId.ToString() + " and activitycodeid=" + disbTypeR.GetACDisbRows()[0].ActivityCodeId.ToString() + " and activitydate='" + srpDate.ToString("yyyy/MM/dd") + "'"; string activityQuery = ""; atriumDB.ActivityRow[] drActivityArr = (atriumDB.ActivityRow[])fmCur.DB.Activity.Select(activityQuery); atriumDB.ActivityRow drActivity; if (drActivityArr.Length == 0) { //JL: Change of DisbursementType from ACMAnager dataset to CodesDB dataset bobo. //ActivityConfig.ACSeriesRow bulkACS =(ActivityConfig.ACSeriesRow) myA.AtMng.acMng.DB.ACSeries.Select("ActivityCodeId=" + disbTypeR.GetACDisbRows()[0].ActivityCodeId.ToString())[0];//.FindByACSeriesId(disbTypeR.GetACDisbRows()[0].ACSeriesId); ActivityConfig.ACSeriesRow bulkACS = null; ACEngine ace = fmCur.InitActivityProcess().Add(srpDate, bulkACS, null, false, null); drActivity = ace.NewActivity; drActivity.BeginEdit(); drActivity.OfficeId = officeId; drActivity.EndEdit(); if (drActivity.HasErrors) { if (drActivity.HasErrors) { WriteErrorLog(officeFileNo, "", srpDate, Resources.CouldNotCreateAC022 + drActivity.RowError); encounteredError = true; } } } else { drActivity = drActivityArr[0]; } atriumDB.DisbursementRow drDisb = (atriumDB.DisbursementRow)fmCur.GetDisbursement().Add(drActivity); AddDisbursement(drDisb, officeId, disbDate, srpDate, nonTaxableDisb, taxableDisb, disbTypeR.DisbursementType, comment); if (drDisb.HasErrors) { WriteErrorLog(officeFileNo, disbTypeR.DisbursementType, disbDate, Resources.CouldNotAddDisbursement + drDisb.RowError); encounteredError = true; } } } catch (Exception x) { WriteErrorLog(officeFileNo, disbTypeR.DisbursementType, disbDate, Resources.OfficeFileNumberNotValid + x.Message); encounteredError = true; } } else { WriteErrorLog(officeFileNo, disbTypeR.DisbursementType, disbDate, Resources.InvalidDisbursmentTypeCode); encounteredError = true; } }
protected override void BeforeChange(DataColumn dc, DataRow ddr) { string ObjectName = this.myDisbursementDT.TableName; atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)ddr; switch (dc.ColumnName) { case DisbursementFields.DisbDate: if (dr.IsDisbDateNull() || myA.IsEmpty(dr.DisbDate.ToString())) { throw new RequiredException(Resources.DisbursementDisbDate); } this.myA.IsValidDate(Resources.DisbursementDisbDate, dr.DisbDate, false, DateTime.Today.AddMonths(-6), DateTime.Today, Resources.ValidationSixMonthsAgo, Resources.ValidationToday); break; case DisbursementFields.DisbType: if (dr.IsNull(dc) || dr.DisbType.Length == 0) { throw new RequiredException(Resources.DisbursementDisbType); } else if (!myA.CheckDomain(dr.DisbType, myA.Codes("DisbursementType"))) { throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dr.Table.TableName, "Dsibursement Type"); } break; case "TaxRateId": if (!dr.IsTaxRateIdNull() && !myA.CheckDomain(dr.TaxRateId, myA.Codes("TaxRate"))) { throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dc.Table.TableName, "Tax Rate"); } break; case "OfficeId": if (!myA.CheckDomain(dr.OfficeId, myA.Codes("OfficeList"))) { throw new AtriumException(atriumBE.Properties.Resources.IsNotValid, dc.ColumnName); } else if (!myA.CheckDomain(dr.OfficeId, myA.Codes("officelist"))) { throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dc.Table.TableName, "Office List"); } break; case DisbursementFields.IRPId: case DisbursementFields.DisbTaxExempt: case DisbursementFields.DisbTaxable: case DisbursementFields.DisbTax: case DisbursementFields.Posted: case DisbursementFields.Final: if (dr.Final) { throw new AtriumException(Resources.DisbNoEditAfterCommit); } break; case DisbursementFields.Taxed: if (!dr.Final && dr.Taxed) { throw new AtriumException(Resources.DisbNoTaxUnlessCommit); } break; default: break; } }