diff --git a/app/stash-services.go b/app/stash-services.go index ddde321..cdecffa 100644 --- a/app/stash-services.go +++ b/app/stash-services.go @@ -7,28 +7,28 @@ import ( // StashPDFParams is a param type type StashPDFParams struct { - document *Document - account *Account - objectType string - principal *User + Document *Document + Account *Account + ObjectType string + Principal *User } // StashPDF stores a PDF in the stash database -func StashPDF(params StashPDFParams) (*Document, error) { +func StashPDF(params StashPDFParams, principal *User) (*Document, error) { sugar.Debugf("render.stashPDF: 📥") var title string var fileName string var description string var ref string - switch params.objectType { + switch params.ObjectType { case "account": - title = "Taxnexus Report for " + params.account.Name - fileName = "Taxnexus Report for " + params.account.Name + ".pdf" + title = "Taxnexus Report for " + params.Account.Name + fileName = "Taxnexus Report for " + params.Account.Name + ".pdf" description = "Account Report generated by render" ref = "render.getAccounts" case "tax_summary": - title = "Taxnexus Tax Report for " + params.account.Name - fileName = params.account.Name + " Tax Report.pdf" + title = "Taxnexus Tax Report for " + params.Account.Name + fileName = params.Account.Name + " Tax Report.pdf" description = "CDTFA Quarterly District Sales and Use Tax for " ref = "render.getTaxes" } @@ -39,16 +39,16 @@ func StashPDF(params StashPDFParams) (*Document, error) { { Description: description, Filename: fileName, - HTML: params.document.HTML, - ObjectType: params.document.SagaType, - OwnerID: "fabric", // todo #6 make OwnerID in new PDF real - ParentID: params.document.ParentID, + HTML: params.Document.HTML, + ObjectType: params.Document.SagaType, + OwnerID: principal.ID, + ParentID: params.Document.ParentID, Ref: ref, Title: title, }, }, } - response, err := stashClient.StashPdf.PostPdfs(stashParams, params.principal.Auth) + response, err := stashClient.StashPdf.PostPdfs(stashParams, params.Principal.Auth) if err != nil { sugar.Errorf("render.stashPDF: 💣 ⛔ post PDF to stash error %w", err) return nil, err @@ -60,10 +60,10 @@ func StashPDF(params StashPDFParams) (*Document, error) { sugar.Debugf("render.stashPDF: 👍 📤") return &Document{ ID: newObj.ID, - Filename: params.account.Name + fileName, - SagaType: params.document.SagaType, - ParentID: params.document.ParentID, - Title: title + params.account.Name, + Filename: params.Account.Name + fileName, + SagaType: params.Document.SagaType, + ParentID: params.Document.ParentID, + Title: title + params.Account.Name, URI: newObj.URI, }, nil }