From f6c2102a1bd1ff19a493a2a080370e515d290dcb Mon Sep 17 00:00:00 2001 From: msaki-caci Date: Mon, 18 Nov 2024 15:25:35 +0000 Subject: [PATCH] B-21671 Create re_fsc_multipliers table Create models for multipliers table Add table to migrations manifest --- migrations/app/migrations_manifest.txt | 1 + ...553_create_re_fsc_multipliers_table.up.sql | 13 ++++++++++++ pkg/models/mto_service_items.go | 2 ++ pkg/models/re_fsc_multipliers.go | 21 +++++++++++++++++++ scripts/db-truncate | 2 +- 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 migrations/app/schema/20241115214553_create_re_fsc_multipliers_table.up.sql create mode 100644 pkg/models/re_fsc_multipliers.go diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index fb7c16d9c9b..ed7a1a70252 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -1029,3 +1029,4 @@ 20241029125015_add_orders_type_enum.up.sql 20241029144404_hdt-614-adjust-accomack-county.up.sql 20241111223224_change_international_sit_services_to_accessorials.up.sql +20241115214553_create_re_fsc_multipliers_table.up.sql diff --git a/migrations/app/schema/20241115214553_create_re_fsc_multipliers_table.up.sql b/migrations/app/schema/20241115214553_create_re_fsc_multipliers_table.up.sql new file mode 100644 index 00000000000..de5ebba77eb --- /dev/null +++ b/migrations/app/schema/20241115214553_create_re_fsc_multipliers_table.up.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS re_fsc_multipliers ( + id uuid NOT NULL, + low_weight int NOT NULL, + high_weight int NOT NULL, + multiplier decimal NOT NULL, + created_at timestamp NOT NULL DEFAULT NOW(), + updated_at timestamp NOT NULL DEFAULT NOW(), +); + +COMMENT ON TABLE re_fsc_multipliers IS 'Stores data needed to needed to calculate FSC'; +COMMENT ON COLUMN re_fsc_multipliers.low_weight IS 'The lowest weight permitted for a shipment'; +COMMENT ON COLUMN re_fsc_multipliers.high_weight IS 'The highest weight permitted for a shipment'; +COMMENT ON COLUMN re_fsc_multipliers.multiplier IS 'The decimal multiplier used to calculate the FSC'; \ No newline at end of file diff --git a/pkg/models/mto_service_items.go b/pkg/models/mto_service_items.go index 862a25fce32..7dd5ac05264 100644 --- a/pkg/models/mto_service_items.go +++ b/pkg/models/mto_service_items.go @@ -68,6 +68,7 @@ type MTOServiceItem struct { StandaloneCrate *bool `db:"standalone_crate"` LockedPriceCents *unit.Cents `db:"locked_price_cents"` ServiceLocation *ServiceLocationType `db:"service_location"` + FscMultiplier *uuid.UUID `db:"re_fsc_multiplier"` } // MTOServiceItemSingle is an object representing a single column in the service items table @@ -100,6 +101,7 @@ type MTOServiceItemSingle struct { CustomerExpenseReason *string `db:"customer_expense_reason"` SITDeliveryMiles *unit.Miles `db:"sit_delivery_miles"` PricingEstimate *unit.Cents `db:"pricing_estimate"` + FscMultiplier *uuid.UUID `db:"re_fsc_multiplier"` } // TableName overrides the table name used by Pop. diff --git a/pkg/models/re_fsc_multipliers.go b/pkg/models/re_fsc_multipliers.go new file mode 100644 index 00000000000..37ec7a1b884 --- /dev/null +++ b/pkg/models/re_fsc_multipliers.go @@ -0,0 +1,21 @@ +package models + +import ( + "time" + + "github.com/gofrs/uuid" + "google.golang.org/genproto/googleapis/type/decimal" +) + +type FscMultiplier struct { + ID uuid.UUID `json:"id" db:"id" rw:"r"` + LowWeight int `json:"low_weight" rw:"r"` + HighWeight int `json:"high_weight" rw:"r"` + Multiplier *decimal.Decimal `json:"multiplier"` + CreatedAt time.Time `json:"created_at" db:"created_at" rw:"r"` + UpdatedAt time.Time `json:"updated_at" db:"updated_at" rw:"r"` +} + +func (f FscMultiplier) TableName() string { + return "re_fsc_multipliers" +} diff --git a/scripts/db-truncate b/scripts/db-truncate index 6844ae0a77a..db0ec07dd86 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','re_services','re_service_items')) 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', 're_fsc_multipliers')) LOOP EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE'; END LOOP; END \$\$;