Skip to content

Commit

Permalink
Merge branch 'main' into B-21557-Estimated-Price
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydoyecaci authored Jan 21, 2025
2 parents 085d98e + ca313cd commit a832f04
Show file tree
Hide file tree
Showing 49 changed files with 1,962 additions and 197 deletions.
299 changes: 254 additions & 45 deletions .gitlab-ci.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY build /build
COPY public/static/react-file-viewer /public/static/react-file-viewer

# Mount mutable tmp for app packages like pdfcpu
# hadolint ignore=DL3007
VOLUME ["/tmp"]

ENTRYPOINT ["/bin/milmove"]
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.dp3
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ COPY build /build
COPY public/static/react-file-viewer /public/static/react-file-viewer

# Mount mutable tmp for app packages like pdfcpu
# hadolint ignore=DL3007
VOLUME ["/tmp"]

ENTRYPOINT ["/bin/milmove"]
Expand Down
Binary file modified config/tls/milmove-cert-bundle.p7b
Binary file not shown.
3 changes: 3 additions & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@
20241217163231_update_duty_locations_bad_zips.up.sql
20241217180136_add_AK_zips_to_zip3_distances.up.sql
20241218201833_add_PPPO_BASE_ELIZABETH.up.sql
20241218204620_add_international_nts_service_items.up.sql
20241220171035_add_additional_AK_zips_to_zip3_distances.up.sql
20241220213134_add_destination_gbloc_db_function.up.sql
20241224172258_add_and_update_po_box_zip.up.sql
Expand All @@ -1069,4 +1070,6 @@
20241230190647_add_missing_AK_zips_to_zip3_distances.up.sql
20250103180420_update_pricing_proc_to_use_local_price_variable.up.sql
20250110001339_update_nts_release_enum_name.up.sql
20250110153428_add_shipment_address_updates_to_move_history.up.sql
20250110214012_homesafeconnect_cert.up.sql
20250116200912_disable_homesafe_stg_cert.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--
-- Add service items for international NTS shipments.
--
INSERT INTO re_service_items
(id, service_id, shipment_type, market_code, is_auto_approved, created_at, updated_at, sort)
VALUES
--ISLH International Shipping & Linehaul
('2a560507-db09-4be1-b809-49c0f515b31b', '9f3d551a-0725-430e-897e-80ee9add3ae9' ,'HHG_INTO_NTS', 'i', true, now(), now(), 1),
--PODFSC International POD Fuel Surcharge
('e702818f-defd-452c-81a3-865b902e7dd0', '388115e8-abe9-441d-96cf-a39f24baa0a3' ,'HHG_INTO_NTS', 'i', true, now(), now(), 2),
--INPK International NTS packing
('366ee5a4-eb61-4ded-a68c-ddc29fe1a886', '874cb86a-bc39-4f57-a614-53ee3fcacf14' ,'HHG_INTO_NTS', 'i', true, now(), now(), 3),
--ICRT International crating
('aac4e95e-27ed-4f09-9b6b-384d8542f410', '86203d72-7f7c-49ff-82f0-5b95e4958f60' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IDASIT International destination add'l day SIT
('010f2f91-7381-4149-8d74-8eb5f593a864', '806c6d59-57ff-4a3f-9518-ebf29ba9cb10' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IDDSIT International destination SIT delivery
('a41966b7-b83a-4eaf-8e68-d5e884777102', '28389ee1-56cf-400c-aa52-1501ecdd7c69' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IDFSIT International destination 1st day SIT
('14c77957-3c76-465a-bb07-c98d36ef1e54', 'bd6064ca-e780-4ab4-a37b-0ae98eebb244' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IDSHUT International destination shuttle service
('d52d2d03-100a-4ed9-b2de-16eac63a375f', '22fc07ed-be15-4f50-b941-cbd38153b378' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IOASIT International origin add'l day SIT
('7fd91408-7d69-4375-b7e6-5b2ff714206b', 'bd424e45-397b-4766-9712-de4ae3a2da36' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IOFSIT International origin 1st day SIT
('b3dc509d-d652-4300-a702-a1ddce6255b6', 'b488bf85-ea5e-49c8-ba5c-e2fa278ac806' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IOPSIT International origin SIT pickup
('001eadb6-3526-45b9-96e0-0648bb481e86', '6f4f6e31-0675-4051-b659-89832259f390' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IOSHUT International origin shuttle service
('b991c5c9-af2c-4146-b999-1d0bdf91de3f', '624a97c5-dfbf-4da9-a6e9-526b4f95af8d' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IUCRT International uncrating
('5a89315a-257b-4ef0-92cb-4c06aa6f1332', '4132416b-b1aa-42e7-98f2-0ac0a03e8a31' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IOFSC International Origin SIT Fuel Surcharge
('d4a98dea-a5f7-4b92-b5de-e6350ab07824', '81e29d0c-02a6-4a7a-be02-554deb3ee49e' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL),
--IDSFSC International Destination SIT Fuel Surcharge
('eaea90c2-93d3-4db9-89cd-23ac57ec9ce1', '690a5fc1-0ea5-4554-8294-a367b5daefa9' ,'HHG_INTO_NTS', 'i', false, now(), now(), NULL);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- adding shipment_address_updates table to move history so we can track the activity
SELECT add_audit_history_table(
target_table := 'shipment_address_updates',
audit_rows := BOOLEAN 't',
audit_query_text := BOOLEAN 't',
ignored_cols := ARRAY[
'created_at'
]
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Local test migration.
-- This will be run on development environments.
-- It should mirror what you intend to apply on prd/stg/exp/demo
-- DO NOT include any sensitive data.
24 changes: 24 additions & 0 deletions pkg/assets/sql_scripts/move_history_fetcher.sql
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,25 @@ WITH move AS (
JOIN gsr_appeals ON gsr_appeals.id = audit_history.object_id
WHERE audit_history.table_name = 'gsr_appeals'
),
shipment_address_updates AS (
SELECT shipment_address_updates.*,
jsonb_agg(jsonb_build_object(
'status', shipment_address_updates.status
)
)::TEXT AS context
FROM shipment_address_updates
JOIN move_shipments ON shipment_address_updates.shipment_id = move_shipments.id
GROUP BY shipment_address_updates.id
),
shipment_address_updates_logs as (
SELECT audit_history.*,
shipment_address_updates.context AS context,
NULL AS context_id
FROM
audit_history
JOIN shipment_address_updates ON shipment_address_updates.id = audit_history.object_id
WHERE audit_history.table_name = 'shipment_address_updates'
),
combined_logs AS (
SELECT
*
Expand Down Expand Up @@ -732,6 +751,11 @@ WITH move AS (
*
FROM
gsr_appeals_logs
UNION
SELECT
*
FROM
shipment_address_updates_logs


)
Expand Down
6 changes: 5 additions & 1 deletion pkg/factory/mto_shipment_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func buildMTOShipmentWithBuildType(db *pop.Connection, customs []Customization,
defaultStatus = models.MTOShipmentStatusDraft
buildStorageFacility = hasStorageFacilityCustom
shipmentHasPickupDetails = true
shipmentHasDeliveryDetails = false
shipmentHasDeliveryDetails = true
case mtoShipmentNTSR:
defaultShipmentType = models.MTOShipmentTypeHHGOutOfNTS
defaultStatus = models.MTOShipmentStatusDraft
Expand All @@ -83,6 +83,10 @@ func buildMTOShipmentWithBuildType(db *pop.Connection, customs []Customization,
MarketCode: defaultMarketCode,
}

if newMTOShipment.ShipmentType == models.MTOShipmentTypeHHGIntoNTS && newMTOShipment.StorageFacility != nil {
newMTOShipment.DestinationAddress = &newMTOShipment.StorageFacility.Address
}

if cMtoShipment.Status == models.MTOShipmentStatusApproved {
approvedDate := time.Date(GHCTestYear, time.March, 20, 0, 0, 0, 0, time.UTC)
newMTOShipment.ApprovedDate = &approvedDate
Expand Down
4 changes: 2 additions & 2 deletions pkg/factory/mto_shipment_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ func (suite *FactorySuite) TestBuildMTOShipment() {
suite.NotNil(ntsShipment.PrimeActualWeight)
suite.Nil(ntsShipment.StorageFacility)
suite.NotNil(ntsShipment.ScheduledPickupDate)
suite.Nil(ntsShipment.RequestedDeliveryDate)
suite.NotNil(ntsShipment.RequestedDeliveryDate)
suite.Nil(ntsShipment.ActualDeliveryDate)
suite.Nil(ntsShipment.ScheduledDeliveryDate)
suite.NotNil(ntsShipment.ScheduledDeliveryDate)
})

suite.Run("Successful creation of NTSShipment with storage facility", func() {
Expand Down
16 changes: 14 additions & 2 deletions pkg/gen/ghcapi/embedded_spec.go

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

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

3 changes: 3 additions & 0 deletions pkg/gen/ghcmessages/counseling_update_order_payload.go

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

1 change: 1 addition & 0 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ func Order(order *models.Order) *ghcmessages.Order {
MoveCode: moveCode,
MoveTaskOrderID: moveTaskOrderID,
OriginDutyLocationGBLOC: ghcmessages.GBLOC(swag.StringValue(order.OriginDutyLocationGBLOC)),
HasDependents: order.HasDependents,
}

return &payload
Expand Down
32 changes: 32 additions & 0 deletions pkg/models/re_contract.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package models

import (
"database/sql"
"fmt"
"time"

"github.com/gobuffalo/pop/v6"
"github.com/gobuffalo/validate/v3"
"github.com/gobuffalo/validate/v3/validators"
"github.com/gofrs/uuid"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/apperror"
)

// ReContract represents a contract with pricing information
Expand All @@ -32,3 +37,30 @@ func (r *ReContract) Validate(_ *pop.Connection) (*validate.Errors, error) {
&validators.StringIsPresent{Field: r.Name, Name: "Name"},
), nil
}

func FetchContractForMove(appCtx appcontext.AppContext, moveID uuid.UUID) (ReContract, error) {
var move Move
err := appCtx.DB().Find(&move, moveID)
if err != nil {
if err == sql.ErrNoRows {
return ReContract{}, apperror.NewNotFoundError(moveID, "looking for Move")
}
return ReContract{}, err
}

if move.AvailableToPrimeAt == nil {
return ReContract{}, apperror.NewConflictError(moveID, "unable to pick contract because move is not available to prime")
}

var contractYear ReContractYear
err = appCtx.DB().EagerPreload("Contract").Where("? between start_date and end_date", move.AvailableToPrimeAt).
First(&contractYear)
if err != nil {
if err == sql.ErrNoRows {
return ReContract{}, apperror.NewNotFoundError(uuid.Nil, fmt.Sprintf("no contract year found for %s", move.AvailableToPrimeAt.String()))
}
return ReContract{}, err
}

return contractYear.Contract, nil
}
31 changes: 31 additions & 0 deletions pkg/models/re_contract_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package models_test

import (
"time"

"github.com/transcom/mymove/pkg/factory"
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/testdatagen"
)

func (suite *ModelSuite) TestReContractValidations() {
Expand All @@ -23,3 +27,30 @@ func (suite *ModelSuite) TestReContractValidations() {
suite.verifyValidationErrors(&emptyReContract, expErrors)
})
}

func (suite *ModelSuite) TestFetchContractForMove() {
suite.Run("finds valid contract", func() {
reContract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{})
testdatagen.FetchOrMakeReContractYear(suite.DB(), testdatagen.Assertions{
ReContractYear: models.ReContractYear{
Contract: reContract,
ContractID: reContract.ID,
StartDate: time.Now(),
EndDate: time.Now().Add(time.Hour * 12),
Escalation: 1.0,
EscalationCompounded: 1.0,
},
})
move := factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil)
contract, err := models.FetchContractForMove(suite.AppContextForTest(), move.ID)
suite.NoError(err)
suite.Equal(contract.ID, reContract.ID)
})

suite.Run("returns error if no contract found", func() {
move := factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil)
contract, err := models.FetchContractForMove(suite.AppContextForTest(), move.ID)
suite.Error(err)
suite.Equal(contract, models.ReContract{})
})
}
14 changes: 14 additions & 0 deletions pkg/models/re_oconus_rate_areas.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package models
import (
"time"

"github.com/gobuffalo/pop/v6"
"github.com/gofrs/uuid"
)

Expand All @@ -19,3 +20,16 @@ type OconusRateArea struct {
func (o OconusRateArea) TableName() string {
return "re_oconus_rate_areas"
}

func FetchOconusRateArea(db *pop.Connection, zip string) (*OconusRateArea, error) {
var reOconusRateArea OconusRateArea
err := db.Q().
InnerJoin("re_rate_areas ra", "re_oconus_rate_areas.rate_area_id = ra.id").
InnerJoin("us_post_region_cities upc", "upc.id = re_oconus_rate_areas.us_post_region_cities_id").
Where("upc.uspr_zip_id = ?", zip).
First(&reOconusRateArea)
if err != nil {
return nil, err
}
return &reOconusRateArea, nil
}
18 changes: 16 additions & 2 deletions pkg/models/re_rate_area.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func FetchReRateAreaItem(tx *pop.Connection, contractID uuid.UUID, code string)
}

// a db stored proc that takes in an address id & a service code to get the rate area id for an address
func FetchRateAreaID(db *pop.Connection, addressID uuid.UUID, serviceID uuid.UUID, contractID uuid.UUID) (uuid.UUID, error) {
if addressID != uuid.Nil && serviceID != uuid.Nil && contractID != uuid.Nil {
func FetchRateAreaID(db *pop.Connection, addressID uuid.UUID, serviceID *uuid.UUID, contractID uuid.UUID) (uuid.UUID, error) {
if addressID != uuid.Nil && contractID != uuid.Nil {
var rateAreaID uuid.UUID
err := db.RawQuery("SELECT get_rate_area_id($1, $2, $3)", addressID, serviceID, contractID).First(&rateAreaID)
if err != nil {
Expand All @@ -67,3 +67,17 @@ func FetchRateAreaID(db *pop.Connection, addressID uuid.UUID, serviceID uuid.UUI
}
return uuid.Nil, fmt.Errorf("error fetching rate area ID - required parameters not provided")
}

func FetchConusRateAreaByPostalCode(db *pop.Connection, zip string, contractID uuid.UUID) (*ReRateArea, error) {
var reRateArea ReRateArea
postalCode := zip[0:3]
err := db.Q().
InnerJoin("re_zip3s rz", "rz.rate_area_id = re_rate_areas.id").
Where("zip3 = ?", postalCode).
Where("re_rate_areas.contract_id = ?", contractID).
First(&reRateArea)
if err != nil {
return nil, err
}
return &reRateArea, nil
}
6 changes: 2 additions & 4 deletions pkg/models/re_rate_area_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ func (suite *ModelSuite) TestFetchRateAreaID() {
service := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeIHPK)
contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{})
address := factory.BuildAddress(suite.DB(), nil, nil)
rateAreaId, err := models.FetchRateAreaID(suite.DB(), address.ID, service.ID, contract.ID)
rateAreaId, err := models.FetchRateAreaID(suite.DB(), address.ID, &service.ID, contract.ID)
suite.NotNil(rateAreaId)
suite.NoError(err)
})

suite.Run("fail - receive error when not all values are provided", func() {
var nilUuid uuid.UUID
contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{})
address := factory.BuildAddress(suite.DB(), nil, nil)
rateAreaId, err := models.FetchRateAreaID(suite.DB(), address.ID, nilUuid, contract.ID)
rateAreaId, err := models.FetchRateAreaID(suite.DB(), address.ID, nil, uuid.Nil)
suite.Equal(uuid.Nil, rateAreaId)
suite.Error(err)
})
Expand Down
Loading

0 comments on commit a832f04

Please sign in to comment.