Skip to content

Commit

Permalink
Merge pull request #14335 from transcom/B-21393V2
Browse files Browse the repository at this point in the history
B 21393 - Consolidated PPM Allowable Weights
  • Loading branch information
r-mettler authored Dec 11, 2024
2 parents bb9cced + 88b1119 commit cdf2c80
Show file tree
Hide file tree
Showing 59 changed files with 768 additions and 445 deletions.
1 change: 1 addition & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@
20241007184230_insertReOconusRateAreas.up.sql
20241007184259_insertReIntlTransTime.up.sql
20241007224427_update_addresses_us_post_region_cities_id.up.sql
20241008133341_consolidate_allowable_weight_in_ppm_shipments.up.sql
20241008212243_populate_market_code_on_shipments_table.up.sql
20241009210749_create_view_v_locations.up.sql
20241011201326_changes_for_actual_expense_reimbursement_field.up.sql
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SET statement_timeout = 300000;
SET lock_timeout = 300000;
SET idle_in_transaction_session_timeout = 300000;

ALTER TABLE ppm_shipments
ADD COLUMN IF NOT EXISTS allowable_weight integer;

COMMENT on COLUMN ppm_shipments.allowable_weight IS 'Combined allowable weight for all trips.';

UPDATE ppm_shipments
SET allowable_weight = summed_weights.summed_allowable_weight
FROM (
SELECT ppm_shipment_id, SUM(coalesce(full_weight, 0) - coalesce(empty_weight, 0)) AS summed_allowable_weight FROM public.weight_tickets
GROUP BY ppm_shipment_id
) AS summed_weights
WHERE ppm_shipments.id = summed_weights.ppm_shipment_id
AND ppm_shipments.status = 'NEEDS_CLOSEOUT';

UPDATE ppm_shipments
SET allowable_weight = summed_weights.summed_allowable_weight
FROM (
SELECT ppm_shipment_id, SUM(weight_tickets.allowable_weight) AS summed_allowable_weight FROM public.weight_tickets
GROUP BY ppm_shipment_id
) AS summed_weights
WHERE ppm_shipments.id = summed_weights.ppm_shipment_id
AND ppm_shipments.status = 'CLOSEOUT_COMPLETE';

ALTER TABLE weight_tickets
DROP COLUMN IF EXISTS allowable_weight;
10 changes: 10 additions & 0 deletions pkg/factory/ppm_shipment_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,16 @@ func BuildPPMShipmentThatNeedsCloseout(db *pop.Connection, userUploader *uploade

ppmShipment.SignedCertification = &signedCert

if ppmShipment.AllowableWeight == nil {
var allowableWeight = unit.Pound(0)
if len(ppmShipment.WeightTickets) >= 1 {
for _, weightTicket := range ppmShipment.WeightTickets {
allowableWeight += *weightTicket.FullWeight - *weightTicket.EmptyWeight
}
}
ppmShipment.AllowableWeight = &allowableWeight
}

ppmShipment.Status = models.PPMShipmentStatusNeedsCloseout
if ppmShipment.SubmittedAt == nil {
ppmShipment.SubmittedAt = models.TimePointer(time.Now())
Expand Down
50 changes: 28 additions & 22 deletions pkg/gen/ghcapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/gen/ghcmessages/p_p_m_shipment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/gen/ghcmessages/update_p_p_m_shipment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions pkg/gen/ghcmessages/update_weight_ticket.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions pkg/gen/ghcmessages/weight_ticket.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cdf2c80

Please sign in to comment.