Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into B-17150-DB-UPDATES-OKTA
Browse files Browse the repository at this point in the history
  • Loading branch information
deandreJones committed Aug 9, 2023
2 parents 15ef55f + 153c3da commit bb2152d
Show file tree
Hide file tree
Showing 51 changed files with 1,939 additions and 683 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.53

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
32 changes: 32 additions & 0 deletions pkg/factory/address_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,38 @@ func BuildAddress(db *pop.Connection, customs []Customization, traits []Trait) m
return address
}

func BuildMinimalAddress(db *pop.Connection, customs []Customization, traits []Trait) models.Address {
customs = setupCustomizations(customs, traits)

// Find address customization and extract the custom address
var cAddress models.Address
if result := findValidCustomization(customs, Address); result != nil {
cAddress = result.Model.(models.Address)
if result.LinkOnly {
return cAddress
}
}

// Create default Address
address := models.Address{
StreetAddress1: "N/A",
City: "Fort Gorden",
State: "GA",
PostalCode: "30813",
Country: models.StringPointer("US"),
}

// Overwrite values with those from customizations
testdatagen.MergeModels(&address, cAddress)

// If db is false, it's a stub. No need to create in database.
if db != nil {
mustCreate(db, &address)
}

return address
}

// BuildDefaultAddress makes an Address with default values
func BuildDefaultAddress(db *pop.Connection) models.Address {
return BuildAddress(db, nil, nil)
Expand Down
2 changes: 1 addition & 1 deletion pkg/factory/shipment_address_update_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func BuildShipmentAddressUpdate(db *pop.Connection, customs []Customization, tra

shipmentAddressUpdate := models.ShipmentAddressUpdate{
ID: uuid.Must(uuid.NewV4()),
ContractorRemarks: "Test Contractor Remark",
ContractorRemarks: "Customer reached out to me this week & let me know they want to move closer to a sick dependent who needs care.",
OfficeRemarks: nil,
Status: models.ShipmentAddressUpdateStatusRequested,
NewAddress: newAddress,
Expand Down
2 changes: 1 addition & 1 deletion pkg/factory/shipment_address_update_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (suite *FactorySuite) TestBuildShipmentAddressUpdate() {

// Validate results, default status is requested
suite.Equal(models.ShipmentAddressUpdateStatusRequested, addressUpdate.Status)
suite.Equal(addressUpdate.ContractorRemarks, "Test Contractor Remark")
suite.Equal(addressUpdate.ContractorRemarks, "Customer reached out to me this week & let me know they want to move closer to a sick dependent who needs care.")
suite.Nil(addressUpdate.OfficeRemarks)
suite.NotNil(addressUpdate.NewAddress)
suite.NotNil(addressUpdate.NewAddressID)
Expand Down
78 changes: 64 additions & 14 deletions pkg/handlers/ghcapi/payment_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,39 @@ func (suite *HandlerSuite) TestShipmentsSITBalanceHandler() {
suite.Run("successful response of the shipments SIT Balance handler", func() {
officeUserTIO := setupTestData()

now := time.Now()
move := factory.BuildAvailableToPrimeMove(suite.DB(), []factory.Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
}, nil)
shipment := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: models.MTOShipment{
Status: models.MTOShipmentStatusApproved,
},
},
{
Model: move,
LinkOnly: true,
},
}, nil)

thirtyDaySITExtensionRequest := 30
factory.BuildSITDurationUpdate(suite.DB(), []factory.Customization{
{
Model: shipment,
LinkOnly: true,
},
{
Model: models.SITDurationUpdate{
Status: models.SITExtensionStatusApproved,
RequestedDays: thirtyDaySITExtensionRequest,
ApprovedDays: &thirtyDaySITExtensionRequest,
},
},
}, nil)

reviewedPaymentRequest := factory.BuildPaymentRequest(suite.DB(), []factory.Customization{
{
Expand All @@ -591,15 +623,11 @@ func (suite *HandlerSuite) TestShipmentsSITBalanceHandler() {
},
},
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
AvailableToPrimeAt: &now,
},
Model: move,
LinkOnly: true,
},
}, nil)

move := reviewedPaymentRequest.MoveTaskOrder

pendingPaymentRequest := factory.BuildPaymentRequest(suite.DB(), []factory.Customization{
{
Model: models.PaymentRequest{
Expand All @@ -614,7 +642,6 @@ func (suite *HandlerSuite) TestShipmentsSITBalanceHandler() {

year, month, day := time.Now().Date()
originEntryDate := time.Date(year, month, day-120, 0, 0, 0, 0, time.UTC)
sitDaysAllowance := 120

doasit := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Expand All @@ -629,18 +656,14 @@ func (suite *HandlerSuite) TestShipmentsSITBalanceHandler() {
},
},
{
Model: models.MTOShipment{
Status: models.MTOShipmentStatusApproved,
SITDaysAllowance: &sitDaysAllowance,
},
Model: shipment,
LinkOnly: true,
},
{
Model: move,
LinkOnly: true,
},
}, nil)

shipment := doasit.MTOShipment
// Creates the payment service item for DOASIT w/ SIT start date param
doasitParam := factory.BuildPaymentServiceItemParam(suite.DB(), []factory.Customization{
{
Expand Down Expand Up @@ -670,6 +693,33 @@ func (suite *HandlerSuite) TestShipmentsSITBalanceHandler() {
Model: move,
LinkOnly: true,
},
{
Model: shipment,
LinkOnly: true,
},
}, nil)
originDepartureDate := originEntryDate.AddDate(0, 0, 90)
factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: models.MTOServiceItem{
Status: models.MTOServiceItemStatusApproved,
SITEntryDate: &originEntryDate,
SITDepartureDate: &originDepartureDate,
},
},
{
Model: models.ReService{
Code: models.ReServiceCodeDOPSIT,
},
},
{
Model: shipment,
LinkOnly: true,
},
{
Model: move,
LinkOnly: true,
},
}, nil)

paymentEndDate := originEntryDate.Add(time.Hour * 24 * 30)
Expand Down
2 changes: 1 addition & 1 deletion pkg/models/line_of_accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type LineOfAccounting struct {
ID uuid.UUID `json:"id" db:"id"`
LoaSysID *int `json:"loa_sys_id" db:"loa_sys_id"`
LoaSysID *int `json:"loa_sys_id" db:"loa_sys_id"` // Using an int here deviates from the TRDM matrix; however, no direct conflicts found as of yet
LoaDptID *string `json:"loa_dpt_id" db:"loa_dpt_id"`
LoaTnsfrDptNm *string `json:"loa_tnsfr_dpt_nm" db:"loa_tnsfr_dpt_nm"`
LoaBafID *string `json:"loa_baf_id" db:"loa_baf_id"`
Expand Down
6 changes: 0 additions & 6 deletions pkg/models/transportation_accounting_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ func (t *TransportationAccountingCode) Validate(_ *pop.Connection) (*validate.Er
func (t TransportationAccountingCode) TableName() string {
return "transportation_accounting_codes"
}

func MapTransportationAccountingCodeFileRecordToInternalStruct(tacFileRecord TransportationAccountingCodeTrdmFileRecord) TransportationAccountingCode {
return TransportationAccountingCode{
TAC: tacFileRecord.TRNSPRTN_ACNT_CD,
}
}
73 changes: 0 additions & 73 deletions pkg/models/transportation_accounting_code_test.go
Original file line number Diff line number Diff line change
@@ -1,83 +1,10 @@
package models_test

import (
"reflect"
"testing"

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

// This test will check if any field names are not being mapped properly. This test is not finalized.
func TestTransportationAccountingCodeMapForUnusedFields(t *testing.T) {
t.Skip("Skipping TestTransportationAccountingCodeMapForUnusedFields until the fields and usecase has been finalized.")

// Example of TransportationAccountingCodeTrdmFileRecord
tacFileRecord := models.TransportationAccountingCodeTrdmFileRecord{
TRNSPRTN_ACNT_CD: "4EVR",
TAC_SYS_ID: "3080819",
LOA_SYS_ID: "55555555",
TAC_FY_TXT: "2023",
TAC_FN_BL_MOD_CD: "W",
ORG_GRP_DFAS_CD: "HS",
TAC_MVT_DSG_ID: "",
TAC_TY_CD: "O",
TAC_USE_CD: "N",
TAC_MAJ_CLMT_ID: "012345",
TAC_BILL_ACT_TXT: "123456",
TAC_COST_CTR_NM: "012345",
BUIC: "",
TAC_HIST_CD: "",
TAC_STAT_CD: "I",
TRNSPRTN_ACNT_TX: "For the purpose of MacDill AFB transporting to Scott AFB",
TRNSPRTN_ACNT_BGN_DT: "2022-10-01 00:00:00",
TRNSPRTN_ACNT_END_DT: "2023-09-30 00:00:00",
DD_ACTVTY_ADRS_ID: "A12345",
TAC_BLLD_ADD_FRST_LN_TX: "MacDill",
TAC_BLLD_ADD_SCND_LN_TX: "Second Address Line",
TAC_BLLD_ADD_THRD_LN_TX: "",
TAC_BLLD_ADD_FRTH_LN_TX: "TAMPA FL 33621",
TAC_FNCT_POC_NM: "[email protected]",
}

mappedStruct := models.MapTransportationAccountingCodeFileRecordToInternalStruct(tacFileRecord)

reflectedMappedStruct := reflect.TypeOf(mappedStruct)
reflectedTacFileRecord := reflect.TypeOf(tacFileRecord)

// Iterate through each field in the tacRecord struct for the comparison
for i := 0; i < reflectedTacFileRecord.NumField(); i++ {
fieldName := reflectedTacFileRecord.Field(i).Name

// Check if this field exists in the reflectedMappedStruct
_, exists := reflectedMappedStruct.FieldByName(fieldName)

// Error if the field isn't found in the reflectedMappedStruct
if !exists {
t.Errorf("Field '%s' in TransportationAccountingCodeTrdmFileRecord is not used in MapTransportationAccountingCodeFileRecordToInternalStruct function", fieldName)
}
}
}

// This function will test the receival of a parsed TAC that has undergone the pipe delimited .txt file parser. It will test
// that the received values correctly map to our internal TAC struct. For example, our Transporation Accounting Code is called
// "TAC" in its struct, however when it is received in pipe delimited format it will be received as "TRNSPRTN_ACNT_CD".
// This function makes sure it gets connected properly.
func TestTransportationAccountingCodeMapToInternal(t *testing.T) {

tacFileRecord := models.TransportationAccountingCodeTrdmFileRecord{
TRNSPRTN_ACNT_CD: "4EVR",
}

mappedTacFileRecord := models.MapTransportationAccountingCodeFileRecordToInternalStruct(tacFileRecord)

// Check that the TRNSPRTN_ACNT_CD field in the original struct was correctly
// mapped to the TAC field in the resulting struct
if mappedTacFileRecord.TAC != tacFileRecord.TRNSPRTN_ACNT_CD {
t.Errorf("Expected TAC to be '%s', got '%s'", tacFileRecord.TRNSPRTN_ACNT_CD, mappedTacFileRecord.TAC)
}
}

func (suite *ModelSuite) Test_CanSaveValidTac() {
tac := models.TransportationAccountingCode{
TAC: "Tac1",
Expand Down
34 changes: 0 additions & 34 deletions pkg/models/transportation_accounting_code_trdm_file.go

This file was deleted.

11 changes: 11 additions & 0 deletions pkg/parser/loa/fixtures/Line Of Accounting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Unclassified
LOA_SYS_ID|LOA_DPT_ID|LOA_TNSFR_DPT_NM|LOA_BAF_ID|LOA_TRSY_SFX_TX|LOA_MAJ_CLM_NM|LOA_OP_AGNCY_ID|LOA_ALLT_SN_ID|LOA_PGM_ELMNT_ID|LOA_TSK_BDGT_SBLN_TX|LOA_DF_AGNCY_ALCTN_RCPNT_ID|LOA_JB_ORD_NM|LOA_SBALTMT_RCPNT_ID|LOA_WK_CNTR_RCPNT_NM|LOA_MAJ_RMBSMT_SRC_ID|LOA_DTL_RMBSMT_SRC_ID|LOA_CUST_NM|LOA_OBJ_CLS_ID|LOA_SRV_SRC_ID|LOA_SPCL_INTR_ID|LOA_BDGT_ACNT_CLS_NM|LOA_DOC_ID|LOA_CLS_REF_ID|LOA_INSTL_ACNTG_ACT_ID|LOA_LCL_INSTL_ID|LOA_FMS_TRNSACTN_ID|LOA_DSC_TX|LOA_BGN_DT|LOA_END_DT|LOA_FNCT_PRS_NM|LOA_STAT_CD|LOA_HIST_STAT_CD|LOA_HS_GDS_CD|ORG_GRP_DFAS_CD|LOA_UIC|LOA_TRNSN_ID|LOA_SUB_ACNT_ID|LOA_BET_CD|LOA_FND_TY_FG_CD|LOA_BGT_LN_ITM_ID|LOA_SCRTY_COOP_IMPL_AGNC_CD|LOA_SCRTY_COOP_DSGNTR_CD|LOA_SCRTY_COOP_LN_ITM_ID|LOA_AGNC_DSBR_CD|LOA_AGNC_ACNTNG_CD|LOA_FND_CNTR_ID|LOA_CST_CNTR_ID|LOA_PRJ_ID|LOA_ACTVTY_ID|LOA_CST_CD|LOA_WRK_ORD_ID|LOA_FNCL_AR_ID|LOA_SCRTY_COOP_CUST_CD|LOA_END_FY_TX|LOA_BG_FY_TX|LOA_BGT_RSTR_CD|LOA_BGT_SUB_ACT_CD
124641|97||4930|AA37||6D|0000|MZZF0000|||||D0000||||22NL|||MA1MN4|FRT1MNUSAF7790||011000|||CONUS ENTRY|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
124642|97||4930|AA37||6D|0000|MZZF0000|||||D0000||||22N2|||MA1MN4|FRT1MNUSAF8790||011000|||OCONUS ENTRY|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
124643|97||4930|AA37||6D|0000|MZZF0000|||||D0000||||22NL|||P50MD6|FRT0MDUSAF9790||011000|||ENTRY TYPE A|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
124644|97||4930|AA37||6D|0000|MZZF0000|||||D0000||||22NL|||P50MN6|FRT0MNUSAF1790||011000|||ADDITIONAL ENTRY|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
124645|97||4930|AA37||6D|0000|MZZF0000|||||D0000||||22NL|||P51MD6|FRT1MDUSAF2790||011000|||FURNITURE KIT|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
124646|97||4930|AA37||6D|0000|MZZF0000|||||D0000||||22NL|||P51MN6|FRT1MNUSAF3790||011000|||PIECE FOR REPAIR|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
124647|97||4930|AA37||6D|0000|MZZF0000|||||D0000||||22NL|||P52MD6|FRT2MDUSAF4790||011000|||ENTRY TYPE B|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
124840|97||4930|AC6E||62|AC6E|SM0Z1400|||||||||22N2|||AC6E00|FRTAC6EAAJA790||028043|||PHONE REPAIR KIT|2006-10-01 00:00:00|2007-09-30 00:00:00||U|||DZ|||||||||||||||||||||||
Unclassified
Loading

0 comments on commit bb2152d

Please sign in to comment.