diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index adb316a8e2e..fb7c16d9c9b 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -1024,6 +1024,8 @@ 20241009210749_create_view_v_locations.up.sql 20241011201326_changes_for_actual_expense_reimbursement_field.up.sql 20241017183144_add_AK_HI_duty_locations.up.sql +20241023130404_create_re_service_items.up.sql 20241024114748_create_gbloc_aors.up.sql 20241029125015_add_orders_type_enum.up.sql 20241029144404_hdt-614-adjust-accomack-county.up.sql +20241111223224_change_international_sit_services_to_accessorials.up.sql diff --git a/migrations/app/schema/20241023130404_create_re_service_items.up.sql b/migrations/app/schema/20241023130404_create_re_service_items.up.sql new file mode 100644 index 00000000000..ddfc97a2c7a --- /dev/null +++ b/migrations/app/schema/20241023130404_create_re_service_items.up.sql @@ -0,0 +1,117 @@ +CREATE TABLE IF NOT EXISTS re_service_items +(id uuid NOT NULL, +service_id uuid NOT NULL + CONSTRAINT fk_re_service_items_service_id REFERENCES re_services (id), +shipment_type mto_shipment_type NOT NULL, +market_code market_code_enum NOT NULL, +is_auto_approved bool NOT NULL, +created_at timestamp NOT NULL DEFAULT NOW(), +updated_at timestamp NOT NULL DEFAULT NOW(), +CONSTRAINT re_service_items_pkey PRIMARY KEY (id), +CONSTRAINT unique_re_service_items UNIQUE (service_id, shipment_type, market_code) +); + +COMMENT ON TABLE re_service_items IS 'Associates service items to market_code and shipment_type.'; +COMMENT ON COLUMN re_service_items.service_id IS 'The associated id for the service item'; +COMMENT ON COLUMN re_service_items.shipment_type IS 'The type of shipment from mto_shipments table.'; +COMMENT ON COLUMN re_service_items.market_code IS 'Market code indicator. i for international and d for domestic.'; +COMMENT ON COLUMN re_service_items.is_auto_approved IS 'Set to true if the service item is automatically approved when assigned to the shipment.'; + +--Create enum type for service_location +CREATE TYPE service_location_enum AS ENUM ( + 'O', --Origin + 'D', --Destination + 'B'); --Both + +--Add service_location to re_services +ALTER TABLE re_services ADD COLUMN IF NOT EXISTS service_location service_location_enum; +COMMENT ON COLUMN re_services.service_location IS 'Specifies where this service item may be billed at (Origin, Destination or Both)'; + +--Add service_location to mto_service_items +ALTER TABLE mto_service_items ADD COLUMN IF NOT EXISTS service_location service_location_enum; +COMMENT ON COLUMN mto_service_items.service_location IS 'Specifies the responsible billing location for this service item (Origin or Destination)'; + +--Add new international service items +INSERT INTO public.re_services +(id, code, name, created_at, updated_at, priority, service_location) +VALUES('fafad6c2-6037-4a95-af2f-d9861ba7db8e', 'UBP', 'International UB', now(), now(), 99, 'B'); + +INSERT INTO public.re_services +(id, code, name, created_at, updated_at, priority, service_location) +VALUES('9f3d551a-0725-430e-897e-80ee9add3ae9', 'ISLH', 'International Shipping & Linehaul', now(), now(), 99, 'B'); + +INSERT INTO public.re_services +(id, code, name, created_at, updated_at, priority, service_location) +VALUES('f75758d8-2fcd-40ba-9432-3ff3032a71d1', 'POEFSC', 'International POE Fuel Surcharge', now(), now(), 99, 'O'); + +INSERT INTO public.re_services +(id, code, name, created_at, updated_at, priority, service_location) +VALUES('388115e8-abe9-441d-96cf-a39f24baa0a3', 'PODFSC', 'International POD Fuel Surcharge', now(), now(), 99, 'D'); + +INSERT INTO public.re_services +(id, code, name, created_at, updated_at, priority, service_location) +VALUES('81e29d0c-02a6-4a7a-be02-554deb3ee49e', 'IOSFSC', 'International Origin SIT Fuel Surcharge', now(), now(), 99, 'O'); + +INSERT INTO public.re_services +(id, code, name, created_at, updated_at, priority, service_location) +VALUES('690a5fc1-0ea5-4554-8294-a367b5daefa9', 'IDSFSC', 'International Destination SIT Fuel Surcharge', now(), now(), 99, 'D'); + +--update existing re_services +update re_services set service_location = 'O' where code in ('IUBPK','IHPK','IOASIT','IOFSIT','IOPSIT','IOSHUT','ICRT'); +update re_services set service_location = 'D' where code in ('IUBUPK','IHUPK','IDASIT','IDFSIT','IDDSIT','IDSHUT','IUCRT'); + +INSERT INTO re_service_items (id,service_id,shipment_type,market_code,is_auto_approved,created_at,updated_at) VALUES + ('2933a8a0-5d89-4fcb-99f0-60893edf8c8a'::uuid,'f75758d8-2fcd-40ba-9432-3ff3032a71d1'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('6b2dedf0-389f-41b7-908e-22a8ecaa320c'::uuid,'388115e8-abe9-441d-96cf-a39f24baa0a3'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('df4f7cbe-10d7-4042-a380-657835d408e1'::uuid,'fafad6c2-6037-4a95-af2f-d9861ba7db8e'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('78bde6ed-9fac-442b-aa74-dfba1a537336'::uuid,'ae84d292-f885-4138-86e2-b451855ffbf2'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('c4089abd-3225-4986-a5d9-37b46ae5b645'::uuid,'f2739142-97d1-40f3-a8f4-6a9daf390806'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('ba2dc894-163d-4db9-81e3-0259dc66a70f'::uuid,'f75758d8-2fcd-40ba-9432-3ff3032a71d1'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('c361227b-1aae-49ec-bcbb-30f663d70445'::uuid,'388115e8-abe9-441d-96cf-a39f24baa0a3'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('567f3d6d-c1a4-46fe-9424-4b60f1dba939'::uuid,'9f3d551a-0725-430e-897e-80ee9add3ae9'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('2008074d-e447-4619-b2bd-fe2a38a2759e'::uuid,'67ba1eaf-6ffd-49de-9a69-497be7789877'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('daf7b541-f9d1-4b1a-998b-d530ca48da3e'::uuid,'56e91c2d-015d-4243-9657-3ed34867abaa'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('32be29e1-5269-4fd0-85b4-03270cbe6a65'::uuid,'86203d72-7f7c-49ff-82f0-5b95e4958f60'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()); +INSERT INTO re_service_items (id,service_id,shipment_type,market_code,is_auto_approved,created_at,updated_at) VALUES + ('0ee7f930-6421-44b0-8820-48bffc2b2605'::uuid,'806c6d59-57ff-4a3f-9518-ebf29ba9cb10'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('e555e8a5-23bf-40ea-9ee8-01479c971716'::uuid,'28389ee1-56cf-400c-aa52-1501ecdd7c69'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('2705b054-3a05-492d-9262-3a6d4125c268'::uuid,'bd6064ca-e780-4ab4-a37b-0ae98eebb244'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('cbed2e49-799e-42c0-bd86-4204c3ca049d'::uuid,'22fc07ed-be15-4f50-b941-cbd38153b378'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('60be16ad-8d92-4e51-b565-7ef7904f4fe9'::uuid,'bd424e45-397b-4766-9712-de4ae3a2da36'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('c1000d89-ae2b-47bc-b3b1-63c2c24fc076'::uuid,'b488bf85-ea5e-49c8-ba5c-e2fa278ac806'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('b09f964d-fee7-4bf9-84ea-c06571b7ef51'::uuid,'6f4f6e31-0675-4051-b659-89832259f390'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('ab8981ca-b3f0-4421-8753-95860ca40cfb'::uuid,'624a97c5-dfbf-4da9-a6e9-526b4f95af8d'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('4d09972f-5fb3-44a2-bd0e-4b21f716e222'::uuid,'4132416b-b1aa-42e7-98f2-0ac0a03e8a31'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()); +INSERT INTO re_service_items (id,service_id,shipment_type,market_code,is_auto_approved,created_at,updated_at) VALUES + ('28487c9e-a91b-4870-b2e3-fbefb6a324e6'::uuid,'86203d72-7f7c-49ff-82f0-5b95e4958f60'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('6bfeb792-7f08-4b33-904d-f837dc69c097'::uuid,'806c6d59-57ff-4a3f-9518-ebf29ba9cb10'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('f896c537-14e8-4612-833c-794d0ada17b8'::uuid,'28389ee1-56cf-400c-aa52-1501ecdd7c69'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('3d5cc86e-bd3a-49e0-a041-63e0625e690f'::uuid,'bd6064ca-e780-4ab4-a37b-0ae98eebb244'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('6d4cc684-55ba-4308-864f-76846ec66cf1'::uuid,'22fc07ed-be15-4f50-b941-cbd38153b378'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('3c3e99f3-bf63-48b9-9101-a9f8b91afea3'::uuid,'bd424e45-397b-4766-9712-de4ae3a2da36'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('047fcb9f-4b90-454b-aca4-3561b46e4de9'::uuid,'b488bf85-ea5e-49c8-ba5c-e2fa278ac806'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()); +INSERT INTO re_service_items (id,service_id,shipment_type,market_code,is_auto_approved,created_at,updated_at) VALUES + ('d6c8ce58-bc00-499f-9cad-9047210b8746'::uuid,'6f4f6e31-0675-4051-b659-89832259f390'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('6799f4b5-c4ba-48e4-a4bd-c6adb71b7041'::uuid,'624a97c5-dfbf-4da9-a6e9-526b4f95af8d'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('faa6dc9d-e120-4d26-a54b-b84a2b2f6d7c'::uuid,'4132416b-b1aa-42e7-98f2-0ac0a03e8a31'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",false,now(),now()), + ('cdc719ba-8f57-4b11-80a0-f416413b0064'::uuid,'81e29d0c-02a6-4a7a-be02-554deb3ee49e'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('b56b974c-ce60-4efc-bf79-553d8094d18a'::uuid,'690a5fc1-0ea5-4554-8294-a367b5daefa9'::uuid,'HHG'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('a5b07f41-b279-44c0-9ecd-241bd8a5c2eb'::uuid,'81e29d0c-02a6-4a7a-be02-554deb3ee49e'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()), + ('39cd5798-f0b1-49a6-b9fe-0f4f4039b80b'::uuid,'690a5fc1-0ea5-4554-8294-a367b5daefa9'::uuid,'UNACCOMPANIED_BAGGAGE'::public."mto_shipment_type",'i'::public."market_code_enum",true,now(),now()); + +--Point existing UB service pricing to new UBP service +update re_intl_prices +set service_id = (select id from re_services where code = 'UBP') +where service_id in (select id from re_services where code in ('IOCUB','ICOUB','IOOUB','NSTUB')); + +update re_intl_prices +set service_id = (select id from re_services where code = 'ISLH') +where service_id in (select id from re_services where code in ('IOCLH','ICOLH','IOOLH','NSTH')); + +--Remove UB stuff from service_params as we don't need it. +delete from service_params sp +where service_id in (select id from re_services where code in ('IOCUB','ICOUB','IOOUB','NSTUB','IOCLH','ICOLH','IOOLH','NSTH')); + +--Remove obsolete UB service itmes from re_services +delete from re_services rs +where code in ('IOCUB','ICOUB','IOOUB','NSTUB','IOCLH','ICOLH','IOOLH','NSTH'); \ No newline at end of file diff --git a/migrations/app/schema/20241111223224_change_international_sit_services_to_accessorials.up.sql b/migrations/app/schema/20241111223224_change_international_sit_services_to_accessorials.up.sql new file mode 100644 index 00000000000..b72b61f2fa2 --- /dev/null +++ b/migrations/app/schema/20241111223224_change_international_sit_services_to_accessorials.up.sql @@ -0,0 +1,4 @@ +--Set auto approved to false for IOSFSC and IDSFSC +update re_service_items +set is_auto_approved = false +where service_id in ('81e29d0c-02a6-4a7a-be02-554deb3ee49e', '690a5fc1-0ea5-4554-8294-a367b5daefa9'); \ No newline at end of file diff --git a/pkg/factory/mto_service_item_factory.go b/pkg/factory/mto_service_item_factory.go index c39d7680d4b..d9e18ed0a90 100644 --- a/pkg/factory/mto_service_item_factory.go +++ b/pkg/factory/mto_service_item_factory.go @@ -50,9 +50,9 @@ func buildMTOServiceItemWithBuildType(db *pop.Connection, customs []Customizatio var reService models.ReService if result := findValidCustomization(customs, ReService); result != nil { - reService = FetchOrBuildReService(db, customs, nil) + reService = FetchReService(db, customs, nil) } else { - reService = FetchOrBuildReServiceByCode(db, models.ReServiceCode("STEST")) + reService = FetchReServiceByCode(db, models.ReServiceCode("DLH")) } requestedApprovalsRequestedStatus := false @@ -606,7 +606,7 @@ func BuildRealMTOServiceItemWithAllDeps(db *pop.Connection, serviceCode models.R // look up the service item param keys we need if serviceItemParamKeys, ok := fixtureServiceItemParamsMap[serviceCode]; ok { // get or create the ReService - reService := FetchOrBuildReServiceByCode(db, serviceCode) + reService := FetchReServiceByCode(db, serviceCode) // create all params defined for this particular service for _, serviceParamKeyToCreate := range serviceItemParamKeys { diff --git a/pkg/factory/mto_service_item_factory_test.go b/pkg/factory/mto_service_item_factory_test.go index b716d26317c..0560384306b 100644 --- a/pkg/factory/mto_service_item_factory_test.go +++ b/pkg/factory/mto_service_item_factory_test.go @@ -48,8 +48,8 @@ func (suite *FactorySuite) TestBuildMTOServiceItem() { Status: models.MTOShipmentStatusDraft, } customReService := models.ReService{ - Name: "Custom Name", - Code: models.ReServiceCode("CNAME"), + Name: "Domestic linehaul", + Code: models.ReServiceCode("DLH"), } customMtoServiceItem := models.MTOServiceItem{ Status: models.MTOServiceItemStatusRejected, @@ -236,7 +236,7 @@ func (suite *FactorySuite) TestBuildMTOServiceItem() { mtoServiceItem := BuildRealMTOServiceItemWithAllDeps(suite.DB(), models.ReServiceCodeMS, move, shipment, nil, nil) - reService := FetchOrBuildReServiceByCode(suite.DB(), models.ReServiceCodeMS) + reService := FetchReServiceByCode(suite.DB(), models.ReServiceCodeMS) suite.Equal(move.ID, mtoServiceItem.MoveTaskOrderID) suite.NotNil(mtoServiceItem.MTOShipmentID) diff --git a/pkg/factory/re_service_factory.go b/pkg/factory/re_service_factory.go index cf402974d56..9ac6ee546b4 100644 --- a/pkg/factory/re_service_factory.go +++ b/pkg/factory/re_service_factory.go @@ -5,54 +5,24 @@ import ( "log" "github.com/gobuffalo/pop/v6" - "github.com/gofrs/uuid" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/testdatagen" ) -const defaultServiceCode = models.ReServiceCode("STEST") +const defaultServiceCode = models.ReServiceCode("DLH") -// BuildReService creates a ReService -// Params: -// - customs is a slice that will be modified by the factory -// - db can be set to nil to create a stubbed model that is not stored in DB. -func BuildReService(db *pop.Connection, customs []Customization, traits []Trait) models.ReService { - customs = setupCustomizations(customs, traits) - - // Find reService assertion and convert to models ReService - var cReService models.ReService - if result := findValidCustomization(customs, ReService); result != nil { - cReService = result.Model.(models.ReService) - if result.LinkOnly { - return cReService - } - } - - // create reService - reServiceUUID := uuid.Must(uuid.NewV4()) - reService := models.ReService{ - ID: reServiceUUID, - Name: "Test Service", - Code: defaultServiceCode, - } - - // Overwrite values with those from assertions - testdatagen.MergeModels(&reService, cReService) - - // If db is false, it's a stub. No need to create in database - if db != nil { - mustCreate(db, &reService) +func fetchDefaultReService(db *pop.Connection) models.ReService { + var reService models.ReService + err := db.Where("code = $1", defaultServiceCode).First(&reService) + if err != nil && err != sql.ErrNoRows { + log.Panic(err) } - return reService } -// FetchOrBuildReService tries fetching a ReService using ReServiceCode, then falls back to creating one -func FetchOrBuildReService(db *pop.Connection, customs []Customization, traits []Trait) models.ReService { - if db == nil { - return BuildReService(db, customs, traits) - } +// FetchReService tries fetching a ReService using ReServiceCode, then falls back to creating one +func FetchReService(db *pop.Connection, customs []Customization, traits []Trait) models.ReService { customs = setupCustomizations(customs, traits) @@ -64,6 +34,17 @@ func FetchOrBuildReService(db *pop.Connection, customs []Customization, traits [ return cReService } } + + if db == nil { + defaultReService := models.ReService{ + Name: "Domestic linehaul", + Code: defaultServiceCode, + } + // Overwrite values with those from assertions + testdatagen.MergeModels(&defaultReService, cReService) + return defaultReService + } + var reService models.ReService if !cReService.ID.IsNil() { err := db.Where("ID = $1", cReService.ID).First(&reService) @@ -87,11 +68,11 @@ func FetchOrBuildReService(db *pop.Connection, customs []Customization, traits [ return reService } - return BuildReService(db, customs, traits) + return fetchDefaultReService(db) } -func FetchOrBuildReServiceByCode(db *pop.Connection, reServiceCode models.ReServiceCode) models.ReService { - return FetchOrBuildReService(db, []Customization{ +func FetchReServiceByCode(db *pop.Connection, reServiceCode models.ReServiceCode) models.ReService { + return FetchReService(db, []Customization{ { Model: models.ReService{ Code: reServiceCode, @@ -99,32 +80,3 @@ func FetchOrBuildReServiceByCode(db *pop.Connection, reServiceCode models.ReServ }, }, nil) } - -// BuildReServiceByCode builds ReService using ReServiceCode -func BuildReServiceByCode(db *pop.Connection, reServiceCode models.ReServiceCode) models.ReService { - return BuildReService(db, []Customization{ - { - Model: models.ReService{ - Code: reServiceCode, - }, - }, - }, nil) -} - -// BuildDDFSITReService creates the three destination SIT service codes: DDFSIT, DDASIT, DDDSIT. Returns DDFSIT only. -func BuildDDFSITReService(db *pop.Connection) models.ReService { - reService := FetchOrBuildReServiceByCode(db, models.ReServiceCodeDDFSIT) - FetchOrBuildReServiceByCode(db, models.ReServiceCodeDDASIT) - FetchOrBuildReServiceByCode(db, models.ReServiceCodeDDDSIT) - FetchOrBuildReServiceByCode(db, models.ReServiceCodeDDSFSC) - return reService -} - -// BuildDOFSITReService creates the three origin SIT service codes: DOFSIT, DOPSIT, DOASIT. Returns DOFSIT only. -func BuildDOFSITReService(db *pop.Connection) models.ReService { - reService := FetchOrBuildReServiceByCode(db, models.ReServiceCodeDOFSIT) - FetchOrBuildReServiceByCode(db, models.ReServiceCodeDOASIT) - FetchOrBuildReServiceByCode(db, models.ReServiceCodeDOPSIT) - FetchOrBuildReServiceByCode(db, models.ReServiceCodeDOSFSC) - return reService -} diff --git a/pkg/factory/re_service_factory_test.go b/pkg/factory/re_service_factory_test.go index eb8572e8e10..fcfe03da8ee 100644 --- a/pkg/factory/re_service_factory_test.go +++ b/pkg/factory/re_service_factory_test.go @@ -1,53 +1,47 @@ package factory import ( - "github.com/gofrs/uuid" - "github.com/transcom/mymove/pkg/models" ) -func (suite *FactorySuite) TestBuildReService() { +func (suite *FactorySuite) TestFetchReService() { suite.Run("Successful creation of default reService (customer)", func() { - // Under test: BuildReService + // Under test: FetchReService // Mocked: None // Set up: Create a ReService with no customizations or traits // Expected outcome:ReService should be created with default values - defaultReServiceCode := models.ReServiceCode("STEST") - reService := BuildReService(suite.DB(), nil, nil) + defaultReServiceCode := models.ReServiceCode("DLH") + reService := FetchReService(suite.DB(), nil, nil) suite.Equal(defaultReServiceCode, reService.Code) }) - suite.Run("Successful creation of reService with customization", func() { - // Under test: BuildReService + suite.Run("Successful retrieval of ReService", func() { + // Under test: FetchReService // Set up: Create a ReService with a customized email and no trait - // Expected outcome:ReService should be created with email and inactive status + // Expected outcome:ReService should be returned customReService := models.ReService{ - ID: uuid.Must(uuid.NewV4()), - Code: models.ReServiceCodeCS, - Name: "Counseling", - Priority: 2, + Code: models.ReServiceCodeCS, + Name: "Counseling", } - reService := BuildReService(suite.DB(), []Customization{ + reService := FetchReService(suite.DB(), []Customization{ { Model: customReService, }, }, nil) - suite.Equal(customReService.ID, reService.ID) - suite.Equal(customReService.Code, reService.Code) - suite.Equal(customReService.Name, reService.Name) - suite.Equal(customReService.Priority, reService.Priority) + suite.Equal(models.ReServiceCodeCS, reService.Code) + suite.Equal("Counseling", reService.Name) }) suite.Run("Successful creation of stubbed reService", func() { - // Under test: BuildReService + // Under test: FetchReService // Set up: Create a customized reService, but don't pass in a db // Expected outcome:ReService should be created with email and active status // No reService should be created in database precount, err := suite.DB().Count(&models.ReService{}) suite.NoError(err) - reService := BuildReService(nil, []Customization{ + reService := FetchReService(nil, []Customization{ { Model: models.ReService{ Code: models.ReServiceCodeCS, @@ -64,14 +58,14 @@ func (suite *FactorySuite) TestBuildReService() { } -func (suite *FactorySuite) TestBuildReServiceHelpers() { - suite.Run("FetchOrBuildReService - reService exists", func() { - // Under test: FetchOrBuildReService - // Set up: Create a reService, then call FetchOrBuildReService +func (suite *FactorySuite) TestReServiceHelpers() { + suite.Run("FetchReService - reService exists", func() { + // Under test: FetchReService + // Set up: Create a reService, then call FetchReService // Expected outcome:Existing ReService should be returned // No new reService should be created in database - ServicesCounselorReService := BuildReService(suite.DB(), []Customization{ + ServicesCounselorReService := FetchReService(suite.DB(), []Customization{ { Model: models.ReService{ Code: models.ReServiceCodeCS, @@ -83,7 +77,7 @@ func (suite *FactorySuite) TestBuildReServiceHelpers() { precount, err := suite.DB().Count(&models.ReService{}) suite.NoError(err) - reService := FetchOrBuildReService(suite.DB(), []Customization{ + reService := FetchReService(suite.DB(), []Customization{ { Model: models.ReService{ Code: models.ReServiceCodeCS, @@ -100,13 +94,13 @@ func (suite *FactorySuite) TestBuildReServiceHelpers() { suite.Equal(precount, count) }) - suite.Run("FetchOrBuildReServiceByCode - reService exists", func() { - // Under test: FetchOrBuildReServiceByCode - // Set up: Create a reService, then call FetchOrBuildReServiceByCode + suite.Run("FetchReServiceByCode - reService exists", func() { + // Under test: FetchReServiceByCode + // Set up: Create a reService, then call FetchReServiceByCode // Expected outcome:Existing ReService should be returned // No new reService should be created in database - ServicesCounselorReService := BuildReService(suite.DB(), []Customization{ + ServicesCounselorReService := FetchReService(suite.DB(), []Customization{ { Model: models.ReService{ Code: models.ReServiceCodeCS, @@ -118,7 +112,7 @@ func (suite *FactorySuite) TestBuildReServiceHelpers() { precount, err := suite.DB().Count(&models.ReService{}) suite.NoError(err) - reService := FetchOrBuildReServiceByCode(suite.DB(), models.ReServiceCodeCS) + reService := FetchReServiceByCode(suite.DB(), models.ReServiceCodeCS) suite.NoError(err) suite.Equal(ServicesCounselorReService.Code, reService.Code) suite.Equal(ServicesCounselorReService.ID, reService.ID) @@ -129,77 +123,67 @@ func (suite *FactorySuite) TestBuildReServiceHelpers() { suite.Equal(precount, count) }) - suite.Run("FetchOrBuildReService - reService does not exists", func() { - // Under test: FetchOrBuildReService - // Set up: Call FetchOrBuildReService with a non-existent reService + suite.Run("FetchReService - reService does not exists", func() { + // Under test: FetchReService + // Set up: Call FetchReService with a non-existent reService // Expected outcome:new reService is created - precount, err := suite.DB().Count(&models.ReService{}) - suite.NoError(err) - customReService := models.ReService{ Name: "custom name", - Code: models.ReServiceCodeCS, + Code: "Not a real service", } - reService := FetchOrBuildReService(suite.DB(), []Customization{ + reService := FetchReService(suite.DB(), []Customization{ { Model: customReService, }, }, nil) - suite.NoError(err) - suite.Equal(customReService.Code, reService.Code) - suite.Equal(customReService.Name, reService.Name) + suite.Equal(models.ReServiceCodeDLH, reService.Code) + suite.Equal("Domestic linehaul", reService.Name) // find by ID customReServiceByID := models.ReService{ ID: reService.ID, } - reService = FetchOrBuildReService(suite.DB(), []Customization{ + reService = FetchReService(suite.DB(), []Customization{ { Model: customReServiceByID, }, }, nil) - suite.NoError(err) - - suite.Equal(customReServiceByID.ID, reService.ID) - suite.Equal(customReService.Code, reService.Code) - suite.Equal(customReService.Name, reService.Name) - // Count how many reServices are in the DB, new reService should have been created. - count, err := suite.DB().Count(&models.ReService{}) - suite.NoError(err) - suite.Equal(precount+1, count) + suite.Equal(reService.ID, reService.ID) + suite.Equal(reService.Code, reService.Code) + suite.Equal(reService.Name, reService.Name) }) - suite.Run("FetchOrBuildReServiceByCode - reService does not exists", func() { - // Under test: FetchOrBuildReServiceByCode - // Set up: Call FetchOrBuildReServiceByCode with a non-existent reService - // Expected outcome:new reService is created + suite.Run("FetchReServiceByCode - reService does not exists", func() { + // Under test: FetchReServiceByCode + // Set up: Call FetchReServiceByCode with a non-existent reService + // Expected outcome:new reService is NOT created precount, err := suite.DB().Count(&models.ReService{}) suite.NoError(err) - reService := FetchOrBuildReServiceByCode(suite.DB(), models.ReServiceCodeCS) + reService := FetchReServiceByCode(suite.DB(), "Not a real service") suite.NoError(err) - suite.Equal(models.ReServiceCodeCS, reService.Code) + suite.Equal(models.ReServiceCodeDLH, reService.Code) - // Count how many reServices are in the DB, new reService should have been created. + // Count how many reServices are in the DB, new reService should NOT have been created. count, err := suite.DB().Count(&models.ReService{}) suite.NoError(err) - suite.Equal(precount+1, count) + suite.Equal(precount, count) }) - suite.Run("FetchOrBuildReServiceByCode - stubbed reService", func() { - // Under test: FetchOrBuildReServiceByCode - // Set up: Call FetchOrBuildReServiceByCode without a db + suite.Run("FetchReServiceByCode - stubbed reService", func() { + // Under test: FetchReServiceByCode + // Set up: Call FetchReServiceByCode without a db // Expected outcome:ReService is created but not saved to db precount, err := suite.DB().Count(&models.ReService{}) suite.NoError(err) - reService := FetchOrBuildReServiceByCode(nil, models.ReServiceCodeCS) + reService := FetchReServiceByCode(nil, models.ReServiceCodeCS) suite.NoError(err) suite.Equal(models.ReServiceCodeCS, reService.Code) @@ -210,86 +194,47 @@ func (suite *FactorySuite) TestBuildReServiceHelpers() { suite.Equal(precount, count) }) - suite.Run("BuildReServiceByCode", func() { - // Under test: BuildDDFSITReService - // Set up: Call BuildDDFSITReService with ReServiceCodeCS - // Expected outcome:ReService is created + suite.Run("FetchReServiceByCode", func() { + // Under test: FetchReServiceByCode + // Set up: Call FetchReServiceByCode with ReServiceCodeCS + // Expected outcome:ReService is returned - reService := BuildReServiceByCode(suite.DB(), models.ReServiceCodeCS) + reService := FetchReServiceByCode(suite.DB(), models.ReServiceCodeCS) suite.Equal(models.ReServiceCodeCS, reService.Code) }) - suite.Run("BuildDDFSITReService", func() { - // Under test: BuildDDFSITReService - // Set up: Call BuildDDFSITReService - // Expected outcome:DDFSIT reservice is returned. DDASIT, DDDSIT, and DDSFSC are also created + suite.Run("FetchReServiceByCode", func() { + // Under test: FetchReServiceByCode + // Set up: Call FetchReServiceByCode + // Expected outcome:DDFSIT reservice is returned. DDASIT, DDDSIT, and DDSFSC are also returned. - precount, err := suite.DB().Count(&models.ReService{}) - suite.NoError(err) + reService := FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) + suite.Equal(models.ReServiceCodeDDFSIT, reService.Code) - reService := BuildDDFSITReService(suite.DB()) - suite.NoError(err) + reService = FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) + suite.Equal(models.ReServiceCodeDDASIT, reService.Code) - suite.Equal(models.ReServiceCodeDDFSIT, reService.Code) + reService = FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDDSIT) + suite.Equal(models.ReServiceCodeDDDSIT, reService.Code) - // Count how many reServices are in the DB, 3 new reServices should have been created. - var reServices []models.ReService - var hasDDASIT, hasDDDSIT, hasDDSFSC bool - err = suite.DB().All(&reServices) - suite.NoError(err) - suite.Equal(precount+4, len(reServices)) - for _, service := range reServices { - if service.Code == models.ReServiceCodeDDASIT { - hasDDASIT = true - continue - } - if service.Code == models.ReServiceCodeDDDSIT { - hasDDDSIT = true - continue - } - if service.Code == models.ReServiceCodeDDSFSC { - hasDDSFSC = true - } - } - suite.True(hasDDASIT) - suite.True(hasDDDSIT) - suite.True(hasDDSFSC) + reService = FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDSFSC) + suite.Equal(models.ReServiceCodeDDSFSC, reService.Code) }) - suite.Run("BuildDOFSITReService", func() { - // Under test: BuildDOFSITReService - // Set up: Call BuildDOFSITReService - // Expected outcome:DOFSIT reservice is returned. DOPSIT and DOASIT are also created + suite.Run("FetchReServiceByCode", func() { + // Under test: FetchReServiceByCode + // Expected outcome:DOFSIT, DOASIT, DOPSIT, DOSFSC reservices are returned - precount, err := suite.DB().Count(&models.ReService{}) - suite.NoError(err) + reService := FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + suite.Equal(models.ReServiceCodeDOFSIT, reService.Code) - reService := BuildDOFSITReService(suite.DB()) - suite.NoError(err) + reService = FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) + suite.Equal(models.ReServiceCodeDOASIT, reService.Code) - suite.Equal(models.ReServiceCodeDOFSIT, reService.Code) + reService = FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOPSIT) + suite.Equal(models.ReServiceCodeDOPSIT, reService.Code) - // Count how many reServices are in the DB, 3 new reServices should have been created. - var reServices []models.ReService - var hasDOPSIT, hasDOASIT, hasDOSFSC bool - err = suite.DB().All(&reServices) - suite.NoError(err) - suite.Equal(precount+4, len(reServices)) - for _, service := range reServices { - if service.Code == models.ReServiceCodeDOPSIT { - hasDOPSIT = true - continue - } - if service.Code == models.ReServiceCodeDOASIT { - hasDOASIT = true - continue - } - if service.Code == models.ReServiceCodeDOSFSC { - hasDOSFSC = true - } - } - suite.True(hasDOPSIT) - suite.True(hasDOASIT) - suite.True(hasDOSFSC) + reService = FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOSFSC) + suite.Equal(models.ReServiceCodeDOSFSC, reService.Code) }) } diff --git a/pkg/factory/service_param_factory.go b/pkg/factory/service_param_factory.go index e07708d2a42..c9dbf995d29 100644 --- a/pkg/factory/service_param_factory.go +++ b/pkg/factory/service_param_factory.go @@ -33,7 +33,7 @@ func BuildServiceParam(db *pop.Connection, customs []Customization, traits []Tra } } - reService := FetchOrBuildReService(db, customs, traits) + reService := FetchReService(db, customs, traits) serviceItemParamKey := FetchOrBuildServiceItemParamKey(db, customs, traits) @@ -83,7 +83,7 @@ func FetchOrBuildServiceParam(db *pop.Connection, customs []Customization, trait } } - reService := FetchOrBuildReService(db, customs, traits) + reService := FetchReService(db, customs, traits) serviceItemParamKey := FetchOrBuildServiceItemParamKey(db, customs, traits) existingServiceParam := models.ServiceParam{} diff --git a/pkg/factory/service_param_factory_test.go b/pkg/factory/service_param_factory_test.go index b068ddfae0c..a09de3cbc24 100644 --- a/pkg/factory/service_param_factory_test.go +++ b/pkg/factory/service_param_factory_test.go @@ -32,7 +32,7 @@ func (suite *FactorySuite) TestBuildServiceParam() { IsOptional: false, } - reService := BuildDOFSITReService(suite.DB()) + reService := FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) serviceItemParamKey := BuildServiceItemParamKey(suite.DB(), []Customization{ { diff --git a/pkg/handlers/ghcapi/move_task_order_test.go b/pkg/handlers/ghcapi/move_task_order_test.go index 3e7982f7576..85232a4dc1d 100644 --- a/pkg/handlers/ghcapi/move_task_order_test.go +++ b/pkg/handlers/ghcapi/move_task_order_test.go @@ -42,8 +42,8 @@ import ( func (suite *HandlerSuite) TestGetMoveTaskOrderHandlerIntegration() { moveTaskOrder := factory.BuildMove(suite.DB(), nil, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeMS) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeCS) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeMS) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeCS) request := httptest.NewRequest("GET", "/move-task-orders/{moveTaskOrderID}", nil) params := movetaskorderops.GetMoveTaskOrderParams{ @@ -89,7 +89,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationSuccess() { }, }) - service := factory.FetchOrBuildReServiceByCode(suite.DB(), "MS") + service := factory.FetchReServiceByCode(suite.DB(), "MS") msTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: service.ID, @@ -97,7 +97,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationSuccess() { } suite.MustSave(&msTaskOrderFee) - service = factory.FetchOrBuildReServiceByCode(suite.DB(), "CS") + service = factory.FetchReServiceByCode(suite.DB(), "CS") csTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: service.ID, diff --git a/pkg/handlers/ghcapi/mto_service_items_test.go b/pkg/handlers/ghcapi/mto_service_items_test.go index 3b0b3e74d1b..9b6ae2bcf2f 100644 --- a/pkg/handlers/ghcapi/mto_service_items_test.go +++ b/pkg/handlers/ghcapi/mto_service_items_test.go @@ -45,7 +45,7 @@ func (suite *HandlerSuite) TestListMTOServiceItemHandler() { setupTestData := func() (models.User, models.MTOServiceItems) { mto := factory.BuildMove(suite.DB(), nil, nil) mtoID = mto.ID - reService := factory.BuildReService(suite.DB(), []factory.Customization{ + reService := factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ ID: reServiceID, diff --git a/pkg/handlers/ghcapi/mto_shipment_test.go b/pkg/handlers/ghcapi/mto_shipment_test.go index aa96acd49f0..083cf93475e 100644 --- a/pkg/handlers/ghcapi/mto_shipment_test.go +++ b/pkg/handlers/ghcapi/mto_shipment_test.go @@ -591,19 +591,6 @@ func (suite *HandlerSuite) TestApproveShipmentHandler() { }, }, }, nil) - // Populate the reServices table with codes needed by the - // HHG_LONGHAUL_DOMESTIC shipment type - reServiceCodes := []models.ReServiceCode{ - models.ReServiceCodeDLH, - models.ReServiceCodeFSC, - models.ReServiceCodeDOP, - models.ReServiceCodeDDP, - models.ReServiceCodeDPK, - models.ReServiceCodeDUPK, - } - for _, serviceCode := range reServiceCodes { - factory.BuildReServiceByCode(suite.DB(), serviceCode) - } eTag := etag.GenerateEtag(shipment.UpdatedAt) officeUser := factory.BuildOfficeUserWithRoles(nil, nil, []roles.RoleType{roles.RoleTypeTOO}) diff --git a/pkg/handlers/ghcapi/payment_request_test.go b/pkg/handlers/ghcapi/payment_request_test.go index 33eb7ec946a..3d2f116accc 100644 --- a/pkg/handlers/ghcapi/payment_request_test.go +++ b/pkg/handlers/ghcapi/payment_request_test.go @@ -24,7 +24,7 @@ import ( ) func (suite *HandlerSuite) TestFetchPaymentRequestHandler() { - expectedServiceItemName := "Test Service" + expectedServiceItemName := "Domestic linehaul" expectedShipmentType := models.MTOShipmentTypeHHG setupTestData := func() (models.PaymentServiceItemParam, models.OfficeUser) { @@ -125,7 +125,7 @@ func (suite *HandlerSuite) TestFetchPaymentRequestHandler() { } func (suite *HandlerSuite) TestGetPaymentRequestsForMoveHandler() { - expectedServiceItemName := "Test Service" + expectedServiceItemName := "Domestic linehaul" expectedShipmentType := models.MTOShipmentTypeHHG var moveLocator string diff --git a/pkg/handlers/ghcapi/ppm_shipment_test.go b/pkg/handlers/ghcapi/ppm_shipment_test.go index 19dec755bf1..b476066d53a 100644 --- a/pkg/handlers/ghcapi/ppm_shipment_test.go +++ b/pkg/handlers/ghcapi/ppm_shipment_test.go @@ -123,7 +123,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - dopService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOP) + dopService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -151,7 +151,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - ddpService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDP) + ddpService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -179,7 +179,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - dpkService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDPK) + dpkService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -205,7 +205,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - dupkService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDUPK) + dupkService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDUPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -231,7 +231,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - dofsitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + dofsitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -259,7 +259,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - doasitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) + doasitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -287,7 +287,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - ddfsitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) + ddfsitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -315,7 +315,7 @@ func (suite *HandlerSuite) TestGetPPMSITEstimatedCostHandler() { }, }) - ddasitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) + ddasitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ diff --git a/pkg/handlers/primeapi/mto_service_item_test.go b/pkg/handlers/primeapi/mto_service_item_test.go index b635bb4d124..c3e8b9daef6 100644 --- a/pkg/handlers/primeapi/mto_service_item_test.go +++ b/pkg/handlers/primeapi/mto_service_item_test.go @@ -52,7 +52,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) req := httptest.NewRequest("POST", "/mto-service-items", nil) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -129,7 +129,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { }, }, nil) mtoShipment.PrimeEstimatedWeight = nil - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) req := httptest.NewRequest("POST", "/mto-service-items", nil) reason := "lorem ipsum" @@ -447,8 +447,8 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { LinkOnly: true, }, }, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) subtestData.req = httptest.NewRequest("POST", "/mto-service-items", nil) subtestData.mtoServiceItem = models.MTOServiceItem{ @@ -610,7 +610,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -810,7 +810,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITNoA LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -897,7 +897,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITWit LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Date(2024, time.February, 28, 0, 0, 0, 0, time.UTC) sitDepartureDate := time.Date(2024, time.February, 27, 0, 0, 0, 0, time.UTC) sitPostalCode := "00000" @@ -1084,7 +1084,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { LinkOnly: true, }, }, nil) - factory.BuildDDFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) req := httptest.NewRequest("POST", "/mto-service-items", nil) subtestData.mtoServiceItem = models.MTOServiceItem{ diff --git a/pkg/handlers/primeapi/payment_request_test.go b/pkg/handlers/primeapi/payment_request_test.go index 92c37e38301..fd4e8dd14da 100644 --- a/pkg/handlers/primeapi/payment_request_test.go +++ b/pkg/handlers/primeapi/payment_request_test.go @@ -669,7 +669,7 @@ func (suite *HandlerSuite) setupDomesticLinehaulData() (models.Move, models.MTOS }, }) - csService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeCS) + csService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeCS) csTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: csService.ID, @@ -677,7 +677,7 @@ func (suite *HandlerSuite) setupDomesticLinehaulData() (models.Move, models.MTOS } suite.MustSave(&csTaskOrderFee) - msService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeMS) + msService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeMS) msTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: msService.ID, diff --git a/pkg/handlers/primeapiv2/mto_service_item_test.go b/pkg/handlers/primeapiv2/mto_service_item_test.go index ff8fee929c9..ffe960ba4f4 100644 --- a/pkg/handlers/primeapiv2/mto_service_item_test.go +++ b/pkg/handlers/primeapiv2/mto_service_item_test.go @@ -47,7 +47,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) req := httptest.NewRequest("POST", "/mto-service-items", nil) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -124,7 +124,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { }, }, nil) mtoShipment.PrimeEstimatedWeight = nil - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) req := httptest.NewRequest("POST", "/mto-service-items", nil) reason := "lorem ipsum" @@ -442,8 +442,8 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { LinkOnly: true, }, }, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) subtestData.req = httptest.NewRequest("POST", "/mto-service-items", nil) subtestData.mtoServiceItem = models.MTOServiceItem{ @@ -605,7 +605,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -805,7 +805,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITNoA LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -892,7 +892,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITWit LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -1071,7 +1071,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { LinkOnly: true, }, }, nil) - factory.BuildDDFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) req := httptest.NewRequest("POST", "/mto-service-items", nil) subtestData.mtoServiceItem = models.MTOServiceItem{ diff --git a/pkg/handlers/primeapiv3/mto_service_item_test.go b/pkg/handlers/primeapiv3/mto_service_item_test.go index b3865fc27b7..1bc9362127c 100644 --- a/pkg/handlers/primeapiv3/mto_service_item_test.go +++ b/pkg/handlers/primeapiv3/mto_service_item_test.go @@ -47,7 +47,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) req := httptest.NewRequest("POST", "/mto-service-items", nil) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -125,7 +125,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { }, }, nil) mtoShipment.PrimeEstimatedWeight = nil - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) req := httptest.NewRequest("POST", "/mto-service-items", nil) reason := "lorem ipsum" @@ -443,8 +443,8 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { LinkOnly: true, }, }, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) subtestData.req = httptest.NewRequest("POST", "/mto-service-items", nil) subtestData.mtoServiceItem = models.MTOServiceItem{ @@ -606,7 +606,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -806,7 +806,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITNoA LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -893,7 +893,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITWit LinkOnly: true, }, }, nil) - factory.BuildDOFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) sitEntryDate := time.Now() sitPostalCode := "00000" @@ -1072,7 +1072,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { LinkOnly: true, }, }, nil) - factory.BuildDDFSITReService(suite.DB()) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) req := httptest.NewRequest("POST", "/mto-service-items", nil) subtestData.mtoServiceItem = models.MTOServiceItem{ diff --git a/pkg/handlers/supportapi/mto_shipment_test.go b/pkg/handlers/supportapi/mto_shipment_test.go index f42dd8954a1..c1a9bb7018b 100644 --- a/pkg/handlers/supportapi/mto_shipment_test.go +++ b/pkg/handlers/supportapi/mto_shipment_test.go @@ -67,7 +67,7 @@ func (suite *HandlerSuite) TestUpdateMTOShipmentStatusHandler() { models.ReServiceCodeDUPK, } for _, serviceCode := range reServiceCodes { - factory.FetchOrBuildReServiceByCode(suite.DB(), serviceCode) + factory.FetchReServiceByCode(suite.DB(), serviceCode) } return mtoShipment diff --git a/pkg/models/mto_service_items.go b/pkg/models/mto_service_items.go index 5f748d1db37..862a25fce32 100644 --- a/pkg/models/mto_service_items.go +++ b/pkg/models/mto_service_items.go @@ -67,6 +67,7 @@ type MTOServiceItem struct { PricingEstimate *unit.Cents `db:"pricing_estimate"` StandaloneCrate *bool `db:"standalone_crate"` LockedPriceCents *unit.Cents `db:"locked_price_cents"` + ServiceLocation *ServiceLocationType `db:"service_location"` } // MTOServiceItemSingle is an object representing a single column in the service items table diff --git a/pkg/models/re_service.go b/pkg/models/re_service.go index b2eedebd7a2..0226311ccc9 100644 --- a/pkg/models/re_service.go +++ b/pkg/models/re_service.go @@ -121,16 +121,36 @@ const ( ReServiceCodeNSTH ReServiceCode = "NSTH" // ReServiceCodeNSTUB Nonstandard UB ReServiceCodeNSTUB ReServiceCode = "NSTUB" + // ReServiceCodeUBP International UB + ReServiceCodeUBP ReServiceCode = "UBP" + // ReServiceCodeISLH Shipping & Linehaul + ReServiceCodeISLH ReServiceCode = "ISLH" + // ReServiceCodePOEFSC International POE Fuel Surcharge + ReServiceCodePOEFSC ReServiceCode = "POEFSC" + // ReServiceCodePODFSC International POD Fuel Surcharge + ReServiceCodePODFSC ReServiceCode = "PODFSC" +) + +type ServiceLocationType string + +const ( + // ServiceLocationO Origin + ServiceLocationO ServiceLocationType = "O" + // ServiceLocationD Destination + ServiceLocationD ServiceLocationType = "D" + // ServiceLocationB Both + ServiceLocationB ServiceLocationType = "B" ) // ReService model struct type ReService struct { - ID uuid.UUID `json:"id" db:"id"` - Code ReServiceCode `json:"code" db:"code"` - Priority int `db:"priority"` - Name string `json:"name" db:"name"` - CreatedAt time.Time `json:"created_at" db:"created_at"` - UpdatedAt time.Time `json:"updated_at" db:"updated_at"` + ID uuid.UUID `json:"id" db:"id" rw:"r"` + Code ReServiceCode `json:"code" db:"code" rw:"r"` + Priority int `db:"priority" rw:"r"` + Name string `json:"name" db:"name" rw:"r"` + ServiceLocation *ServiceLocationType `db:"service_location" rw:"r"` + CreatedAt time.Time `json:"created_at" db:"created_at" rw:"r"` + UpdatedAt time.Time `json:"updated_at" db:"updated_at" rw:"r"` } // Hold groupings of SIT for the shipment diff --git a/pkg/models/re_service_item.go b/pkg/models/re_service_item.go new file mode 100644 index 00000000000..91dcd826485 --- /dev/null +++ b/pkg/models/re_service_item.go @@ -0,0 +1,22 @@ +package models + +import ( + "time" + + "github.com/gofrs/uuid" +) + +type ReServiceItem struct { + ID uuid.UUID `db:"id" rw:"r"` + ServiceId uuid.UUID `db:"service_id" rw:"r"` + ReService ReService `belongs_to:"re_services" fk_id:"service_id" rw:"r"` + ShipmentType MTOShipmentType `db:"shipment_type" rw:"r"` + MarketCode MarketCode `db:"market_code" rw:"r"` + IsAutoApproved bool `db:"is_auto_approved" rw:"r"` + CreatedAt time.Time `db:"created_at" rw:"r"` + UpdatedAt time.Time `db:"updated_at" rw:"r"` +} + +func (r ReServiceItem) TableName() string { + return "re_service_items" +} diff --git a/pkg/payment_request/service_param_list_fetcher_test.go b/pkg/payment_request/service_param_list_fetcher_test.go index e7b22122de0..4de6653750e 100644 --- a/pkg/payment_request/service_param_list_fetcher_test.go +++ b/pkg/payment_request/service_param_list_fetcher_test.go @@ -7,8 +7,8 @@ import ( func (suite *PaymentRequestHelperSuite) TestFetchServiceParamList() { // Make a couple of services - dlhService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDLH) - dopService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOP) + dlhService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDLH) + dopService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOP) // Make a few keys contractCodeKey := factory.BuildServiceItemParamKey(suite.DB(), []factory.Customization{ diff --git a/pkg/payment_request/service_param_value_lookups/distance_zip_lookup_test.go b/pkg/payment_request/service_param_value_lookups/distance_zip_lookup_test.go index bd79d1f8560..4f826c52009 100644 --- a/pkg/payment_request/service_param_value_lookups/distance_zip_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/distance_zip_lookup_test.go @@ -230,7 +230,7 @@ func (suite *ServiceParamValueLookupsSuite) TestDistanceLookup() { }, nil) // DLH - reServiceDLH := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDLH) + reServiceDLH := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDLH) estimatedWeight := unit.Pound(2048) diff --git a/pkg/payment_request/service_param_value_lookups/distance_zip_sit_dest_lookup_test.go b/pkg/payment_request/service_param_value_lookups/distance_zip_sit_dest_lookup_test.go index dc27f39aea9..8231238b831 100644 --- a/pkg/payment_request/service_param_value_lookups/distance_zip_sit_dest_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/distance_zip_sit_dest_lookup_test.go @@ -34,7 +34,7 @@ func (suite *ServiceParamValueLookupsSuite) TestDistanceZipSITDestLookup() { }, }) - reService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDDSIT) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDDSIT) destAddress = factory.BuildAddress(suite.DB(), []factory.Customization{ diff --git a/pkg/payment_request/service_param_value_lookups/distance_zip_sit_origin_lookup_test.go b/pkg/payment_request/service_param_value_lookups/distance_zip_sit_origin_lookup_test.go index ab13969f4df..31d766db385 100644 --- a/pkg/payment_request/service_param_value_lookups/distance_zip_sit_origin_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/distance_zip_sit_origin_lookup_test.go @@ -35,7 +35,7 @@ func (suite *ServiceParamValueLookupsSuite) TestDistanceZipSITOriginLookup() { EndDate: time.Now().Add(24 * time.Hour), }, }) - reService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) originAddress = factory.BuildAddress(suite.DB(), []factory.Customization{ diff --git a/pkg/payment_request/service_param_value_lookups/eia_fuel_price_lookup_test.go b/pkg/payment_request/service_param_value_lookups/eia_fuel_price_lookup_test.go index d16a4fcb22e..ded105300ab 100644 --- a/pkg/payment_request/service_param_value_lookups/eia_fuel_price_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/eia_fuel_price_lookup_test.go @@ -99,7 +99,7 @@ func (suite *ServiceParamValueLookupsSuite) TestEIAFuelPriceLookup() { // ServiceItemParamNameEIAFuelPrice // FSC - reService1 := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeFSC) + reService1 := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeFSC) // FSC mtoServiceItemFSC := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{ diff --git a/pkg/payment_request/service_param_value_lookups/number_days_sit_lookup_test.go b/pkg/payment_request/service_param_value_lookups/number_days_sit_lookup_test.go index 925306d90df..4ad2ce7dbda 100644 --- a/pkg/payment_request/service_param_value_lookups/number_days_sit_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/number_days_sit_lookup_test.go @@ -69,7 +69,7 @@ func (suite *ServiceParamValueLookupsSuite) TestNumberDaysSITLookup() { EndDate: time.Now().Add(24 * time.Hour), }, }) - reServiceDOFSIT = factory.BuildReService(suite.DB(), []factory.Customization{ + reServiceDOFSIT = factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDOFSIT, @@ -78,7 +78,7 @@ func (suite *ServiceParamValueLookupsSuite) TestNumberDaysSITLookup() { }, }, nil) - reServiceDOASIT = factory.BuildReService(suite.DB(), []factory.Customization{ + reServiceDOASIT = factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDOASIT, @@ -87,7 +87,7 @@ func (suite *ServiceParamValueLookupsSuite) TestNumberDaysSITLookup() { }, }, nil) - reServiceDDFSIT := factory.BuildReService(suite.DB(), []factory.Customization{ + reServiceDDFSIT := factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDDFSIT, @@ -96,7 +96,7 @@ func (suite *ServiceParamValueLookupsSuite) TestNumberDaysSITLookup() { }, }, nil) - reServiceDDASIT = factory.BuildReService(suite.DB(), []factory.Customization{ + reServiceDDASIT = factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDDASIT, diff --git a/pkg/payment_request/service_param_value_lookups/service_param_value_lookups_test.go b/pkg/payment_request/service_param_value_lookups/service_param_value_lookups_test.go index 9ae27318968..bc5587b7941 100644 --- a/pkg/payment_request/service_param_value_lookups/service_param_value_lookups_test.go +++ b/pkg/payment_request/service_param_value_lookups/service_param_value_lookups_test.go @@ -727,7 +727,7 @@ func (suite *ServiceParamValueLookupsSuite) TestServiceParamValueLookup() { }) // Make a move and service for reuse. move := factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil) - reService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDLH) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDLH) // NTS should have a pickup address and storage facility address. pickupPostalCode := "29212" diff --git a/pkg/payment_request/service_param_value_lookups/service_params_cache_test.go b/pkg/payment_request/service_param_value_lookups/service_params_cache_test.go index 7701a0a2d0d..f55832cc189 100644 --- a/pkg/payment_request/service_param_value_lookups/service_params_cache_test.go +++ b/pkg/payment_request/service_param_value_lookups/service_params_cache_test.go @@ -58,11 +58,11 @@ func (suite *ServiceParamValueLookupsSuite) makeSubtestData() (subtestData *para subtestData.mtoShipment1.PrimeEstimatedWeight = &subtestData.estimatedWeight suite.MustSave(&subtestData.mtoShipment1) - reServiceDLH := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDLH) - reServiceDOP := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOP) - reServiceMS := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeMS) - reServiceDCRT := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) - reServiceDOSHUT := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) + reServiceDLH := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDLH) + reServiceDOP := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOP) + reServiceMS := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeMS) + reServiceDCRT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDCRT) + reServiceDOSHUT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) // DLH subtestData.mtoServiceItemShip1DLH = factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{ diff --git a/pkg/payment_request/service_param_value_lookups/weight_billed_lookup.go b/pkg/payment_request/service_param_value_lookups/weight_billed_lookup.go index c36cb48fc52..bca7555ea28 100644 --- a/pkg/payment_request/service_param_value_lookups/weight_billed_lookup.go +++ b/pkg/payment_request/service_param_value_lookups/weight_billed_lookup.go @@ -227,9 +227,7 @@ func applyMinimum(code models.ReServiceCode, shipmentType models.MTOShipmentType models.ReServiceCodeDUPK, models.ReServiceCodeDOSHUT, models.ReServiceCodeDDSHUT, - models.ReServiceCodeIOOLH, - models.ReServiceCodeICOLH, - models.ReServiceCodeIOCLH, + models.ReServiceCodeISLH, models.ReServiceCodeIHPK, models.ReServiceCodeIHUPK, models.ReServiceCodeIOFSIT, @@ -244,9 +242,7 @@ func applyMinimum(code models.ReServiceCode, shipmentType models.MTOShipmentType if weight < 500 { result = 500 } - case models.ReServiceCodeIOOUB, - models.ReServiceCodeICOUB, - models.ReServiceCodeIOCUB, + case models.ReServiceCodeUBP, models.ReServiceCodeIUBPK, models.ReServiceCodeIUBUPK: if weight < 300 { diff --git a/pkg/payment_request/service_param_value_lookups/weight_billed_lookup_test.go b/pkg/payment_request/service_param_value_lookups/weight_billed_lookup_test.go index d0142829a77..dbf0030ccb6 100644 --- a/pkg/payment_request/service_param_value_lookups/weight_billed_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/weight_billed_lookup_test.go @@ -25,13 +25,13 @@ func (suite *ServiceParamValueLookupsSuite) TestWeightBilledLookup() { suite.Equal("1024", valueStr) }) - suite.Run("original is exactly 110% of estimated weight", func() { + suite.Run("ISLH is minimum of 500", func() { // Set the original weight to exactly 110% of estimated weight - _, _, paramLookup := suite.setupTestMTOServiceItemWithWeight(unit.Pound(100), unit.Pound(110), models.ReServiceCodeNSTH, models.MTOShipmentTypeHHG) + _, _, paramLookup := suite.setupTestMTOServiceItemWithWeight(unit.Pound(100), unit.Pound(110), models.ReServiceCodeISLH, models.MTOShipmentTypeHHG) valueStr, err := paramLookup.ServiceParamValue(suite.AppContextForTest(), key) suite.FatalNoError(err) - suite.Equal("110", valueStr) + suite.Equal("500", valueStr) }) suite.Run("original is 120% of estimated weight but there is no adjusted weight", func() { @@ -94,12 +94,12 @@ func (suite *ServiceParamValueLookupsSuite) TestWeightBilledLookup() { {models.ReServiceCodeDOPSIT, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, {models.ReServiceCodeDDDSIT, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, // International - {models.ReServiceCodeIOOLH, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, - {models.ReServiceCodeIOOUB, unit.Pound(250), "300", models.MTOShipmentTypeHHG}, - {models.ReServiceCodeICOLH, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, - {models.ReServiceCodeICOUB, unit.Pound(250), "300", models.MTOShipmentTypeHHG}, - {models.ReServiceCodeIOCLH, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, - {models.ReServiceCodeIOCUB, unit.Pound(250), "300", models.MTOShipmentTypeHHG}, + {models.ReServiceCodeISLH, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, + {models.ReServiceCodeUBP, unit.Pound(250), "300", models.MTOShipmentTypeHHG}, + {models.ReServiceCodeISLH, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, + {models.ReServiceCodeUBP, unit.Pound(250), "300", models.MTOShipmentTypeHHG}, + {models.ReServiceCodeISLH, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, + {models.ReServiceCodeUBP, unit.Pound(250), "300", models.MTOShipmentTypeHHG}, {models.ReServiceCodeIHPK, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, {models.ReServiceCodeIHUPK, unit.Pound(450), "500", models.MTOShipmentTypeHHG}, {models.ReServiceCodeIUBPK, unit.Pound(250), "300", models.MTOShipmentTypeHHG}, diff --git a/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_actual_address_lookup_test.go b/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_actual_address_lookup_test.go index 852361e86de..1a50727ceb5 100644 --- a/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_actual_address_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_actual_address_lookup_test.go @@ -26,7 +26,7 @@ func (suite *ServiceParamValueLookupsSuite) TestZipSITOriginHHGActualAddressLook }, }) - reService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) originAddress := factory.BuildAddress(suite.DB(), []factory.Customization{ diff --git a/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_original_address_lookup_test.go b/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_original_address_lookup_test.go index a62df8f4e77..7d496a34063 100644 --- a/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_original_address_lookup_test.go +++ b/pkg/payment_request/service_param_value_lookups/zip_sit_origin_hhg_original_address_lookup_test.go @@ -25,7 +25,7 @@ func (suite *ServiceParamValueLookupsSuite) TestZipSITOriginHHGOriginalAddressLo EndDate: time.Now().Add(24 * time.Hour), }, }) - reService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) originAddress := factory.BuildAddress(suite.DB(), []factory.Customization{ diff --git a/pkg/services/ghcimport/ghc_rateengine_importer_test.go b/pkg/services/ghcimport/ghc_rateengine_importer_test.go index 9784c7ae834..74aa80f9b59 100644 --- a/pkg/services/ghcimport/ghc_rateengine_importer_test.go +++ b/pkg/services/ghcimport/ghc_rateengine_importer_test.go @@ -24,7 +24,6 @@ type GHCRateEngineImportSuite struct { func (suite *GHCRateEngineImportSuite) SetupSuite() { suite.PreloadData(func() { suite.helperSetupStagingTables() - suite.helperSetupReServicesTable() }) } @@ -49,10 +48,6 @@ func (suite *GHCRateEngineImportSuite) helperSetupStagingTables() { suite.helperLoadSQLFixture("stage_ghc_pricing.sql") } -func (suite *GHCRateEngineImportSuite) helperSetupReServicesTable() { - suite.helperLoadSQLFixture("re_services_data.sql") -} - func TestGHCRateEngineImportSuite(t *testing.T) { hs := &GHCRateEngineImportSuite{ PopTestSuite: testingsuite.NewPopTestSuite(testingsuite.CurrentPackage(), testingsuite.WithPerTestTransaction()), diff --git a/pkg/services/ghcimport/import_re_intl_prices.go b/pkg/services/ghcimport/import_re_intl_prices.go index 32855d876cf..0baff7602ca 100644 --- a/pkg/services/ghcimport/import_re_intl_prices.go +++ b/pkg/services/ghcimport/import_re_intl_prices.go @@ -27,7 +27,6 @@ func (gre *GHCRateEngineImporter) importREInternationalPrices(appCtx appcontext. if err := gre.importNonStandardLocationPrices(appCtx); err != nil { return fmt.Errorf("could not import non-standard location prices: %w", err) } - return nil } @@ -40,15 +39,15 @@ func (gre *GHCRateEngineImporter) importOconusToOconusPrices(appCtx appcontext.A } // Int'l O->O Shipping & LH - serviceIOOLH, foundService := gre.serviceToIDMap[models.ReServiceCodeIOOLH] + serviceISLH, foundService := gre.serviceToIDMap[models.ReServiceCodeISLH] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeIOOLH) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeISLH) } // Int'l O->O UB - serviceIOOUB, foundService := gre.serviceToIDMap[models.ReServiceCodeIOOUB] + serviceUBP, foundService := gre.serviceToIDMap[models.ReServiceCodeUBP] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeIOOUB) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeUBP) } // loop through the OCONUS to OCONUS data and store in db @@ -79,25 +78,25 @@ func (gre *GHCRateEngineImporter) importOconusToOconusPrices(appCtx appcontext.A return fmt.Errorf("could not process UB price [%s]: %w", stageOconusToOconusPrice.UBPrice, err) } - intlPricingModelIOOLH := models.ReIntlPrice{ + intlPricingModelISLH := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceIOOLH, + ServiceID: serviceISLH, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: peakPeriod, PerUnitCents: unit.Cents(perUnitCentsHHG), } - intlPricingModels = append(intlPricingModels, intlPricingModelIOOLH) + intlPricingModels = append(intlPricingModels, intlPricingModelISLH) - intlPricingModelIOOUB := models.ReIntlPrice{ + intlPricingModelUBP := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceIOOUB, + ServiceID: serviceUBP, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: peakPeriod, PerUnitCents: unit.Cents(perUnitCentsUB), } - intlPricingModels = append(intlPricingModels, intlPricingModelIOOUB) + intlPricingModels = append(intlPricingModels, intlPricingModelUBP) for _, model := range intlPricingModels { copyOfModel := model // Make copy to avoid implicit memory aliasing of items from a range statement. @@ -123,15 +122,15 @@ func (gre *GHCRateEngineImporter) importConusToOconusPrices(appCtx appcontext.Ap } // Int'l C->O Shipping & LH - serviceICOLH, foundService := gre.serviceToIDMap[models.ReServiceCodeICOLH] + serviceISLH, foundService := gre.serviceToIDMap[models.ReServiceCodeISLH] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeICOLH) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeISLH) } // Int'l C->O UB - serviceICOUB, foundService := gre.serviceToIDMap[models.ReServiceCodeICOUB] + serviceUBP, foundService := gre.serviceToIDMap[models.ReServiceCodeUBP] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeICOUB) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeUBP) } // loop through the CONUS to OCONUS data and store in db @@ -163,25 +162,25 @@ func (gre *GHCRateEngineImporter) importConusToOconusPrices(appCtx appcontext.Ap return fmt.Errorf("could not process UB price [%s]: %w", stageConusToOconusPrice.UBPrice, err) } - intlPricingModelICOLH := models.ReIntlPrice{ + intlPricingModelISLH := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceICOLH, + ServiceID: serviceISLH, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: peakPeriod, PerUnitCents: unit.Cents(perUnitCentsHHG), } - intlPricingModels = append(intlPricingModels, intlPricingModelICOLH) + intlPricingModels = append(intlPricingModels, intlPricingModelISLH) - intlPricingModelICOUB := models.ReIntlPrice{ + intlPricingModelUBP := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceICOUB, + ServiceID: serviceUBP, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: peakPeriod, PerUnitCents: unit.Cents(perUnitCentsUB), } - intlPricingModels = append(intlPricingModels, intlPricingModelICOUB) + intlPricingModels = append(intlPricingModels, intlPricingModelUBP) for _, model := range intlPricingModels { copyOfModel := model // Make copy to avoid implicit memory aliasing of items from a range statement. @@ -207,15 +206,15 @@ func (gre *GHCRateEngineImporter) importOconusToConusPrices(appCtx appcontext.Ap } // Int'l O->C Shipping & LH - serviceIOCLH, foundService := gre.serviceToIDMap[models.ReServiceCodeIOCLH] + serviceISLH, foundService := gre.serviceToIDMap[models.ReServiceCodeISLH] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeIOCLH) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeISLH) } // Int'l O->C UB - serviceIOCUB, foundService := gre.serviceToIDMap[models.ReServiceCodeIOCUB] + serviceUBP, foundService := gre.serviceToIDMap[models.ReServiceCodeUBP] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeIOCUB) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeUBP) } // loop through the OCONUS to CONUS data and store in db @@ -247,25 +246,25 @@ func (gre *GHCRateEngineImporter) importOconusToConusPrices(appCtx appcontext.Ap return fmt.Errorf("could not process UB price [%s]: %w", stageOconusToConusPrice.UBPrice, err) } - intlPricingModelIOCLH := models.ReIntlPrice{ + intlPricingModelISLH := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceIOCLH, + ServiceID: serviceISLH, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: isPeakPeriod, PerUnitCents: unit.Cents(perUnitCentsHHG), } - intlPricingModels = append(intlPricingModels, intlPricingModelIOCLH) + intlPricingModels = append(intlPricingModels, intlPricingModelISLH) - intlPricingModelIOCUB := models.ReIntlPrice{ + intlPricingModelUBP := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceIOCUB, + ServiceID: serviceUBP, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: isPeakPeriod, PerUnitCents: unit.Cents(perUnitCentsUB), } - intlPricingModels = append(intlPricingModels, intlPricingModelIOCUB) + intlPricingModels = append(intlPricingModels, intlPricingModelUBP) for _, model := range intlPricingModels { copyOfModel := model // Make copy to avoid implicit memory aliasing of items from a range statement. @@ -291,15 +290,15 @@ func (gre *GHCRateEngineImporter) importNonStandardLocationPrices(appCtx appcont } // Int'l non-standard HHG - serviceNSTH, foundService := gre.serviceToIDMap[models.ReServiceCodeNSTH] + serviceISLH, foundService := gre.serviceToIDMap[models.ReServiceCodeISLH] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeNSTH) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeISLH) } // Int'l non-standard UB - serviceNSTUB, foundService := gre.serviceToIDMap[models.ReServiceCodeNSTUB] + serviceUBP, foundService := gre.serviceToIDMap[models.ReServiceCodeUBP] if !foundService { - return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeNSTUB) + return fmt.Errorf("missing service %s in map of services", models.ReServiceCodeUBP) } // loop through the non-standard location data and store in db @@ -336,25 +335,25 @@ func (gre *GHCRateEngineImporter) importNonStandardLocationPrices(appCtx appcont return fmt.Errorf("could not process UB price [%s]: %w", stageNonStandardLocnPrice.UBPrice, err) } - intlPricingModelNSTH := models.ReIntlPrice{ + intlPricingModelISLH := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceNSTH, + ServiceID: serviceISLH, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: peakPeriod, PerUnitCents: unit.Cents(perUnitCentsHHG), } - intlPricingModels = append(intlPricingModels, intlPricingModelNSTH) + intlPricingModels = append(intlPricingModels, intlPricingModelISLH) - intlPricingModelNSTUB := models.ReIntlPrice{ + intlPricingModelUBP := models.ReIntlPrice{ ContractID: gre.ContractID, - ServiceID: serviceNSTUB, + ServiceID: serviceUBP, OriginRateAreaID: originRateAreaID, DestinationRateAreaID: destinationRateAreaID, IsPeakPeriod: peakPeriod, PerUnitCents: unit.Cents(perUnitCentsUB), } - intlPricingModels = append(intlPricingModels, intlPricingModelNSTUB) + intlPricingModels = append(intlPricingModels, intlPricingModelUBP) for _, model := range intlPricingModels { copyOfModel := model // Make copy to avoid implicit memory aliasing of items from a range statement. @@ -367,10 +366,8 @@ func (gre *GHCRateEngineImporter) importNonStandardLocationPrices(appCtx appcont } } } - return nil } - func (gre *GHCRateEngineImporter) getRateAreaIDForKind(rateArea string, kind string) (uuid.UUID, error) { switch kind { case "NSRA", "OCONUS": diff --git a/pkg/services/ghcimport/import_re_intl_prices_test.go b/pkg/services/ghcimport/import_re_intl_prices_test.go index b583dbfd254..13d9f74ffd8 100644 --- a/pkg/services/ghcimport/import_re_intl_prices_test.go +++ b/pkg/services/ghcimport/import_re_intl_prices_test.go @@ -120,45 +120,45 @@ func (suite *GHCRateEngineImportSuite) helperCheckInternationalPriceValues() { expectedPrice int }{ // 3a: OCONUS to OCONUS - {models.ReServiceCodeIOOLH, "GE", "US8101000", false, 1021}, - {models.ReServiceCodeIOOUB, "GE", "US8101000", false, 1717}, - {models.ReServiceCodeIOOLH, "GE", "US8101000", true, 1205}, - {models.ReServiceCodeIOOUB, "GE", "US8101000", true, 2026}, + {models.ReServiceCodeISLH, "GE", "US8101000", false, 1021}, + {models.ReServiceCodeUBP, "GE", "US8101000", false, 1717}, + {models.ReServiceCodeISLH, "GE", "US8101000", true, 1205}, + {models.ReServiceCodeUBP, "GE", "US8101000", true, 2026}, // 3b: CONUS to OCONUS - {models.ReServiceCodeICOLH, "US47", "AS11", false, 3090}, - {models.ReServiceCodeICOUB, "US47", "AS11", false, 3398}, - {models.ReServiceCodeICOLH, "US47", "AS11", true, 3646}, - {models.ReServiceCodeICOUB, "US47", "AS11", true, 4010}, + {models.ReServiceCodeISLH, "US47", "AS11", false, 3090}, + {models.ReServiceCodeUBP, "US47", "AS11", false, 3398}, + {models.ReServiceCodeISLH, "US47", "AS11", true, 3646}, + {models.ReServiceCodeUBP, "US47", "AS11", true, 4010}, // 3c: OCONUS to CONUS - {models.ReServiceCodeIOCLH, "US8101000", "US68", false, 1757}, - {models.ReServiceCodeIOCUB, "US8101000", "US68", false, 3445}, - {models.ReServiceCodeIOCLH, "US8101000", "US68", true, 2073}, - {models.ReServiceCodeIOCUB, "US8101000", "US68", true, 4065}, + {models.ReServiceCodeISLH, "US8101000", "US68", false, 1757}, + {models.ReServiceCodeUBP, "US8101000", "US68", false, 3445}, + {models.ReServiceCodeISLH, "US8101000", "US68", true, 2073}, + {models.ReServiceCodeUBP, "US8101000", "US68", true, 4065}, // 3e: NSRA to NSRA - {models.ReServiceCodeNSTH, "NSRA2", "NSRA13", false, 4849}, - {models.ReServiceCodeNSTUB, "NSRA2", "NSRA13", false, 4793}, - {models.ReServiceCodeNSTH, "NSRA2", "NSRA13", true, 5722}, - {models.ReServiceCodeNSTUB, "NSRA2", "NSRA13", true, 5656}, + {models.ReServiceCodeISLH, "NSRA2", "NSRA13", false, 4849}, + {models.ReServiceCodeUBP, "NSRA2", "NSRA13", false, 4793}, + {models.ReServiceCodeISLH, "NSRA2", "NSRA13", true, 5722}, + {models.ReServiceCodeUBP, "NSRA2", "NSRA13", true, 5656}, // 3e: NSRA to OCONUS - {models.ReServiceCodeNSTH, "NSRA13", "AS11", false, 5172}, - {models.ReServiceCodeNSTUB, "NSRA13", "AS11", false, 1175}, - {models.ReServiceCodeNSTH, "NSRA13", "AS11", true, 6103}, - {models.ReServiceCodeNSTUB, "NSRA13", "AS11", true, 1386}, + {models.ReServiceCodeISLH, "NSRA13", "AS11", false, 5172}, + {models.ReServiceCodeUBP, "NSRA13", "AS11", false, 1175}, + {models.ReServiceCodeISLH, "NSRA13", "AS11", true, 6103}, + {models.ReServiceCodeUBP, "NSRA13", "AS11", true, 1386}, // 3e: OCONUS to NSRA - {models.ReServiceCodeNSTH, "GE", "NSRA2", false, 4872}, - {models.ReServiceCodeNSTUB, "GE", "NSRA2", false, 1050}, - {models.ReServiceCodeNSTH, "GE", "NSRA2", true, 5749}, - {models.ReServiceCodeNSTUB, "GE", "NSRA2", true, 1239}, + {models.ReServiceCodeISLH, "GE", "NSRA2", false, 4872}, + {models.ReServiceCodeUBP, "GE", "NSRA2", false, 1050}, + {models.ReServiceCodeISLH, "GE", "NSRA2", true, 5749}, + {models.ReServiceCodeUBP, "GE", "NSRA2", true, 1239}, // 3e: NSRA to CONUS - {models.ReServiceCodeNSTH, "NSRA2", "US4965500", false, 931}, - {models.ReServiceCodeNSTUB, "NSRA2", "US4965500", false, 1717}, - {models.ReServiceCodeNSTH, "NSRA2", "US4965500", true, 1099}, - {models.ReServiceCodeNSTUB, "NSRA2", "US4965500", true, 2026}, + {models.ReServiceCodeISLH, "NSRA2", "US4965500", false, 931}, + {models.ReServiceCodeUBP, "NSRA2", "US4965500", false, 1717}, + {models.ReServiceCodeISLH, "NSRA2", "US4965500", true, 1099}, + {models.ReServiceCodeUBP, "NSRA2", "US4965500", true, 2026}, // 3e: CONUS to NSRA - {models.ReServiceCodeNSTH, "US68", "NSRA13", false, 1065}, - {models.ReServiceCodeNSTUB, "US68", "NSRA13", false, 1689}, - {models.ReServiceCodeNSTH, "US68", "NSRA13", true, 1257}, - {models.ReServiceCodeNSTUB, "US68", "NSRA13", true, 1993}, + {models.ReServiceCodeISLH, "US68", "NSRA13", false, 1065}, + {models.ReServiceCodeUBP, "US68", "NSRA13", false, 1689}, + {models.ReServiceCodeISLH, "US68", "NSRA13", true, 1257}, + {models.ReServiceCodeUBP, "US68", "NSRA13", true, 1993}, } for _, testCase := range testCases { diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go index d53fe711bfb..ff001839d2d 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go @@ -320,7 +320,7 @@ func (suite *GHCRateEngineServiceSuite) setUpDomesticDestinationData() { }, }) - domesticDestinationService := factory.BuildReService(suite.DB(), []factory.Customization{ + domesticDestinationService := factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDDP, diff --git a/pkg/services/ghcrateengine/domestic_nts_pack_pricer_test.go b/pkg/services/ghcrateengine/domestic_nts_pack_pricer_test.go index caebeecc030..ce75ab4599c 100644 --- a/pkg/services/ghcrateengine/domestic_nts_pack_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_nts_pack_pricer_test.go @@ -115,7 +115,7 @@ func (suite *GHCRateEngineServiceSuite) setupDomesticNTSPackPrices(schedule int, }, }) - packService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDPK) + packService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDPK) otherPrice := models.ReDomesticOtherPrice{ ContractID: contractYear.Contract.ID, ServiceID: packService.ID, @@ -126,7 +126,7 @@ func (suite *GHCRateEngineServiceSuite) setupDomesticNTSPackPrices(schedule int, suite.MustSave(&otherPrice) - ntsPackService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDNPK) + ntsPackService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDNPK) shipmentTypePrice := models.ReShipmentTypePrice{ ContractID: contractYear.Contract.ID, ServiceID: ntsPackService.ID, diff --git a/pkg/services/ghcrateengine/domestic_origin_pricer_test.go b/pkg/services/ghcrateengine/domestic_origin_pricer_test.go index 4ffeaae60e8..8e43cdaf246 100644 --- a/pkg/services/ghcrateengine/domestic_origin_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_origin_pricer_test.go @@ -341,7 +341,7 @@ func (suite *GHCRateEngineServiceSuite) setUpDomesticOriginData() { }, }) - domesticOriginService := factory.BuildReService(suite.DB(), []factory.Customization{ + domesticOriginService := factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDOP, diff --git a/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go b/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go index 526ed6999de..7f43328515a 100644 --- a/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go @@ -318,7 +318,7 @@ func (suite *GHCRateEngineServiceSuite) setUpDomesticShorthaulData() { }, }) - domesticShorthaulService := factory.BuildReService(suite.DB(), []factory.Customization{ + domesticShorthaulService := factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDSH, diff --git a/pkg/services/ghcrateengine/ghc_rate_engine_service_test.go b/pkg/services/ghcrateengine/ghc_rate_engine_service_test.go index 0ce78ac804e..0ed120492f8 100644 --- a/pkg/services/ghcrateengine/ghc_rate_engine_service_test.go +++ b/pkg/services/ghcrateengine/ghc_rate_engine_service_test.go @@ -28,7 +28,7 @@ func TestGHCRateEngineServiceSuite(t *testing.T) { func (suite *GHCRateEngineServiceSuite) setupTaskOrderFeeData(code models.ReServiceCode, priceCents unit.Cents) { contractYear := testdatagen.MakeDefaultReContractYear(suite.DB()) - counselingService := factory.BuildReServiceByCode(suite.DB(), code) + counselingService := factory.FetchReServiceByCode(suite.DB(), code) taskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: counselingService.ID, @@ -46,7 +46,7 @@ func (suite *GHCRateEngineServiceSuite) setupDomesticOtherPrice(code models.ReSe }, }) - service := factory.BuildReServiceByCode(suite.DB(), code) + service := factory.FetchReServiceByCode(suite.DB(), code) otherPrice := models.ReDomesticOtherPrice{ ContractID: contractYear.Contract.ID, @@ -68,7 +68,7 @@ func (suite *GHCRateEngineServiceSuite) setupDomesticAccessorialPrice(code model }, }) - service := factory.BuildReServiceByCode(suite.DB(), code) + service := factory.FetchReServiceByCode(suite.DB(), code) accessorialPrice := models.ReDomesticAccessorialPrice{ ContractID: contractYear.Contract.ID, @@ -89,7 +89,7 @@ func (suite *GHCRateEngineServiceSuite) setupDomesticServiceAreaPrice(code model }, }) - service := factory.BuildReServiceByCode(suite.DB(), code) + service := factory.FetchReServiceByCode(suite.DB(), code) serviceArea := testdatagen.MakeReDomesticServiceArea(suite.DB(), testdatagen.Assertions{ @@ -150,7 +150,7 @@ func (suite *GHCRateEngineServiceSuite) setupShipmentTypePrice(code models.ReSer }, }) - service := factory.BuildReServiceByCode(suite.DB(), code) + service := factory.FetchReServiceByCode(suite.DB(), code) shipmentTypePrice := models.ReShipmentTypePrice{ ContractID: contractYear.Contract.ID, diff --git a/pkg/services/ghcrateengine/service_item_pricer_test.go b/pkg/services/ghcrateengine/service_item_pricer_test.go index 6ebfec34a29..86e5e858af1 100644 --- a/pkg/services/ghcrateengine/service_item_pricer_test.go +++ b/pkg/services/ghcrateengine/service_item_pricer_test.go @@ -89,7 +89,7 @@ func (suite *GHCRateEngineServiceSuite) TestGetPricer() { func (suite *GHCRateEngineServiceSuite) setupPriceServiceItemData() { contractYear := testdatagen.MakeDefaultReContractYear(suite.DB()) - counselingService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeMS) + counselingService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeMS) taskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, diff --git a/pkg/services/move_history/move_history_fetcher_test.go b/pkg/services/move_history/move_history_fetcher_test.go index 13b85471c12..f84af138e33 100644 --- a/pkg/services/move_history/move_history_fetcher_test.go +++ b/pkg/services/move_history/move_history_fetcher_test.go @@ -559,7 +559,7 @@ func (suite *MoveHistoryServiceSuite) TestMoveHistoryFetcherScenarios() { CreatedAt: time.Now(), UpdatedAt: time.Now(), } - reServiceDDFSIT := factory.BuildDDFSITReService(suite.DB()) + reServiceDDFSIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) serviceItem := models.MTOServiceItem{ MoveTaskOrderID: move.ID, @@ -624,7 +624,7 @@ func (suite *MoveHistoryServiceSuite) TestMoveHistoryFetcherScenarios() { ).Return(400, nil) creator := mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) - reService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeMS) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeMS) sitEntryDate := time.Now() attemptedContact := time.Now() diff --git a/pkg/services/move_task_order/move_task_order_creator_test.go b/pkg/services/move_task_order/move_task_order_creator_test.go index 9c68b51842a..44116f08cd7 100644 --- a/pkg/services/move_task_order/move_task_order_creator_test.go +++ b/pkg/services/move_task_order/move_task_order_creator_test.go @@ -8,8 +8,8 @@ import ( ) func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderCreatorIntegration() { - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeMS) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeCS) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeMS) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeCS) builder := query.NewQueryBuilder() mtoCreator := m.NewMoveTaskOrderCreator(builder) diff --git a/pkg/services/move_task_order/move_task_order_updater_test.go b/pkg/services/move_task_order/move_task_order_updater_test.go index f63cba60b1b..6f0fbaba6c5 100644 --- a/pkg/services/move_task_order/move_task_order_updater_test.go +++ b/pkg/services/move_task_order/move_task_order_updater_test.go @@ -644,7 +644,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo }, }) - service := factory.FetchOrBuildReServiceByCode(suite.DB(), "MS") + service := factory.FetchReServiceByCode(suite.DB(), "MS") msTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: service.ID, @@ -652,7 +652,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo } suite.MustSave(&msTaskOrderFee) - service = factory.FetchOrBuildReServiceByCode(suite.DB(), "CS") + service = factory.FetchReServiceByCode(suite.DB(), "CS") csTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: service.ID, diff --git a/pkg/services/mto_service_item/mto_service_item_creator_test.go b/pkg/services/mto_service_item/mto_service_item_creator_test.go index e6084a7f8d1..aa9c691fe76 100644 --- a/pkg/services/mto_service_item/mto_service_item_creator_test.go +++ b/pkg/services/mto_service_item/mto_service_item_creator_test.go @@ -59,7 +59,7 @@ func (suite *MTOServiceItemServiceSuite) buildValidServiceItemWithInvalidMove() // service items can only be created if a Move's status is Approved or // Approvals Requested move := factory.BuildMove(suite.DB(), nil, nil) - reServiceDDFSIT := factory.BuildDDFSITReService(suite.DB()) + reServiceDDFSIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) shipment := factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { Model: move, @@ -88,7 +88,7 @@ func (suite *MTOServiceItemServiceSuite) buildValidDDFSITServiceItemWithValidMov CreatedAt: time.Now(), UpdatedAt: time.Now(), } - reServiceDDFSIT := factory.BuildDDFSITReService(suite.DB()) + reServiceDDFSIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) shipment := factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { Model: move, @@ -114,7 +114,7 @@ func (suite *MTOServiceItemServiceSuite) buildValidDDFSITServiceItemWithValidMov func (suite *MTOServiceItemServiceSuite) buildValidDOSHUTServiceItemWithValidMove() models.MTOServiceItem { move := factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil) - reServiceDOSHUT := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) + reServiceDOSHUT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOSHUT) estimatedPrimeWeight := unit.Pound(6000) shipment := factory.BuildMTOShipment(suite.DB(), []factory.Customization{ @@ -156,7 +156,7 @@ func (suite *MTOServiceItemServiceSuite) buildValidServiceItemWithNoStatusAndVal CreatedAt: time.Now(), UpdatedAt: time.Now(), } - reService := factory.BuildReService(suite.DB(), nil, nil) + reService := factory.FetchReService(suite.DB(), nil, nil) shipment := factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { Model: move, @@ -439,7 +439,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { }, }) - reServiceCS := factory.FetchOrBuildReServiceByCode(suite.DB(), "CS") + reServiceCS := factory.FetchReServiceByCode(suite.DB(), "CS") csTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceCS.ID, @@ -473,7 +473,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { createdServiceItemCSList := *createdServiceItemsCS suite.Equal(createdServiceItemCSList[0].Status, models.MTOServiceItemStatus("APPROVED")) - reServiceMS := factory.FetchOrBuildReServiceByCode(suite.DB(), "MS") + reServiceMS := factory.FetchReServiceByCode(suite.DB(), "MS") msTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceMS.ID, @@ -518,7 +518,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { }, }) - reServiceMS := factory.FetchOrBuildReServiceByCode(suite.DB(), "MS") + reServiceMS := factory.FetchReServiceByCode(suite.DB(), "MS") msTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceMS.ID, @@ -582,7 +582,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { }, }) - reServiceCS := factory.FetchOrBuildReServiceByCode(suite.DB(), "CS") + reServiceCS := factory.FetchReServiceByCode(suite.DB(), "CS") csTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceCS.ID, @@ -615,7 +615,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { suite.Error(err) suite.Contains(err.Error(), "cannot create fee for service item CS: missing requested pickup date (non-PPMs) or expected departure date (PPMs) for shipment") - reServiceMS := factory.FetchOrBuildReServiceByCode(suite.DB(), "MS") + reServiceMS := factory.FetchReServiceByCode(suite.DB(), "MS") msTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceMS.ID, @@ -657,7 +657,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { }, }) - reServiceCS := factory.FetchOrBuildReServiceByCode(suite.DB(), "CS") + reServiceCS := factory.FetchReServiceByCode(suite.DB(), "CS") csTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceCS.ID, @@ -719,7 +719,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { }, }) - reServiceCS := factory.FetchOrBuildReServiceByCode(suite.DB(), "CS") + reServiceCS := factory.FetchReServiceByCode(suite.DB(), "CS") csTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceCS.ID, @@ -762,7 +762,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { suite.Equal(createdServiceItemCSList[0].Status, models.MTOServiceItemStatus("APPROVED")) suite.Equal(*createdServiceItemCSList[0].LockedPriceCents, csTaskOrderFee2.PriceCents) - reServiceMS := factory.FetchOrBuildReServiceByCode(suite.DB(), "MS") + reServiceMS := factory.FetchReServiceByCode(suite.DB(), "MS") msTaskOrderFee := models.ReTaskOrderFee{ ContractYearID: contractYear.ID, ServiceID: reServiceMS.ID, @@ -800,7 +800,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { move := factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil) shipment := factory.BuildMTOShipment(suite.DB(), nil, nil) - reService := factory.BuildReServiceByCode(suite.DB(), "ANY") + reService := factory.FetchReServiceByCode(suite.DB(), "ANY") serviceItemBadShip := models.MTOServiceItem{ MoveTaskOrderID: move.ID, MoveTaskOrder: move, @@ -833,7 +833,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { }, }, nil) - reService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDSHUT) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDSHUT) serviceItemNoWeight := models.MTOServiceItem{ MoveTaskOrderID: move.ID, @@ -857,7 +857,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { LinkOnly: true, }, }, nil) - reServiceDDFSIT := factory.BuildDDFSITReService(suite.DB()) + reServiceDDFSIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) contactOne := models.MTOServiceItemCustomerContact{ Type: models.CustomerContactTypeFirst, @@ -988,10 +988,10 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { }, }, nil) - reServiceDOASIT = factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) - reServiceDOFSIT = factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) - reServiceDOPSIT = factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOPSIT) - reServiceDOSFSC = factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOSFSC) + reServiceDOASIT = factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) + reServiceDOFSIT = factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + reServiceDOPSIT = factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOPSIT) + reServiceDOSFSC = factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOSFSC) return mtoShipment } @@ -1403,7 +1403,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItemFailToCre }, }, nil) - reServiceDOFSIT := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + reServiceDOFSIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) serviceItemDOFSIT := models.MTOServiceItem{ MoveTaskOrder: move, @@ -1428,7 +1428,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItemFailToCre createdServiceItems, _, err := creator.CreateMTOServiceItem(suite.AppContextForTest(), &serviceItemDOFSIT) suite.Nil(createdServiceItems) suite.Error(err) - suite.IsType(apperror.NotFoundError{}, err) + suite.IsType(apperror.InvalidInputError{}, err) }) } @@ -1459,16 +1459,16 @@ func (suite *MTOServiceItemServiceSuite) TestCreateDestSITServiceItem() { ).Return(400, nil) creator := NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) - reServiceDDFSIT := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) + reServiceDDFSIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) return shipment, creator, reServiceDDFSIT } setupAdditionalSIT := func() (models.ReService, models.ReService, models.ReService) { // These codes will be needed for the following tests: - reServiceDDASIT := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) - reServiceDDDSIT := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDDSIT) - reServiceDDSFSC := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDSFSC) + reServiceDDASIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) + reServiceDDDSIT := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDDSIT) + reServiceDDSFSC := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDSFSC) return reServiceDDASIT, reServiceDDDSIT, reServiceDDSFSC } @@ -1496,8 +1496,8 @@ func (suite *MTOServiceItemServiceSuite) TestCreateDestSITServiceItem() { sitDepartureDate := sitEntryDate.AddDate(0, 0, 7) attemptedContact := time.Now() - // Failed creation of DDFSIT because DDASIT/DDDSIT codes are not found in DB - suite.Run("Failure - no DDASIT/DDDSIT codes", func() { + // Successful creation of DDFSIT MTO service item. + suite.Run("Success - Creation of DDFSIT MTO Service Item", func() { shipment, creator, reServiceDDFSIT := setupTestData() serviceItemDDFSIT := models.MTOServiceItem{ @@ -1511,11 +1511,8 @@ func (suite *MTOServiceItemServiceSuite) TestCreateDestSITServiceItem() { Status: models.MTOServiceItemStatusSubmitted, } - createdServiceItems, _, err := creator.CreateMTOServiceItem(suite.AppContextForTest(), &serviceItemDDFSIT) - suite.Nil(createdServiceItems) - suite.Error(err) - suite.IsType(apperror.NotFoundError{}, err) - suite.Contains(err.Error(), "service code") + _, _, err := creator.CreateMTOServiceItem(suite.AppContextForTest(), &serviceItemDDFSIT) + suite.NoError(err) }) // Failed creation of DDFSIT because CustomerContacts has invalid data @@ -1729,7 +1726,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateDestSITServiceItem() { // Make the necessary SIT code objects reServiceDDASIT, _, _ := setupAdditionalSIT() - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) // Make a shipment with no DDFSIT now := time.Now() diff --git a/pkg/services/mto_service_item/mto_service_item_updater_test.go b/pkg/services/mto_service_item/mto_service_item_updater_test.go index 47c55beda43..f2c6889ca98 100644 --- a/pkg/services/mto_service_item/mto_service_item_updater_test.go +++ b/pkg/services/mto_service_item/mto_service_item_updater_test.go @@ -2337,7 +2337,7 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemStatus() { suite.Run("Returns a not found error if the updater can't find the MTO Shipment in the DB.", func() { // Create ReService in DB so that ConvertItemToCustomerExpense makes it to the MTO Shipment check. - testdatagen.FetchOrMakeReService(suite.DB(), testdatagen.Assertions{ReService: models.ReService{Code: "DOFSIT"}}) + testdatagen.FetchReService(suite.DB(), testdatagen.Assertions{ReService: models.ReService{Code: "DOFSIT"}}) _, err := updater.ConvertItemToCustomerExpense( suite.AppContextForTest(), &models.MTOShipment{}, models.StringPointer("test"), true) suite.Error(err) diff --git a/pkg/services/mto_shipment/mto_shipment_creator_test.go b/pkg/services/mto_shipment/mto_shipment_creator_test.go index 4ada4a31e55..82e057c61f6 100644 --- a/pkg/services/mto_shipment/mto_shipment_creator_test.go +++ b/pkg/services/mto_shipment/mto_shipment_creator_test.go @@ -587,7 +587,7 @@ func (suite *MTOShipmentServiceSuite) TestCreateMTOShipment() { } for _, serviceCode := range expectedReServiceCodes { - factory.BuildReServiceByCode(suite.DB(), serviceCode) + factory.FetchReServiceByCode(suite.DB(), serviceCode) } serviceItemsList := []models.MTOServiceItem{ diff --git a/pkg/services/mto_shipment/mto_shipment_updater_test.go b/pkg/services/mto_shipment/mto_shipment_updater_test.go index 321a98bc2bc..230bc161da9 100644 --- a/pkg/services/mto_shipment/mto_shipment_updater_test.go +++ b/pkg/services/mto_shipment/mto_shipment_updater_test.go @@ -1674,7 +1674,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateMTOShipmentStatus() { setupTestData := func() { for i := range expectedReServiceCodes { - factory.BuildReServiceByCode(suite.DB(), expectedReServiceCodes[i]) + factory.FetchReServiceByCode(suite.DB(), expectedReServiceCodes[i]) } mto = factory.BuildMove(suite.DB(), []factory.Customization{ @@ -1941,7 +1941,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateMTOShipmentStatus() { suite.Assert().False(verrs.HasAny()) suite.NoError(err) - factory.BuildReServiceByCode(appCtx.DB(), models.ReServiceCodeDNPK) + factory.FetchReServiceByCode(appCtx.DB(), models.ReServiceCodeDNPK) // This is testing that the Required Delivery Date is calculated correctly. // In order for the Required Delivery Date to be calculated, the following conditions must be true: @@ -2892,7 +2892,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateStatusServiceItems() { setupTestData := func() { for i := range expectedReServiceCodes { - factory.BuildReServiceByCode(suite.DB(), expectedReServiceCodes[i]) + factory.FetchReServiceByCode(suite.DB(), expectedReServiceCodes[i]) } pickupAddress = factory.BuildAddress(suite.DB(), []factory.Customization{ diff --git a/pkg/services/mto_shipment/shipment_approver_test.go b/pkg/services/mto_shipment/shipment_approver_test.go index ec3455de02a..a20a440c8f5 100644 --- a/pkg/services/mto_shipment/shipment_approver_test.go +++ b/pkg/services/mto_shipment/shipment_approver_test.go @@ -75,7 +75,7 @@ func (suite *MTOShipmentServiceSuite) createApproveShipmentSubtestData() (subtes } for _, serviceCode := range subtestData.reServiceCodes { - factory.BuildReServiceByCode(suite.DB(), serviceCode) + factory.FetchReServiceByCode(suite.DB(), serviceCode) } subtestData.mockedShipmentRouter = &shipmentmocks.ShipmentRouter{} @@ -160,7 +160,7 @@ func (suite *MTOShipmentServiceSuite) createApproveShipmentSubtestData() (subtes }, }) - domesticOriginService := factory.FetchOrBuildReService(suite.DB(), []factory.Customization{ + domesticOriginService := factory.FetchReService(suite.DB(), []factory.Customization{ { Model: models.ReService{ Code: models.ReServiceCodeDOP, @@ -515,7 +515,7 @@ func (suite *MTOShipmentServiceSuite) TestApproveShipment() { } for _, serviceCode := range expectedReServiceCodes { - factory.FetchOrBuildReServiceByCode(appCtx.DB(), serviceCode) + factory.FetchReServiceByCode(appCtx.DB(), serviceCode) } // This is testing that the Required Delivery Date is calculated correctly. diff --git a/pkg/services/payment_request/payment_request_recalculator_test.go b/pkg/services/payment_request/payment_request_recalculator_test.go index 55b4a2ec47c..4a91e7f9a10 100644 --- a/pkg/services/payment_request/payment_request_recalculator_test.go +++ b/pkg/services/payment_request/payment_request_recalculator_test.go @@ -464,7 +464,7 @@ func (suite *PaymentRequestServiceSuite) setupRecalculateData1() (models.Move, m suite.MustSave(&ghcDieselFuelPrice) // Domestic Origin Price Service - domOriginPriceService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOP) + domOriginPriceService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOP) domServiceAreaPriceDOP := models.ReDomesticServiceAreaPrice{ ContractID: contractYear.Contract.ID, @@ -479,7 +479,7 @@ func (suite *PaymentRequestServiceSuite) setupRecalculateData1() (models.Move, m suite.MustSave(&domServiceAreaPriceDOP) // Domestic Pack - dpkService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDPK) + dpkService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDPK) // Domestic Other Price domOtherPriceDPK := models.ReDomesticOtherPrice{ diff --git a/pkg/services/ppm_closeout/ppm_closeout_test.go b/pkg/services/ppm_closeout/ppm_closeout_test.go index cbf7c94e90a..2a6f6fa0614 100644 --- a/pkg/services/ppm_closeout/ppm_closeout_test.go +++ b/pkg/services/ppm_closeout/ppm_closeout_test.go @@ -111,7 +111,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - dopService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDOP) + dopService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDOP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -155,7 +155,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - ddpService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDDP) + ddpService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDDP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -182,7 +182,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - dpkService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDPK) + dpkService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -207,7 +207,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - dupkService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDUPK) + dupkService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDUPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -232,7 +232,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - dofsitService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDOFSIT) + dofsitService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDOFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -259,7 +259,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - doasitService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDOASIT) + doasitService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDOASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -286,7 +286,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - ddfsitService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDDFSIT) + ddfsitService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDDFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -313,7 +313,7 @@ func (suite *PPMCloseoutSuite) TestPPMShipmentCreator() { }, }) - ddasitService := factory.BuildReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDDASIT) + ddasitService := factory.FetchReServiceByCode(suite.AppContextForTest().DB(), models.ReServiceCodeDDASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.AppContextForTest().DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ diff --git a/pkg/services/ppmshipment/ppm_estimator_test.go b/pkg/services/ppmshipment/ppm_estimator_test.go index f8c2ece7035..3b3964b2178 100644 --- a/pkg/services/ppmshipment/ppm_estimator_test.go +++ b/pkg/services/ppmshipment/ppm_estimator_test.go @@ -259,7 +259,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - dopService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOP) + dopService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -287,7 +287,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - ddpService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDP) + ddpService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -315,7 +315,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - dpkService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDPK) + dpkService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -341,7 +341,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - dupkService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDUPK) + dupkService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDUPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -367,7 +367,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - dofsitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + dofsitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -395,7 +395,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - doasitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) + doasitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -423,7 +423,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - ddfsitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) + ddfsitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -451,7 +451,7 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() { }, }) - ddasitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) + ddasitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ diff --git a/pkg/services/ppmshipment/ppm_shipment_updater_test.go b/pkg/services/ppmshipment/ppm_shipment_updater_test.go index a46fdf2475c..c33d0e4c8b4 100644 --- a/pkg/services/ppmshipment/ppm_shipment_updater_test.go +++ b/pkg/services/ppmshipment/ppm_shipment_updater_test.go @@ -183,7 +183,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - dopService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOP) + dopService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -211,7 +211,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - ddpService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDP) + ddpService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDP) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -239,7 +239,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - dpkService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDPK) + dpkService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -265,7 +265,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - dupkService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDUPK) + dupkService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDUPK) testdatagen.FetchOrMakeReDomesticOtherPrice(suite.DB(), testdatagen.Assertions{ ReDomesticOtherPrice: models.ReDomesticOtherPrice{ @@ -291,7 +291,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - dofsitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) + dofsitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -319,7 +319,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - doasitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) + doasitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDOASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -347,7 +347,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - ddfsitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) + ddfsitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ @@ -375,7 +375,7 @@ func (suite *PPMShipmentSuite) TestUpdatePPMShipment() { }, }) - ddasitService := factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) + ddasitService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDASIT) testdatagen.FetchOrMakeReDomesticServiceAreaPrice(suite.DB(), testdatagen.Assertions{ ReDomesticServiceAreaPrice: models.ReDomesticServiceAreaPrice{ diff --git a/pkg/services/shipment_address_update/shipment_address_update_requester_test.go b/pkg/services/shipment_address_update/shipment_address_update_requester_test.go index 37b1f6f4457..863e1851d21 100644 --- a/pkg/services/shipment_address_update/shipment_address_update_requester_test.go +++ b/pkg/services/shipment_address_update/shipment_address_update_requester_test.go @@ -680,7 +680,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUp }, }, nil) shipment := addressChange.Shipment - reService := factory.BuildDDFSITReService(suite.DB()) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) sitDestinationOriginalAddress := factory.BuildAddress(suite.DB(), nil, nil) factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{ { @@ -749,7 +749,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUp }, }, nil) shipment := addressChange.Shipment - reService := factory.BuildDDFSITReService(suite.DB()) + reService := factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDDFSIT) sitDestinationOriginalAddress := factory.BuildAddress(suite.DB(), nil, nil) factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{ { @@ -868,7 +868,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUp //Generate a couple of service items to test their status changes upon approval factory.BuildRealMTOServiceItemWithAllDeps(suite.DB(), models.ReServiceCodeMS, move, shipment, nil, nil) factory.BuildRealMTOServiceItemWithAllDeps(suite.DB(), models.ReServiceCodeDLH, move, shipment, nil, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDSH) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDSH) newAddress := models.Address{ StreetAddress1: "123 Any St", @@ -938,7 +938,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUp }, }, }, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDSH) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDSH) newAddress := models.Address{ StreetAddress1: "123 Any St", @@ -1031,7 +1031,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUp //Generate a couple of service items to test their status changes upon approval factory.BuildRealMTOServiceItemWithAllDeps(suite.DB(), models.ReServiceCodeMS, move, shipment, nil, nil) factory.BuildRealMTOServiceItemWithAllDeps(suite.DB(), models.ReServiceCodeDLH, move, shipment, nil, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDSH) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDSH) newAddress := models.Address{ StreetAddress1: "123 Any St", @@ -1098,7 +1098,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUp //Generate a couple of service items to test their status changes upon approval factory.BuildRealMTOServiceItemWithAllDeps(suite.DB(), models.ReServiceCodeMS, move, shipment, nil, nil) factory.BuildRealMTOServiceItemWithAllDeps(suite.DB(), models.ReServiceCodeDSH, move, shipment, nil, nil) - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDLH) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDLH) // Trigger the prime address update to get move in correct state for DSH -> DLH addressChange, _ := addressUpdateRequester.RequestShipmentDeliveryAddressUpdate(suite.AppContextForTest(), shipment.ID, newAddress, "we really need to change the address", etag.GenerateEtag(shipment.UpdatedAt)) diff --git a/pkg/services/sit_extension/sit_extension_denier_test.go b/pkg/services/sit_extension/sit_extension_denier_test.go index f0e70e25c63..3ea81e61d42 100644 --- a/pkg/services/sit_extension/sit_extension_denier_test.go +++ b/pkg/services/sit_extension/sit_extension_denier_test.go @@ -165,7 +165,7 @@ func (suite *SitExtensionServiceSuite) TestDenySITExtension() { today := time.Now() // Test data needed to ensure that conversion sets the correct flags in both sit_extensions and mto_service_items table. - testdatagen.FetchOrMakeReService(suite.DB(), testdatagen.Assertions{ReService: models.ReService{Code: "DOFSIT"}}) + testdatagen.FetchReService(suite.DB(), testdatagen.Assertions{ReService: models.ReService{Code: "DOFSIT"}}) testdatagen.MakeMTOServiceItem(suite.DB(), testdatagen.Assertions{ ReService: models.ReService{ Code: models.ReServiceCodeDOFSIT, diff --git a/pkg/testdatagen/make_mto_service_item.go b/pkg/testdatagen/make_mto_service_item.go index f6b7f8e83bf..a176bba88f6 100644 --- a/pkg/testdatagen/make_mto_service_item.go +++ b/pkg/testdatagen/make_mto_service_item.go @@ -28,7 +28,7 @@ func makeServiceItem(db *pop.Connection, assertions Assertions, isBasicServiceIt reService := assertions.ReService if isZeroUUID(reService.ID) { - reService = FetchOrMakeReService(db, assertions) + reService = FetchReService(db, assertions) } status := assertions.MTOServiceItem.Status diff --git a/pkg/testdatagen/make_re_domestic_other_price.go b/pkg/testdatagen/make_re_domestic_other_price.go index b58d85b1655..3ac4ff51003 100644 --- a/pkg/testdatagen/make_re_domestic_other_price.go +++ b/pkg/testdatagen/make_re_domestic_other_price.go @@ -27,7 +27,7 @@ func MakeReDomesticOtherPrice(db *pop.Connection, assertions Assertions) models. } if reService.ID == uuid.Nil { - reService = FetchOrMakeReService(db, assertions) + reService = FetchReService(db, assertions) } reDomesticOtherPrice := models.ReDomesticOtherPrice{ diff --git a/pkg/testdatagen/make_re_domestic_service_area_price.go b/pkg/testdatagen/make_re_domestic_service_area_price.go index a0096cec4af..14c7fd528b1 100644 --- a/pkg/testdatagen/make_re_domestic_service_area_price.go +++ b/pkg/testdatagen/make_re_domestic_service_area_price.go @@ -39,7 +39,7 @@ func MakeReDomesticServiceAreaPrice(db *pop.Connection, assertions Assertions) m } if reService.ID == uuid.Nil { - reService = FetchOrMakeReService(db, assertions) + reService = FetchReService(db, assertions) } reDomesticServiceAreaPrice := models.ReDomesticServiceAreaPrice{ diff --git a/pkg/testdatagen/make_re_service.go b/pkg/testdatagen/make_re_service.go index 916b3c07647..ed39bd75d18 100644 --- a/pkg/testdatagen/make_re_service.go +++ b/pkg/testdatagen/make_re_service.go @@ -9,24 +9,8 @@ import ( "github.com/transcom/mymove/pkg/models" ) -// MakeReService creates a single ReService -func MakeReService(db *pop.Connection, assertions Assertions) models.ReService { - reService := models.ReService{ - Code: DefaultServiceCode, - Name: "Test Service", - } - - // Overwrite values with those from assertions - mergeModels(&reService, assertions.ReService) - - mustCreate(db, &reService, assertions.Stub) - - return reService -} - -// FetchOrMakeReService returns the ReService for a given service code, or creates one if -// the service code does not exist yet. -func FetchOrMakeReService(db *pop.Connection, assertions Assertions) models.ReService { +// FetchReService returns the ReService for a given service code, or returns a default (DLH). +func FetchReService(db *pop.Connection, assertions Assertions) models.ReService { var existingReServices models.ReServices code := DefaultServiceCode if assertions.ReService.Code != "" { @@ -38,7 +22,7 @@ func FetchOrMakeReService(db *pop.Connection, assertions Assertions) models.ReSe } if len(existingReServices) == 0 { - return MakeReService(db, assertions) + return MakeDefaultReService(db) } return existingReServices[0] @@ -46,5 +30,11 @@ func FetchOrMakeReService(db *pop.Connection, assertions Assertions) models.ReSe // MakeDefaultReService makes a single ReService with default values func MakeDefaultReService(db *pop.Connection) models.ReService { - return MakeReService(db, Assertions{}) + reService := models.ReService{ + Code: "DLH", + Name: "Domestic linehaul", + } + return FetchReService(db, Assertions{ + ReService: reService, + }) } diff --git a/pkg/testingsuite/pop_suite_test.go b/pkg/testingsuite/pop_suite_test.go index 2571ac348b2..d7c56730acd 100644 --- a/pkg/testingsuite/pop_suite_test.go +++ b/pkg/testingsuite/pop_suite_test.go @@ -3,7 +3,6 @@ package testingsuite import ( "testing" - "github.com/gofrs/uuid" "github.com/stretchr/testify/suite" "github.com/transcom/mymove/pkg/factory" @@ -104,44 +103,20 @@ func (suite *PreloadedPopSuite) SetupTest() { } -func (suite *PreloadedPopSuite) SetupSuite() { - - suite.PreloadData(func() { - // Loads some data into database - // ReServiceCodeCS - factory.BuildReService(suite.DB(), []factory.Customization{ - {Model: suite.ReServices[0]}, - }, nil) - - // ReServiceCodeMS - factory.BuildReService(suite.DB(), []factory.Customization{ - {Model: suite.ReServices[1]}, - }, nil) - - // ReServiceCodeDCRT - factory.BuildReService(suite.DB(), []factory.Customization{ - {Model: suite.ReServices[2]}, - }, nil) - }) - -} - func (suite *PreloadedPopSuite) TearDownSuite() { suite.PopTestSuite.TearDown() } func TestPreloadedPopSuite(t *testing.T) { + reservices := []models.ReService{ { - ID: uuid.Must(uuid.NewV4()), Code: models.ReServiceCodeCS, }, { - ID: uuid.Must(uuid.NewV4()), Code: models.ReServiceCodeMS, }, { - ID: uuid.Must(uuid.NewV4()), Code: models.ReServiceCodeDCRT, }, } @@ -164,28 +139,22 @@ func (suite *PreloadedPopSuite) TestRunAlt() { var foundReService models.ReService for _, reservice := range suite.ReServices { - err := suite.DB().Find(&foundReService, reservice.ID) + err := suite.DB().Where("code = $1", reservice.Code).First(&foundReService) suite.NoError(err, "Reservice %s not found", reservice.Code) } // Add a DUCRT ReService, this should not exist outside this subtest - factory.BuildReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) + factory.FetchReServiceByCode(suite.DB(), models.ReServiceCodeDUCRT) }) suite.Run("Run a test to check that subtests are isolated", func() { // Under test: suite.PreloadData // Set up: This suite has preloaded data in the SetupSuite function // Expected outcome: The 3 preloaded reService items are found in the database - // The one new reService added in the subtest above is NOT found var foundReService models.ReService for _, reservice := range suite.ReServices { - err := suite.DB().Find(&foundReService, reservice.ID) + err := suite.DB().Where("code = $1", reservice.Code).First(&foundReService) suite.NoError(err, "Reservice %s not found", reservice.Code) } - - var foundReServices []models.ReService - err := suite.DB().Where("code = ?", models.ReServiceCodeDUCRT).All(&foundReServices) - suite.NoError(err) - suite.Len(foundReServices, 0) }) } @@ -195,19 +164,13 @@ func (suite *PreloadedPopSuite) TestRunAltAgain() { // Under test: suite.PreloadData // Set up: This suite has preloaded data in the SetupSuite function // Expected outcome: The 3 preloaded reService items are found in the database - // The one new reService added in the other test in this suite is NOT found // Reason for a second test is to ensure they don't accidentally get cleaned up between tests var foundReService models.ReService for _, reservice := range suite.ReServices { - err := suite.DB().Find(&foundReService, reservice.ID) + err := suite.DB().Where("code = $1", reservice.Code).First(&foundReService) suite.NoError(err, "Reservice %s not found", reservice.Code) } - - var foundReServices []models.ReService - err := suite.DB().Where("code = ?", models.ReServiceCodeDUCRT).All(&foundReServices) - suite.NoError(err) - suite.Len(foundReServices, 0) }) } diff --git a/scripts/db-truncate b/scripts/db-truncate index 168bdb87e69..6844ae0a77a 100755 --- a/scripts/db-truncate +++ b/scripts/db-truncate @@ -9,7 +9,7 @@ DO \$\$ DECLARE r RECORD; BEGIN FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema() - AND tablename NOT IN ('us_post_region_cities', 're_countries', 're_states', 're_cities', 're_us_post_regions', 're_oconus_rate_areas', 're_rate_areas', 're_intl_transit_times')) LOOP + AND tablename NOT IN ('us_post_region_cities', 're_countries', 're_states', 're_cities', 're_us_post_regions', 're_oconus_rate_areas', 're_rate_areas', 're_intl_transit_times','re_services','re_service_items')) LOOP EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE'; END LOOP; END \$\$;