Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nigel Kukard
wiaflos
Commits
39c7e15e
Commit
39c7e15e
authored
Jul 14, 2019
by
Nigel Kukard
Browse files
Fix up invoice title, number and document ID
parent
99ab5af5
Pipeline
#4101
passed with stages
in 2 minutes and 41 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
wiaflos/server/core/Invoicing.pm
View file @
39c7e15e
...
...
@@ -1181,12 +1181,22 @@ sub sendInvoice
# If no accounts address, use general address
$billEmailAddr
=
@billEmailAddrs
>
0
?
join
('
,
',
@billEmailAddrs
)
:
join
('
,
',
@genEmailAddrs
);
# Massage the data a bit
my
$invoiceTitle
;
my
$invoiceNumber
=
$invoice
->
{'
Number
'};
if
(
$proforma
eq
"
yes
")
{
$invoiceTitle
=
"
Proforma Invoice
";
$invoiceNumber
=~
s/^INV/PRF/
;
}
else
{
$invoiceTitle
=
"
Tax Invoice Copy
"
}
# Build array of stuff we can use
my
$vars
=
{
'
WiaflosString
'
=>
$GENSTRING
,
# Document type
'
Title
'
=>
$proforma
eq
"
yes
"
?
"
PROFORMA INVOICE
"
:
"
TAX INVOICE COPY
"
,
'
Title
'
=>
uc
(
$invoiceTitle
)
,
# Client
'
ClientName
'
=>
$client
->
{'
Name
'},
...
...
@@ -1197,7 +1207,7 @@ sub sendInvoice
# Invoice
'
ClientTaxReference
'
=>
defined
(
$invoice
->
{'
TaxReference
'})
?
$invoice
->
{'
TaxReference
'}
:
"",
'
InvoiceNumber
'
=>
$invoice
->
{'
Number
'}
,
'
InvoiceNumber
'
=>
$invoiceNumber
,
'
InvoiceOrderNumber
'
=>
defined
(
$invoice
->
{'
OrderNumber
'})
?
$invoice
->
{'
OrderNumber
'}
:
"",
'
InvoiceIssueDate
'
=>
$invoice
->
{'
IssueDate
'},
'
InvoiceDueDate
'
=>
$invoice
->
{'
DueDate
'},
...
...
@@ -1231,7 +1241,7 @@ sub sendInvoice
my
$tempDir
=
File::
Temp
->
newdir
();
# Invoice filename
my
$invoiceFilename
=
sprintf
('
%s.%s
',
$invoice
->
{'
Number
'}
,
$format
);
my
$invoiceFilename
=
sprintf
('
%s.%s
',
$invoiceNumber
,
$format
);
$invoiceFilename
=~
s,/,-,g
;
# Path of the invoice file we're generating
my
$invoicePath
=
sprintf
('
%s/%s
',
$tempDir
,
$invoiceFilename
);
...
...
@@ -1242,6 +1252,10 @@ sub sendInvoice
#
# Generate invoice
#
#
# Work out the DOC_ID
my
$documentID
=
sprintf
('
%s - %s - %s
',
$client
->
{'
Name
'},
$client
->
{'
Code
'},
$invoiceNumber
);
$vars
->
{'
DocumentID
'}
=
$documentID
;
# Load template
my
$res
=
loadTemplate2
(
$template
,
$vars
,
$invoicePath
,
$format
);
...
...
wiaflos/server/core/templating.pm
View file @
39c7e15e
...
...
@@ -115,13 +115,13 @@ sub loadTemplate2
setError
("
Unsupported format '
$format
'
");
return
;
}
# Make sure this is for pdf...
if
(
!
$SUPPORTS_PDF
)
{
setError
("
AWIT-Docplates couldn't be loaded
");
return
;
}
# Create our docplate object
my
$docplate
=
AWIT::
Docplate
->
new
();
# Loop with each of them
...
...
@@ -147,11 +147,8 @@ sub loadTemplate2
$docplate
->
addPreProcessTemplate
("
bits/start.tt2
");
$docplate
->
addPostProcessTemplate
("
bits/end.tt2
");
# Work out the DOC_ID
my
$docid
=
sprintf
('
%s - Account %s - Invoice %s
',
$vars
->
{'
ClientName
'},
$vars
->
{'
ClientCode
'},
$vars
->
{'
InvoiceNumber
'});
# Process template
if
(
!
$docplate
->
process
(
$templateName
,{'
DOC_ID
'
=>
$
docid
},
$texFile
))
{
if
(
!
$docplate
->
process
(
$templateName
,{'
DOC_ID
'
=>
$
vars
->
{'
DocumentID
'}
},
$texFile
))
{
setError
(
$docplate
->
error
);
return
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment