Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scaffold - note - comp reqs are broken until psp-9066 is implemented. #4583

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,29 +852,29 @@ private void ValidatePayeeDependency(PimsAcquisitionFile acquisitionFile)

foreach (var compReq in compensationRequisitions)
{
// Check for Acquisition File Owner removed
if (compReq.AcquisitionOwnerId is not null
&& !acquisitionFile.PimsAcquisitionOwners.Any(x => x.Internal_Id.Equals(compReq.AcquisitionOwnerId))
&& currentAcquisitionFile.PimsAcquisitionOwners.Any(x => x.Internal_Id.Equals(compReq.AcquisitionOwnerId)))
{
throw new ForeignKeyDependencyException("Acquisition File Owner can not be removed since it's assigned as a payee for a compensation requisition");
}

// Check for Acquisition InterestHolders
if (compReq.InterestHolderId is not null
&& !acquisitionFile.PimsInterestHolders.Any(x => x.Internal_Id.Equals(compReq.InterestHolderId))
&& currentAcquisitionFile.PimsInterestHolders.Any(x => x.Internal_Id.Equals(compReq.InterestHolderId)))
{
throw new ForeignKeyDependencyException("Acquisition File Interest Holders can not be removed since it's assigned as a payee for a compensation requisition");
}

// Check for File Person
if (compReq.AcquisitionFileTeamId is not null
&& !acquisitionFile.PimsAcquisitionFileTeams.Any(x => x.Internal_Id.Equals(compReq.AcquisitionFileTeamId))
&& currentAcquisitionFile.PimsAcquisitionFileTeams.Any(x => x.Internal_Id.Equals(compReq.AcquisitionFileTeamId)))
{
throw new ForeignKeyDependencyException("Acquisition File team member can not be removed since it's assigned as a payee for a compensation requisition");
}
// Check for Acquisition File Owner removed TODO: update for multiple payees.
//if (compReq.AcquisitionOwnerId is not null
// && !acquisitionFile.PimsAcquisitionOwners.Any(x => x.Internal_Id.Equals(compReq.AcquisitionOwnerId))
// && currentAcquisitionFile.PimsAcquisitionOwners.Any(x => x.Internal_Id.Equals(compReq.AcquisitionOwnerId)))
//{
// throw new ForeignKeyDependencyException("Acquisition File Owner can not be removed since it's assigned as a payee for a compensation requisition");
//}

//// Check for Acquisition InterestHolders
//if (compReq.InterestHolderId is not null
// && !acquisitionFile.PimsInterestHolders.Any(x => x.Internal_Id.Equals(compReq.InterestHolderId))
// && currentAcquisitionFile.PimsInterestHolders.Any(x => x.Internal_Id.Equals(compReq.InterestHolderId)))
//{
// throw new ForeignKeyDependencyException("Acquisition File Interest Holders can not be removed since it's assigned as a payee for a compensation requisition");
//}

//// Check for File Person
//if (compReq.AcquisitionFileTeamId is not null
// && !acquisitionFile.PimsAcquisitionFileTeams.Any(x => x.Internal_Id.Equals(compReq.AcquisitionFileTeamId))
// && currentAcquisitionFile.PimsAcquisitionFileTeams.Any(x => x.Internal_Id.Equals(compReq.AcquisitionFileTeamId)))
//{
// throw new ForeignKeyDependencyException("Acquisition File team member can not be removed since it's assigned as a payee for a compensation requisition");
//}
}
}

Expand All @@ -890,13 +890,13 @@ private void ValidateInterestHoldersDependency(long acquisitionFileId, List<Pims

foreach (var compReq in compensationRequisitions)
{
// Check for Interest Holder
if (compReq.InterestHolderId is not null
&& !interestHolders.Any(x => x.InterestHolderId.Equals(compReq.InterestHolderId))
&& currentAcquisitionFile.PimsInterestHolders.Any(x => x.Internal_Id.Equals(compReq.InterestHolderId)))
{
throw new ForeignKeyDependencyException("Acquisition File Interest Holder can not be removed since it's assigned as a payee for a compensation requisition");
}
// Check for Interest Holder: TODO: update for multiple payees.
//if (compReq.InterestHolderId is not null
// && !interestHolders.Any(x => x.InterestHolderId.Equals(compReq.InterestHolderId))
// && currentAcquisitionFile.PimsInterestHolders.Any(x => x.Internal_Id.Equals(compReq.InterestHolderId)))
//{
// throw new ForeignKeyDependencyException("Acquisition File Interest Holder can not be removed since it's assigned as a payee for a compensation requisition");
//}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Mapster;
using Pims.Api.Models.Base;
using System.Linq;
using Entity = Pims.Dal.Entities;

namespace Pims.Api.Models.Concepts.CompensationRequisition
Expand All @@ -25,12 +26,6 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.AgreementDate, src => src.AgreementDt)
.Map(dest => dest.GenerationDate, src => src.GenerationDt)
.Map(dest => dest.Financials, src => src.PimsCompReqFinancials)
.Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId)
.Map(dest => dest.AcquisitionOwner, src => src.AcquisitionOwner)
.Map(dest => dest.InterestHolderId, src => src.InterestHolderId)
.Map(dest => dest.InterestHolder, src => src.InterestHolder)
.Map(dest => dest.AcquisitionFileTeamId, src => src.AcquisitionFileTeamId)
.Map(dest => dest.AcquisitionFileTeam, src => src.AcquisitionFileTeam)
.Map(dest => dest.LegacyPayee, src => src.LegacyPayee)
.Map(dest => dest.IsPaymentInTrust, src => src.IsPaymentInTrust)
.Map(dest => dest.GstNumber, src => src.GstNumber)
Expand All @@ -57,9 +52,6 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.AgreementDt, src => src.AgreementDate)
.Map(dest => dest.GenerationDt, src => src.GenerationDate)
.Map(dest => dest.PimsCompReqFinancials, src => src.Financials)
.Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId)
.Map(dest => dest.InterestHolderId, src => src.InterestHolderId)
.Map(dest => dest.AcquisitionFileTeamId, src => src.AcquisitionFileTeamId)
.Map(dest => dest.LegacyPayee, src => src.LegacyPayee)
.Map(dest => dest.IsPaymentInTrust, src => src.IsPaymentInTrust)
.Map(dest => dest.GstNumber, src => src.GstNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public PimsCompensationRequisition GetById(long compensationRequisitionId)
.Include(x => x.Responsibility)
.Include(c => c.PimsCompReqFinancials)
.ThenInclude(y => y.FinancialActivityCode)
.Include(x => x.AcquisitionOwner)
.Include(x => x.AcquisitionFileTeam)
.Include(x => x.InterestHolder)
.Include(x => x.PimsCompReqPayees)
.ThenInclude(x => x.AcquisitionOwner)
.Include(x => x.PimsCompReqPayees)
.ThenInclude(x => x.AcquisitionFileTeam)
.Include(x => x.PimsCompReqPayees)
.ThenInclude(x => x.InterestHolder)
.Include(x => x.AlternateProject)
.Include(x => x.PimsLeaseStakeholderCompReqs)
.ThenInclude(y => y.LeaseStakeholder)
Expand Down
94 changes: 85 additions & 9 deletions source/backend/entities/PimsBaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public PimsBaseContext(DbContextOptions<PimsBaseContext> options)

public virtual DbSet<PimsCompReqFinancialHist> PimsCompReqFinancialHists { get; set; }

public virtual DbSet<PimsCompReqPayee> PimsCompReqPayees { get; set; }

public virtual DbSet<PimsCompReqPayeeHist> PimsCompReqPayeeHists { get; set; }

public virtual DbSet<PimsCompensationRequisition> PimsCompensationRequisitions { get; set; }

public virtual DbSet<PimsCompensationRequisitionHist> PimsCompensationRequisitionHists { get; set; }
Expand Down Expand Up @@ -2005,6 +2009,78 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.EffectiveDateHist).HasDefaultValueSql("(getutcdate())");
});

modelBuilder.Entity<PimsCompReqPayee>(entity =>
{
entity.HasKey(e => e.CompReqPayeeId).HasName("CMPRQP_PK");

entity.ToTable("PIMS_COMP_REQ_PAYEE", tb =>
{
tb.HasComment("Table to support multiple payees on a compensation requisition.");
tb.HasTrigger("PIMS_CMPRQP_A_S_IUD_TR");
tb.HasTrigger("PIMS_CMPRQP_I_S_I_TR");
tb.HasTrigger("PIMS_CMPRQP_I_S_U_TR");
});

entity.Property(e => e.CompReqPayeeId)
.HasDefaultValueSql("(NEXT VALUE FOR [PIMS_COMP_REQ_PAYEE_ID_SEQ])")
.HasComment("Generated surrogate primary key.");
entity.Property(e => e.AcquisitionFileTeamId).HasComment("Foreign key reference to the PIMS_ACQUISITION_FILE_TEAM table.");
entity.Property(e => e.AcquisitionOwnerId).HasComment("Foreign key reference to the PIMS_ACQUISITION_OWNER table.");
entity.Property(e => e.AppCreateTimestamp)
.HasDefaultValueSql("(getutcdate())")
.HasComment("The date and time the user created the record.");
entity.Property(e => e.AppCreateUserDirectory)
.HasDefaultValueSql("(user_name())")
.HasComment("The directory of the user account that created the record.");
entity.Property(e => e.AppCreateUserGuid).HasComment("The GUID of the user account that created the record.");
entity.Property(e => e.AppCreateUserid)
.HasDefaultValueSql("(user_name())")
.HasComment("The user account that created the record.");
entity.Property(e => e.AppLastUpdateTimestamp)
.HasDefaultValueSql("(getutcdate())")
.HasComment("The date and time the user updated the record.");
entity.Property(e => e.AppLastUpdateUserDirectory)
.HasDefaultValueSql("(user_name())")
.HasComment("The directory of the user account that updated the record.");
entity.Property(e => e.AppLastUpdateUserGuid).HasComment("The GUID of the user account that updated the record.");
entity.Property(e => e.AppLastUpdateUserid)
.HasDefaultValueSql("(user_name())")
.HasComment("The user account that updated the record.");
entity.Property(e => e.CompensationRequisitionId).HasComment("Foreign key reference to the PIMS_COMPENSATION_REQUISITION table.");
entity.Property(e => e.ConcurrencyControlNumber)
.HasDefaultValue(1L)
.HasComment("Application code is responsible for retrieving the row and then incrementing the value of the CONCURRENCY_CONTROL_NUMBER column by one prior to issuing an update. If this is done then the update will succeed, provided that the row was not updated by any o");
entity.Property(e => e.DbCreateTimestamp)
.HasDefaultValueSql("(getutcdate())")
.HasComment("The date and time the record was created.");
entity.Property(e => e.DbCreateUserid)
.HasDefaultValueSql("(user_name())")
.HasComment("The user or proxy account that created the record.");
entity.Property(e => e.DbLastUpdateTimestamp)
.HasDefaultValueSql("(getutcdate())")
.HasComment("The date and time the record was created or last updated.");
entity.Property(e => e.DbLastUpdateUserid)
.HasDefaultValueSql("(user_name())")
.HasComment("The user or proxy account that created or last updated the record.");
entity.Property(e => e.InterestHolderId).HasComment("Foreign key reference to the PIMS_INTEREST_HOLDER table.");

entity.HasOne(d => d.AcquisitionFileTeam).WithMany(p => p.PimsCompReqPayees).HasConstraintName("PIM_ACQNTM_PIM_CMPRQP_FK");

entity.HasOne(d => d.AcquisitionOwner).WithMany(p => p.PimsCompReqPayees).HasConstraintName("PIM_ACQOWN_PIM_CMPRQP_FK");

entity.HasOne(d => d.CompensationRequisition).WithMany(p => p.PimsCompReqPayees).HasConstraintName("PIM_CMPREQ_PIM_CMPRQP_FK");

entity.HasOne(d => d.InterestHolder).WithMany(p => p.PimsCompReqPayees).HasConstraintName("PIM_INTHLD_PIM_CMPRQP_FK");
});

modelBuilder.Entity<PimsCompReqPayeeHist>(entity =>
{
entity.HasKey(e => e.CompReqPayeeHistId).HasName("PIMS_CMPRQP_H_PK");

entity.Property(e => e.CompReqPayeeHistId).HasDefaultValueSql("(NEXT VALUE FOR [PIMS_COMP_REQ_PAYEE_H_ID_SEQ])");
entity.Property(e => e.EffectiveDateHist).HasDefaultValueSql("(getutcdate())");
});

modelBuilder.Entity<PimsCompensationRequisition>(entity =>
{
entity.HasKey(e => e.CompensationRequisitionId).HasName("CMPREQ_PK");
Expand All @@ -2021,8 +2097,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasDefaultValueSql("(NEXT VALUE FOR [PIMS_COMPENSATION_REQUISITION_ID_SEQ])")
.HasComment("Generated surrogate primary key.");
entity.Property(e => e.AcquisitionFileId).HasComment("Foreign key to the PIMS_ACQUISITION_FILE table.");
entity.Property(e => e.AcquisitionFileTeamId).HasComment("Foreign key to the PIMS_ACQUISITION_FILE_TEAM table.");
entity.Property(e => e.AcquisitionOwnerId).HasComment("Foreign key to the PIMS_ACQUISITION_OWNER table.");
entity.Property(e => e.AgreementDt).HasComment("Agreement date.");
entity.Property(e => e.AlternateProjectId).HasComment("Link a file to an \"Alternate Project\", so the user can make alternate payments that may be due after the original file's project closes.");
entity.Property(e => e.AppCreateTimestamp)
Expand Down Expand Up @@ -2068,7 +2142,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.FiscalYear).HasComment("Fiscal year of the compensation requisition.");
entity.Property(e => e.GenerationDt).HasComment("Document generation date.");
entity.Property(e => e.GstNumber).HasComment("GST number of the organization receiving the payment.");
entity.Property(e => e.InterestHolderId).HasComment("Foreign key to the PIMS_INTEREST_HOLDER table.");
entity.Property(e => e.IsDisabled)
.HasDefaultValue(false)
.HasComment("Indicates if the requisition is inactive.");
Expand All @@ -2086,16 +2159,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

entity.HasOne(d => d.AcquisitionFile).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_ACQNFL_PIM_CMPREQ_FK");

entity.HasOne(d => d.AcquisitionFileTeam).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_ACQPER_PIM_CMPREQ_FK");

entity.HasOne(d => d.AcquisitionOwner).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_ACQOWN_PIM_CMPREQ_FK");

entity.HasOne(d => d.AlternateProject).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_PROJCT_PIM_CMPREQ_FK");

entity.HasOne(d => d.ChartOfAccounts).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_CHRTAC_PIM_CMPREQ_FK");

entity.HasOne(d => d.InterestHolder).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_INTHLD_PIM_CMPREQ_FK");

entity.HasOne(d => d.Lease).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_LEASE_PIM_CMPREQ_FK");

entity.HasOne(d => d.Responsibility).WithMany(p => p.PimsCompensationRequisitions).HasConstraintName("PIM_RESPCD_PIM_CMPREQ_FK");
Expand Down Expand Up @@ -9332,6 +9399,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.HasSequence("PIMS_COMP_REQ_FINANCIAL_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
modelBuilder.HasSequence("PIMS_COMP_REQ_PAYEE_H_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
modelBuilder.HasSequence("PIMS_COMP_REQ_PAYEE_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
modelBuilder.HasSequence("PIMS_COMPENSATION_REQUISITION_H_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
Expand Down Expand Up @@ -9695,6 +9768,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.HasSequence("PIMS_PROJECT_PROPERTY_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
modelBuilder.HasSequence("PIMS_PROJECT_TEAM_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
modelBuilder.HasSequence("PIMS_PROJECT_WORKFLOW_MODEL_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
Expand Down
42 changes: 21 additions & 21 deletions source/backend/entities/ef/PimsAcquisitionFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,6 @@ public partial class PimsAcquisitionFile
[StringLength(20)]
public string SubfileInterestTypeCode { get; set; }

/// <summary>
/// Foreign key to the PIMS_ACQ_FILE_APPRAISAL_TYPE table.
/// </summary>
[Column("ACQ_FILE_APPRAISAL_TYPE_CODE")]
[StringLength(20)]
public string AcqFileAppraisalTypeCode { get; set; }

/// <summary>
/// Foreign key to the PIMS_ACQ_FILE_LGL_SRVY_TYPE table.
/// </summary>
[Column("ACQ_FILE_LGL_SRVY_TYPE_CODE")]
[StringLength(20)]
public string AcqFileLglSrvyTypeCode { get; set; }

/// <summary>
/// Foreign key to the PIMS_ACQ_FILE_EXPROP_RISK_TYPE table.
/// </summary>
[Column("ACQ_FILE_EXPROP_RISK_TYPE_CODE")]
[StringLength(20)]
public string AcqFileExpropRiskTypeCode { get; set; }

/// <summary>
/// Descriptive name given to the acquisition file.
/// </summary>
Expand Down Expand Up @@ -289,6 +268,27 @@ public partial class PimsAcquisitionFile
[StringLength(30)]
public string DbLastUpdateUserid { get; set; }

/// <summary>
/// Foreign key to the PIMS_ACQ_FILE_APPRAISAL_TYPE table.
/// </summary>
[Column("ACQ_FILE_APPRAISAL_TYPE_CODE")]
[StringLength(20)]
public string AcqFileAppraisalTypeCode { get; set; }

/// <summary>
/// Foreign key to the PIMS_ACQ_FILE_LGL_SRVY_TYPE table.
/// </summary>
[Column("ACQ_FILE_LGL_SRVY_TYPE_CODE")]
[StringLength(20)]
public string AcqFileLglSrvyTypeCode { get; set; }

/// <summary>
/// Foreign key to the PIMS_ACQ_FILE_EXPROP_RISK_TYPE table.
/// </summary>
[Column("ACQ_FILE_EXPROP_RISK_TYPE_CODE")]
[StringLength(20)]
public string AcqFileExpropRiskTypeCode { get; set; }

[ForeignKey("AcqFileAppraisalTypeCode")]
[InverseProperty("PimsAcquisitionFiles")]
public virtual PimsAcqFileAppraisalType AcqFileAppraisalTypeCodeNavigation { get; set; }
Expand Down
Loading
Loading