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