Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main b 18911 gun safe backend #12557

Merged
merged 16 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,9 @@
20240402155228_updateLongBeachGbloc.up.sql
20240402192009_add_shipment_locator_and_shipment_seq_num.up.sql
20240403172437_backfill_counties_again.up.sql
20240404152441_add_gun_safe_to_entitlements.up.sql
20240405190435_add_safety_privilege.up.sql
20240411201158_add_application_parameter_and_validation_code_table.up.sql
20240412201837_edit_gun_safe_entitlement_not_null.up.sql
20240416145256_update_safety_privilege_label.up.sql
20240503123556_add_diversion_reason_to_mto_shipments.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Adds new column to entitlements table
-- allows customer to move a gun safe with their move.
ALTER TABLE entitlements
ADD COLUMN IF NOT EXISTS gun_safe BOOLEAN DEFAULT FALSE;

-- Comments on new column
COMMENT ON COLUMN entitlements.gun_safe IS 'True if customer is entitled to move a gun safe up to 500 lbs without it being charged against their authorized weight allowance.';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- COALESCE makes sure that any currently NULL gun_safe values are converted to false before setting to NOT NULL.
ALTER TABLE entitlements
ALTER COLUMN gun_safe TYPE boolean USING (COALESCE(gun_safe, false)),
ALTER COLUMN gun_safe SET DEFAULT false,
Copy link
Contributor

@deandreJones deandreJones May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is taken care of in the above migration file?
ALTER COLUMN gun_safe SET DEFAULT false,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in my original migration that added the gun_safe column, it could be either T, F, or null, but after finding that null would error out in some cases, I added this migration to edit the table so that it's only true or false, since that also makes sense logically anyway. Now it defaults to false, and is only set to true if the customer/office user flags that a gun safe is allowed.

ALTER COLUMN gun_safe SET NOT NULL;
28 changes: 28 additions & 0 deletions pkg/gen/ghcapi/embedded_spec.go

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

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

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

4 changes: 4 additions & 0 deletions pkg/gen/ghcmessages/entitlements.go

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

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

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

8 changes: 8 additions & 0 deletions pkg/gen/primeapi/embedded_spec.go

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

4 changes: 4 additions & 0 deletions pkg/gen/primemessages/entitlements.go

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

8 changes: 8 additions & 0 deletions pkg/gen/primev2api/embedded_spec.go

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

4 changes: 4 additions & 0 deletions pkg/gen/primev2messages/entitlements.go

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

8 changes: 8 additions & 0 deletions pkg/gen/primev3api/embedded_spec.go

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

4 changes: 4 additions & 0 deletions pkg/gen/primev3messages/entitlements.go

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

8 changes: 8 additions & 0 deletions pkg/gen/supportapi/embedded_spec.go

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

4 changes: 4 additions & 0 deletions pkg/gen/supportmessages/entitlement.go

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

4 changes: 3 additions & 1 deletion pkg/handlers/ghcapi/internal/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ func Entitlement(entitlement *models.Entitlement) *ghcmessages.Entitlements {
totalDependents = int64(*entitlement.TotalDependents)
}
requiredMedicalEquipmentWeight := int64(entitlement.RequiredMedicalEquipmentWeight)
gunSafe := entitlement.GunSafe
return &ghcmessages.Entitlements{
ID: strfmt.UUID(entitlement.ID.String()),
AuthorizedWeight: authorizedWeight,
Expand All @@ -629,7 +630,8 @@ func Entitlement(entitlement *models.Entitlement) *ghcmessages.Entitlements {
TotalWeight: totalWeight,
RequiredMedicalEquipmentWeight: requiredMedicalEquipmentWeight,
OrganizationalClothingAndIndividualEquipment: entitlement.OrganizationalClothingAndIndividualEquipment,
ETag: etag.GenerateEtag(entitlement.UpdatedAt),
GunSafe: gunSafe,
ETag: etag.GenerateEtag(entitlement.UpdatedAt),
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/primeapi/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func Entitlement(entitlement *models.Entitlement) *primemessages.Entitlements {
ID: strfmt.UUID(entitlement.ID.String()),
AuthorizedWeight: authorizedWeight,
DependentsAuthorized: entitlement.DependentsAuthorized,
GunSafe: entitlement.GunSafe,
NonTemporaryStorage: entitlement.NonTemporaryStorage,
PrivatelyOwnedVehicle: entitlement.PrivatelyOwnedVehicle,
ProGearWeight: int64(entitlement.ProGearWeight),
Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/primeapiv2/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func Entitlement(entitlement *models.Entitlement) *primev2messages.Entitlements
ID: strfmt.UUID(entitlement.ID.String()),
AuthorizedWeight: authorizedWeight,
DependentsAuthorized: entitlement.DependentsAuthorized,
GunSafe: entitlement.GunSafe,
NonTemporaryStorage: entitlement.NonTemporaryStorage,
PrivatelyOwnedVehicle: entitlement.PrivatelyOwnedVehicle,
ProGearWeight: int64(entitlement.ProGearWeight),
Expand Down
1 change: 1 addition & 0 deletions pkg/models/ghc_entitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Entitlement struct {
DBAuthorizedWeight *int `db:"authorized_weight"`
WeightAllotted *WeightAllotment `db:"-"`
StorageInTransit *int `db:"storage_in_transit"`
GunSafe bool `db:"gun_safe"`
RequiredMedicalEquipmentWeight int `db:"required_medical_equipment_weight"`
OrganizationalClothingAndIndividualEquipment bool `db:"organizational_clothing_and_individual_equipment"`
ProGearWeight int `db:"pro_gear_weight"`
Expand Down
8 changes: 8 additions & 0 deletions pkg/services/order/order_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ func allowanceFromTOOPayload(existingOrder models.Order, payload ghcmessages.Upd
order.Entitlement.StorageInTransit = &newSITAllowance
}

if payload.GunSafe != nil {
order.Entitlement.GunSafe = *payload.GunSafe
}

return order
}

Expand Down Expand Up @@ -478,6 +482,10 @@ func allowanceFromCounselingPayload(existingOrder models.Order, payload ghcmessa
order.Entitlement.StorageInTransit = &newSITAllowance
}

if payload.GunSafe != nil {
order.Entitlement.GunSafe = *payload.GunSafe
}

return order
}

Expand Down
3 changes: 3 additions & 0 deletions swagger-def/definitions/prime/Entitlements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ properties:
example: true
type: boolean
x-nullable: true
gunSafe:
type: boolean
example: false
nonTemporaryStorage:
example: false
type: boolean
Expand Down
11 changes: 11 additions & 0 deletions swagger-def/ghc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3917,6 +3917,9 @@ definitions:
example: true
type: boolean
x-nullable: true
gunSafe:
type: boolean
example: false
nonTemporaryStorage:
example: false
type: boolean
Expand Down Expand Up @@ -4666,6 +4669,10 @@ definitions:
description: the number of storage in transit days that the customer is entitled to for a given shipment on their move
type: integer
minimum: 0
gunSafe:
description: True if user is entitled to move a gun safe (up to 500 lbs) as part of their move without it being charged against their weight allowance.
type: boolean
x-nullable: true
UpdateBillableWeightPayload:
type: object
properties:
Expand Down Expand Up @@ -4735,6 +4742,10 @@ definitions:
description: the number of storage in transit days that the customer is entitled to for a given shipment on their move
type: integer
minimum: 0
gunSafe:
description: True if user is entitled to move a gun safe (up to 500 lbs) as part of their move without it being charged against their weight allowance.
type: boolean
x-nullable: true
MoveTaskOrder:
description: The Move (MoveTaskOrder)
properties:
Expand Down
3 changes: 3 additions & 0 deletions swagger-def/support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,9 @@ definitions:
example: true
type: boolean
x-nullable: true
gunSafe:
type: boolean
example: false
nonTemporaryStorage:
example: false
type: boolean
Expand Down
Loading
Loading