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

B-20671 B-20674 B-20758 simulate process TPPS cmd MAIN #13624

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
8b46a64
first draft for new tpps paid invoice report table
traskowskycaci Aug 2, 2024
328b614
remove fluff from migration file
traskowskycaci Aug 2, 2024
faa3042
bare bones of a tpps paid invoice parser
traskowskycaci Aug 2, 2024
475f59b
add test for string version of the csv file
traskowskycaci Aug 5, 2024
7b43e8e
update comments to reference tpps
traskowskycaci Aug 5, 2024
30ff7c7
parse test csv into TPPSData struct
traskowskycaci Aug 6, 2024
fe8616a
parse test csv into TPPSData struct
traskowskycaci Aug 6, 2024
097c161
fix a few small typos
traskowskycaci Aug 6, 2024
6b32ff6
store tpps report entries to database
traskowskycaci Aug 9, 2024
4a1527a
add path to test csv for parsing and storing
traskowskycaci Aug 9, 2024
3e5c3d9
add parser test, clean up
traskowskycaci Aug 9, 2024
c02f42e
fix parser test
traskowskycaci Aug 9, 2024
b76c4bc
add validators for tpps paid fields
traskowskycaci Aug 9, 2024
ac6870d
add TPPSPaidInvoiceReport to editype lists
traskowskycaci Aug 9, 2024
8f74ed4
undo commenting out of ld_classic
traskowskycaci Aug 9, 2024
b7bdf63
clean up comments and test names
traskowskycaci Aug 9, 2024
5526253
exclude from tpps_paid_invoice_report/parser_test from hitting the tr…
traskowskycaci Aug 9, 2024
04466d7
Merge branch 'main' into B-20671-parse-tpps-paid-invoice-MAIN
traskowskycaci Aug 12, 2024
51951df
catch err for os.open, test for failure to open file
traskowskycaci Aug 12, 2024
6f68094
make column headers dynamic rather than hard-coded
traskowskycaci Aug 12, 2024
d0a097f
add comment notating tab-delimiter
traskowskycaci Aug 12, 2024
0f66764
add comment for test string delimiters
traskowskycaci Aug 12, 2024
7c3355a
reformat validators and only keep necessary validators in
traskowskycaci Aug 12, 2024
ec06c72
move tpps_paid_invoice_report_testfile.csv to fixtures folder
traskowskycaci Aug 13, 2024
9fa33e8
be explicit about which fields are required for processing
traskowskycaci Aug 13, 2024
13174d6
add test file for pkg/models/tpps_paid_invoice_report.go
traskowskycaci Aug 13, 2024
3a29766
nullable value handling
traskowskycaci Aug 14, 2024
cbd5821
Merge branch 'main' into B-20671-parse-tpps-paid-invoice-MAIN
traskowskycaci Aug 15, 2024
053396b
Merge branch 'main' into B-20671-parse-tpps-paid-invoice-MAIN
traskowskycaci Aug 15, 2024
2b3b46b
add fk to reference payment_request_number from tpps invoice number
traskowskycaci Aug 15, 2024
6af1968
fetch tpps invoice report info for payment request
traskowskycaci Aug 15, 2024
fc0a0d7
remove commenting out of ldclassic
traskowskycaci Aug 16, 2024
0b9b860
add relevant tpps report data to pr and pr si payloads
traskowskycaci Aug 16, 2024
31a91bf
Merge branch 'main' into B-20674-tpps-paid-info-MAIN
traskowskycaci Aug 16, 2024
1649418
display tpps info on UI for payment requests
traskowskycaci Aug 19, 2024
984da8e
fix failing server tests
traskowskycaci Aug 19, 2024
1e772c4
add rejected amount for TPPS paid and TPPS received statuses
traskowskycaci Aug 19, 2024
c0887d1
add client tests for showing tpps info
traskowskycaci Aug 19, 2024
3feb96f
reorder payment request details for tpps paid
traskowskycaci Aug 19, 2024
c60e241
Merge branch 'main' into B-20674-tpps-paid-info-MAIN
traskowskycaci Aug 19, 2024
2db976c
Merge branch 'main' into B-20674-tpps-paid-info-MAIN
traskowskycaci Aug 20, 2024
fbfc31f
Merge branch 'main' into B-20671-parse-tpps-paid-invoice-MAIN
traskowskycaci Aug 20, 2024
37e71f8
add parsing test for encoded version of file, fix a few issues in parser
traskowskycaci Aug 20, 2024
3829afb
change negative one to zero
traskowskycaci Aug 21, 2024
770931e
add nil check on tppsPaidReportData
traskowskycaci Aug 21, 2024
fd6db79
add comments to explain TPPS invoice relationship to PR
traskowskycaci Aug 21, 2024
1207228
Merge branch 'B-20671-parse-tpps-paid-invoice-MAIN' into B-20758-tpps…
traskowskycaci Aug 21, 2024
b8da51c
fix typo on processes
traskowskycaci Aug 22, 2024
08a4dfb
Merge branch 'B-20671-parse-tpps-paid-invoice-MAIN' into B-20758-tpps…
traskowskycaci Aug 22, 2024
2d6a6dd
update PR status to PAID, expand tests
traskowskycaci Aug 23, 2024
b3b4c21
add payment request ID to logging
traskowskycaci Aug 28, 2024
9fe7e5d
maintain zap error
traskowskycaci Aug 28, 2024
628199f
Merge branch 'main' into B-20671-parse-tpps-paid-invoice-MAIN
traskowskycaci Aug 29, 2024
bd719e5
Merge branch 'main' into B-20671-parse-tpps-paid-invoice-MAIN
traskowskycaci Aug 29, 2024
1cf1737
Merge branch 'main' into B-20674-tpps-paid-info-MAIN
traskowskycaci Aug 29, 2024
e02aec1
Merge branch 'B-20674-tpps-paid-info-MAIN' into B-20671-test-pickup-dir
traskowskycaci Aug 29, 2024
1450071
Merge branch 'main' into B-20758-tpps-paid-pr-status-MAIN
traskowskycaci Aug 29, 2024
8fb44e8
Merge branch 'B-20758-tpps-paid-pr-status-MAIN' into B-20671-test-pic…
traskowskycaci Aug 29, 2024
2576953
create new simulate-process-tpps cmd to process tpps paid invoice report
traskowskycaci Aug 29, 2024
7d3496b
Merge branch 'main' into B-20671-B-20574-B-20758-simulate-process-tpp…
traskowskycaci Aug 29, 2024
913c71d
comment out unused code until B-20560 is started
traskowskycaci Aug 30, 2024
f9a0d41
Merge branch 'main' into B-20671-B-20574-B-20758-simulate-process-tpp…
traskowskycaci Aug 30, 2024
e910331
add comment explaining purpose
traskowskycaci Sep 3, 2024
b39041b
Merge branch 'main' into B-20671-B-20574-B-20758-simulate-process-tpp…
traskowskycaci Sep 3, 2024
02a2719
Merge branch 'main' into B-20671-B-20574-B-20758-simulate-process-tpp…
traskowskycaci Sep 4, 2024
d744f3c
Merge branch 'main' into B-20671-B-20574-B-20758-simulate-process-tpp…
traskowskycaci Sep 4, 2024
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
18 changes: 12 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ repos:
pkg/cli/auth.go$|
)$
- id: trailing-whitespace
exclude: ^public/swagger-ui/
exclude: >
(?x)^(
public/swagger-ui/|
pkg/edi/tpps_paid_invoice_report/parser_test.go|
)$

- repo: https://github.com/golangci/golangci-lint
rev: v1.57.2
Expand Down Expand Up @@ -134,11 +138,13 @@ repos:
language: script
files: swagger/.*
types: [yaml]
exclude: swagger-def/.* # These are partial swagger files that are compiled into the ones in swagger/*.
# They will be checked unless explicitly excluded, but they will fail.
# By only validating the compiled files, we are effectively checking these files as well.
require_serial: true # Make sure that we only call the script once with all affected YAML files as CI seems to
# have sporadic failures if we call this script in parallel.
exclude:
swagger-def/.* # These are partial swagger files that are compiled into the ones in swagger/*.
# They will be checked unless explicitly excluded, but they will fail.
# By only validating the compiled files, we are effectively checking these files as well.
require_serial:
true # Make sure that we only call the script once with all affected YAML files as CI seems to
# have sporadic failures if we call this script in parallel.

- repo: local
hooks:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ bin/tls-checker: $(shell find cmd/tls-checker -name '*.go') $(PKG_GOSRC) .check_
bin/generate-payment-request-edi: $(shell find cmd/generate-payment-request-edi -name '*.go') $(PKG_GOSRC) .check_go_version.stamp .check_gopath.stamp
go build -ldflags "$(LDFLAGS)" -o bin/generate-payment-request-edi ./cmd/generate-payment-request-edi

bin/simulate-process-tpps: $(shell find cmd/simulate-process-tpps -name '*.go') $(PKG_GOSRC) .check_go_version.stamp .check_gopath.stamp
go build -ldflags "$(LDFLAGS)" -o bin/simulate-process-tpps ./cmd/simulate-process-tpps

#
# ----- END BIN TARGETS -----
#
Expand Down Expand Up @@ -404,6 +407,7 @@ build_tools: bin/gin \
bin/webhook-client \
bin/read-alb-logs \
bin/send-to-gex \
bin/simulate-process-tpps \
bin/tls-checker ## Build all tools

.PHONY: build
Expand Down
11 changes: 11 additions & 0 deletions cmd/milmove-tasks/process_edis.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,16 @@ func processEDIs(_ *cobra.Command, _ []string) error {
logger.Info("Successfully processed EDI824 application advice responses")
}

// Pending completion of B-20560, uncomment the code below
/*
// Process TPPS paid invoice report
pathTPPSPaidInvoiceReport := v.GetString(cli.SFTPTPPSPaidInvoiceReportPickupDirectory)
_, err = syncadaSFTPSession.FetchAndProcessSyncadaFiles(appCtx, pathTPPSPaidInvoiceReport, lastReadTime, invoice.NewTPPSPaidInvoiceReportProcessor())
if err != nil {
logger.Error("Error reading TPPS Paid Invoice Report application advice responses", zap.Error(err))
} else {
logger.Info("Successfully processed TPPS Paid Invoice Report application advice responses")
}
*/
return nil
}
111 changes: 111 additions & 0 deletions cmd/simulate-process-tpps/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package main

import (
"fmt"
"log"
"os"
"strings"

"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/cli"
"github.com/transcom/mymove/pkg/logging"
processor "github.com/transcom/mymove/pkg/services/invoice"
)

// Call this from command line with go run ./cmd/simulate-process-tpps/
// This binary will be explicitly for simulation and testing purposes for the scenario of
// payment request numbers 1077-4079-3, 1208-5962-1, 8801-2773-2, 8801-2773-3
// Those payment request numbers must exist in the payment_requests table in order for
// this binary to be used properly

func checkConfig(v *viper.Viper, logger *zap.Logger) error {

err := cli.CheckDatabase(v, logger)
if err != nil {
return err
}

return nil
}

func initFlags(flag *pflag.FlagSet) {
// DB Config
cli.InitDatabaseFlags(flag)

// Logging Levels
cli.InitLoggingFlags(flag)

// Don't sort flags
flag.SortFlags = false
}

func main() {
flag := pflag.CommandLine
initFlags(flag)
parseErr := flag.Parse(os.Args[1:])
if parseErr != nil {
log.Fatal("failed to parse flags", zap.Error(parseErr))
}

v := viper.New()
bindErr := v.BindPFlags(flag)
if bindErr != nil {
log.Fatal("failed to bind flags", zap.Error(bindErr))
}
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
v.AutomaticEnv()

dbEnv := v.GetString(cli.DbEnvFlag)

logger, _, err := logging.Config(logging.WithEnvironment(dbEnv), logging.WithLoggingLevel(v.GetString(cli.LoggingLevelFlag)))
if err != nil {
log.Fatalf("failed to initialize Zap logging due to %v", err)
}
zap.ReplaceGlobals(logger)

err = checkConfig(v, logger)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err.Error())
fmt.Fprintln(os.Stderr, "Usage:")
flag.PrintDefaults()
os.Exit(1)
}

// DB connection
dbConnection, err := cli.InitDatabase(v, logger)
if err != nil {
logger.Fatal("Connecting to DB", zap.Error(err))
}

// Create new TPPS Paid Invoice Report Processor
processor := processor.NewTPPSPaidInvoiceReportProcessor()

appCtx := appcontext.NewAppContext(dbConnection, logger, nil)

testTPPSPaidInvoiceReportFilePath := "pkg/services/invoice/fixtures/tpps_paid_invoice_report_testfile_tpps_pickup_dir.csv"

err = processor.ProcessFile(appCtx, testTPPSPaidInvoiceReportFilePath, "")
if err != nil {
appCtx.Logger().Error("Error while processing TPPS Paid Invoice Report file", zap.String("path", testTPPSPaidInvoiceReportFilePath), zap.Error(err))
}

testTPPSPaidInvoiceData := `
1077-4079-3 2024-08-05 2024-08-05 421.87 DUPK DUPK 10340 0.0311 321.57 1077-4079-cabd6371 2
1077-4079-3 2024-08-05 2024-08-05 421.87 DDP DDP 10340 0.0097 100.3 1077-4079-a4e717fd 1
1208-5962-1 2024-08-05 2024-08-05 557 MS MS 1 557 557 1208-5962-e0fb5863 1
8801-2773-2 2024-08-05 2024-08-05 2748.04 DOP DOP 1 77.02 77.02 8801-2773-f2bb471e 1
8801-2773-2 2024-08-05 2024-08-05 2748.04 DPK DPK 1 2671.02 2671.02 8801-2773-fdaee177 2
8801-2773-3 2024-08-05 2024-08-05 1397.74 DDP DDP 1 91.31 91.31 8801-2773-2e54e07d 2
8801-2773-3 2024-08-05 2024-08-05 1397.74 DLH DLH 1 1052.84 1052.84 8801-2773-27961d7f 1
8801-2773-3 2024-08-05 2024-08-05 1397.74 FSC FSC 1 6.66 6.66 8801-2773-f9e0672c 3
8801-2773-3 2024-08-05 2024-08-05 1397.74 DUPK DUPK 1 246.93 246.93 8801-2773-c6c78cf9 4

`

appCtx.Logger().Info("The tpps_paid_invoice_reports table should now have the following data: ")
appCtx.Logger().Info(testTPPSPaidInvoiceData)
}
2 changes: 2 additions & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@
20240731125005_retroactively_update_approve_at_column_based_on_available_to_prime.up.sql
20240801135811_create_mobile_home.up.sql
20240801135833_alter_mto_shipment_type_motorhome.up.sql
20240802161708_tpps_paid_invoice_table.up.sql
20240806151051_update_pws_violations.up.sql
20240807140736_add_locked_price_cents_to_mto_service_items.up.sql
20240807212737_add_counseling_transportation_office_id_to_moves.up.sql
Expand All @@ -984,6 +985,7 @@
20240814144527_remove_allow_pptas_client.up.sql
20240815144613_remove_sit_address_updates_table.up.sql
20240815182944_add_super_column_to_admin_users.up.sql
20240815195730_add_fk_to_tpps_paid_invoice_reports.up.sql
20240816200315_update_pws_violations_pt2.up.sql
20240819164156_update_pws_violations_pt3.up.sql
20240820125856_allow_pptas_migration.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
CREATE TABLE IF NOT EXISTS tpps_paid_invoice_reports (
id uuid NOT NULL,
invoice_number varchar NOT NULL,
tpps_created_doc_date timestamp,
seller_paid_date timestamp NOT NULL,
invoice_total_charges_in_millicents integer NOT NULL,
line_description varchar NOT NULL,
product_description varchar NOT NULL,
line_billing_units integer NOT NULL,
line_unit_price_in_millicents integer NOT NULL,
line_net_charge_in_millicents integer NOT NULL,
po_tcn varchar NOT NULL,
line_number varchar NOT NULL,
first_note_code varchar,
first_note_description varchar,
first_note_to varchar,
first_note_message varchar,
second_note_code varchar,
second_note_description varchar,
second_note_to varchar,
second_note_message varchar,
third_note_code varchar,
third_note_code_description varchar,
third_note_code_to varchar,
third_note_code_message varchar,
created_at timestamp not null,
updated_at timestamp not null
);

COMMENT on COLUMN tpps_paid_invoice_reports.invoice_number IS 'Invoice number from the report that should match a payment_request_number';
COMMENT on COLUMN tpps_paid_invoice_reports.tpps_created_doc_date IS 'Date that TPPS created the invoice report';
COMMENT on COLUMN tpps_paid_invoice_reports.seller_paid_date IS 'Seller paid date';
COMMENT on COLUMN tpps_paid_invoice_reports.invoice_total_charges_in_millicents IS 'Total charges for the invoice represented in millicents';
COMMENT on COLUMN tpps_paid_invoice_reports.line_description IS 'Reservice code for the service item';
COMMENT on COLUMN tpps_paid_invoice_reports.product_description IS 'Reservice code for the service item';
COMMENT on COLUMN tpps_paid_invoice_reports.line_billing_units IS 'Line billing units';
COMMENT on COLUMN tpps_paid_invoice_reports.line_unit_price_in_millicents IS 'Unit price represented in millicents';
COMMENT on COLUMN tpps_paid_invoice_reports.line_net_charge_in_millicents IS 'Net charge represented in millicents';
COMMENT on COLUMN tpps_paid_invoice_reports.po_tcn IS 'PO/TCN';
COMMENT on COLUMN tpps_paid_invoice_reports.line_number IS 'Line number';
COMMENT on COLUMN tpps_paid_invoice_reports.first_note_code IS 'Code of the first note';
COMMENT on COLUMN tpps_paid_invoice_reports.first_note_description IS 'Description of the first note';
COMMENT on COLUMN tpps_paid_invoice_reports.first_note_to IS 'Note of the first note';
COMMENT on COLUMN tpps_paid_invoice_reports.first_note_message IS 'Message of the first note';
COMMENT on COLUMN tpps_paid_invoice_reports.second_note_code IS 'Code of the second note';
COMMENT on COLUMN tpps_paid_invoice_reports.second_note_description IS 'Description of the second note';
COMMENT on COLUMN tpps_paid_invoice_reports.second_note_to IS 'Note of the second note';
COMMENT on COLUMN tpps_paid_invoice_reports.second_note_message IS 'Message of the second note';
COMMENT on COLUMN tpps_paid_invoice_reports.third_note_code IS 'Code of the third note';
COMMENT on COLUMN tpps_paid_invoice_reports.third_note_code_description IS 'Description of the third note';
COMMENT on COLUMN tpps_paid_invoice_reports.third_note_code_to IS 'Note of the third note';
COMMENT on COLUMN tpps_paid_invoice_reports.third_note_code_message IS 'Message of the third note';

COMMENT ON TABLE tpps_paid_invoice_reports IS 'Contains data populated from processing the TPPS paid invoice report';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE tpps_paid_invoice_reports
ADD CONSTRAINT tpps_paid_invoice_reports_invoice_number_fkey
FOREIGN KEY (invoice_number)
REFERENCES payment_requests(payment_request_number)
ON DELETE CASCADE;
10 changes: 10 additions & 0 deletions pkg/cli/gex_sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ const (
GEXSFTP824PickupDirectory string = "gex-sftp-824-pickup-directory"
)

// Pending completion of B-20560, uncomment the code below
/*
// Set of flags used for SFTPTPPSPaid
const (
// SFTPTPPSPaidInvoiceReportPickupDirectory is the ENV var for the directory where TPPS delivers the TPPS paid invoice report
SFTPTPPSPaidInvoiceReportPickupDirectory string = "pending" // pending completion of B-20560
)
*/

// InitGEXSFTPFlags initializes GEX SFTP command line flags
func InitGEXSFTPFlags(flag *pflag.FlagSet) {
flag.Int(GEXSFTPPortFlag, 22, "GEX SFTP Port")
Expand All @@ -51,6 +60,7 @@ func InitGEXSFTPFlags(flag *pflag.FlagSet) {
flag.String(GEXSFTPHostKeyFlag, "", "GEX SFTP Host Key")
flag.String(GEXSFTP997PickupDirectory, "", "GEX 997 SFTP Pickup Directory")
flag.String(GEXSFTP824PickupDirectory, "", "GEX 834 SFTP Pickup Directory")
// flag.String(SFTPTPPSPaidInvoiceReportPickupDirectory, "", "TPPS Paid Invoice SFTP Pickup Directory") // pending completion of B-20560
}

// CheckGEXSFTP validates GEX SFTP command line flags
Expand Down
Loading
Loading