Skip to content

Commit

Permalink
B-21671
Browse files Browse the repository at this point in the history
Create re_fsc_multipliers table
Create models for multipliers table
Add table to migrations manifest
  • Loading branch information
msaki-caci committed Nov 18, 2024
1 parent 6a7bd45 commit f6c2102
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 2 additions & 0 deletions pkg/models/mto_service_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions pkg/models/re_fsc_multipliers.go
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion scripts/db-truncate
Original file line number Diff line number Diff line change
Expand Up @@ -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 \$\$;
Expand Down

0 comments on commit f6c2102

Please sign in to comment.