From 8a8492d0281a1b8e63c2b1c5ce809f3400d0f964 Mon Sep 17 00:00:00 2001 From: loganwc Date: Tue, 17 Dec 2024 20:39:30 +0000 Subject: [PATCH] added check before TAC query --- .../pptas_report/pptas_report_list_fetcher.go | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/pkg/services/pptas_report/pptas_report_list_fetcher.go b/pkg/services/pptas_report/pptas_report_list_fetcher.go index ff32e32186c..0e0ab435c2f 100644 --- a/pkg/services/pptas_report/pptas_report_list_fetcher.go +++ b/pkg/services/pptas_report/pptas_report_list_fetcher.go @@ -513,31 +513,33 @@ func buildServiceItemCrate(serviceItem models.MTOServiceItem) pptasmessages.Crat // inputs all TAC related fields and builds full line of accounting string func inputReportTAC(report *models.PPTASReport, pptasShipment *pptasmessages.PPTASShipment, orders models.Order, appCtx appcontext.AppContext, tacFetcher services.TransportationAccountingCodeFetcher, loa services.LineOfAccountingFetcher) error { - tac, err := tacFetcher.FetchOrderTransportationAccountingCodes(models.DepartmentIndicator(*orders.DepartmentIndicator), orders.IssueDate, *orders.TAC, appCtx) - if err != nil { - return err - } else if len(tac) < 1 { - return nil - } - - if tac[0].LineOfAccounting != nil { - longLoa := loa.BuildFullLineOfAccountingString(*tac[0].LineOfAccounting) - - pptasShipment.Loa = &longLoa - pptasShipment.FiscalYear = tac[0].TacFyTxt - pptasShipment.Appro = tac[0].LineOfAccounting.LoaBafID - pptasShipment.Subhead = tac[0].LineOfAccounting.LoaTrsySfxTx - pptasShipment.ObjClass = tac[0].LineOfAccounting.LoaObjClsID - pptasShipment.Bcn = tac[0].LineOfAccounting.LoaAlltSnID - pptasShipment.SubAllotCD = tac[0].LineOfAccounting.LoaSbaltmtRcpntID - pptasShipment.Aaa = tac[0].LineOfAccounting.LoaTrnsnID - pptasShipment.TypeCD = tac[0].LineOfAccounting.LoaJbOrdNm - pptasShipment.Paa = tac[0].LineOfAccounting.LoaInstlAcntgActID - pptasShipment.CostCD = tac[0].LineOfAccounting.LoaPgmElmntID - pptasShipment.Ddcd = tac[0].LineOfAccounting.LoaDptID - - if report.OrderNumber == nil { - report.OrderNumber = tac[0].LineOfAccounting.LoaDocID + if orders.DepartmentIndicator != nil && orders.TAC != nil && !orders.IssueDate.IsZero() { + tac, err := tacFetcher.FetchOrderTransportationAccountingCodes(models.DepartmentIndicator(*orders.DepartmentIndicator), orders.IssueDate, *orders.TAC, appCtx) + if err != nil { + return err + } else if len(tac) < 1 { + return nil + } + + if tac[0].LineOfAccounting != nil { + longLoa := loa.BuildFullLineOfAccountingString(*tac[0].LineOfAccounting) + + pptasShipment.Loa = &longLoa + pptasShipment.FiscalYear = tac[0].TacFyTxt + pptasShipment.Appro = tac[0].LineOfAccounting.LoaBafID + pptasShipment.Subhead = tac[0].LineOfAccounting.LoaTrsySfxTx + pptasShipment.ObjClass = tac[0].LineOfAccounting.LoaObjClsID + pptasShipment.Bcn = tac[0].LineOfAccounting.LoaAlltSnID + pptasShipment.SubAllotCD = tac[0].LineOfAccounting.LoaSbaltmtRcpntID + pptasShipment.Aaa = tac[0].LineOfAccounting.LoaTrnsnID + pptasShipment.TypeCD = tac[0].LineOfAccounting.LoaJbOrdNm + pptasShipment.Paa = tac[0].LineOfAccounting.LoaInstlAcntgActID + pptasShipment.CostCD = tac[0].LineOfAccounting.LoaPgmElmntID + pptasShipment.Ddcd = tac[0].LineOfAccounting.LoaDptID + + if report.OrderNumber == nil { + report.OrderNumber = tac[0].LineOfAccounting.LoaDocID + } } }