Skip to content

Commit

Permalink
Merge pull request #14815 from transcom/B-22307-INT
Browse files Browse the repository at this point in the history
B-22307 int deleted expense types
  • Loading branch information
r-mettler authored Feb 19, 2025
2 parents 12198ee + 9bb6eff commit 1034dfb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/services/ppm_closeout/ppm_closeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,33 @@ func (p *ppmCloseoutFetcher) GetPPMShipment(appCtx appcontext.AppContext, ppmShi
return nil, apperror.NewQueryError("PPMShipment", err, "while looking for PPMShipment")
}
}

// the following checks are needed since we can't use "ExcludeDeletedScope()" in the big query above
// this is because not all of the tables being queried have "deleted_at" columns and this returns an error
if ppmShipment.WeightTickets != nil {
var filteredWeightTickets []models.WeightTicket
// We do not need to consider deleted weight tickets or uploads within them
for _, wt := range ppmShipment.WeightTickets {
if wt.DeletedAt == nil {
wt.EmptyDocument.UserUploads = wt.EmptyDocument.UserUploads.FilterDeleted()
wt.FullDocument.UserUploads = wt.FullDocument.UserUploads.FilterDeleted()
wt.ProofOfTrailerOwnershipDocument.UserUploads = wt.ProofOfTrailerOwnershipDocument.UserUploads.FilterDeleted()
filteredWeightTickets = append(filteredWeightTickets, wt)
}
}
ppmShipment.WeightTickets = filteredWeightTickets
}
// We do not need to consider deleted moving expenses
if len(ppmShipment.MovingExpenses) > 0 {
ppmShipment.MovingExpenses = ppmShipment.MovingExpenses.FilterDeleted()
}
// We do not need to consider deleted progear weight tickets
if len(ppmShipment.ProgearWeightTickets) > 0 {
ppmShipment.ProgearWeightTickets = ppmShipment.ProgearWeightTickets.FilterDeleted()
}

var weightTicket models.WeightTicket

if len(ppmShipment.WeightTickets) >= 1 {
weightTicket = ppmShipment.WeightTickets[0]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,32 @@ func (SSWPPMComputer *SSWPPMComputer) FetchDataShipmentSummaryWorksheetFormData(
return nil, dbQErr
}

// the following checks are needed since we can't use "ExcludeDeletedScope()" in the big query above
// this is because not all of the tables being queried have "deleted_at" columns and this returns an error
if ppmShipment.WeightTickets != nil {
var filteredWeightTickets []models.WeightTicket
// We do not need to consider deleted weight tickets or uploads within them
for _, wt := range ppmShipment.WeightTickets {
if wt.DeletedAt == nil {
wt.EmptyDocument.UserUploads = wt.EmptyDocument.UserUploads.FilterDeleted()
wt.FullDocument.UserUploads = wt.FullDocument.UserUploads.FilterDeleted()
wt.ProofOfTrailerOwnershipDocument.UserUploads = wt.ProofOfTrailerOwnershipDocument.UserUploads.FilterDeleted()
filteredWeightTickets = append(filteredWeightTickets, wt)
}
}
ppmShipment.WeightTickets = filteredWeightTickets
}
// We do not need to consider deleted moving expenses
if len(ppmShipment.MovingExpenses) > 0 {
nonDeletedMovingExpenses := ppmShipment.MovingExpenses.FilterDeleted()
ppmShipment.MovingExpenses = nonDeletedMovingExpenses
}
// We do not need to consider deleted progear weight tickets
if len(ppmShipment.ProgearWeightTickets) > 0 {
nonDeletedProgearTickets := ppmShipment.ProgearWeightTickets.FilterDeleted()
ppmShipment.ProgearWeightTickets = nonDeletedProgearTickets
}

// Final actual weight is a calculated value we don't store. This needs to be fetched independently
// Requires WeightTickets eager preload
ppmShipmentFinalWeight := models.GetPPMNetWeight(ppmShipment)
Expand Down

0 comments on commit 1034dfb

Please sign in to comment.