Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-ubl
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-ubl
Commits
c74ed1f0
Commit
c74ed1f0
authored
Nov 18, 2007
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- renames the actual conversion file
parent
303ccf66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
85 deletions
+120
-85
document.xml.tcl
www/document.xml.tcl
+120
-9
invoice.xml-postgresql.xql
www/invoice.xml-postgresql.xql
+0
-76
No files found.
www/
invoice
.xml.tcl
→
www/
document
.xml.tcl
View file @
c74ed1f0
...
...
@@ -24,6 +24,26 @@ ad_page_contract {
set
user_id
[
ad_maybe_redirect_for_registration
]
set
today
[
db_string today
"select to_char(now(), 'YYYY-MM-DD')"
]
set
invoice_url
"/intranet-invoices/view?invoice_id=
$invoice
_id"
# rounding precision can be between 2 (USD,EUR, ...
)
# and -5 (Old Turkish Lira, ...
)
.
set
rounding_precision 2
set
required_field
"<font color=red size=+1><B>*</B></font>"
set
rounding_factor
[
expr
exp
(
log
(
10
)
*
$rounding
_precision
)]
set
rf
$rounding
_factor
# Locale
set
locale
"en_US"
# set locale [lang::user::locale
]
set
cur_format
[
im_l10n_sql_currency_format
]
set
vat_format
$cur
_format
set
tax_format
$cur
_format
# ---------------------------------------------------------------
# Get information about the financial document ("invoice"
)
...
...
@@ -32,7 +52,7 @@ set today [db_string today "select to_char(now(), 'YYYY-MM-DD')"]
if
{
!
[
db_0or1row project_info
"
select c.*,
i.*,
o.creation_date as issue_date
,
to_char(o.creation_date, 'YYYY-MM-DD') as issue_date_pretty
,
cust.company_name as customer_name,
ocust.address_line1 as customer_address_line1,
...
...
@@ -56,7 +76,6 @@ if {![db_0or1row project_info "
prov_contact.work_phone as provider_contact_work_phone,
paymeth.category_description as payment_method_desc
from
im_costs c,
im_invoices i
...
...
@@ -83,7 +102,28 @@ if {![db_0or1row project_info "
return
}
set
invoice_url
"/intranet-invoices/view?invoice_id=
$invoice
_id"
# Calculate grand total based on the same inner SQL
db_1row calc_grand_total
""
set
subtotal_pretty
[
lc_numeric
[
im_numeric_add_trailing_zeros
[
expr
$subtotal
+0
]
$rounding
_precision
]
""
$locale
]
set
vat_amount_pretty
[
lc_numeric
[
im_numeric_add_trailing_zeros
[
expr
$vat
_amount+0
]
$rounding
_precision
]
""
$locale
]
set
tax_amount_pretty
[
lc_numeric
[
im_numeric_add_trailing_zeros
[
expr
$tax
_amount+0
]
$rounding
_precision
]
""
$locale
]
set
grand_total_pretty
[
lc_numeric
[
im_numeric_add_trailing_zeros
[
expr
$grand
_total+0
]
$rounding
_precision
]
""
$locale
]
set
total_due_pretty
[
lc_numeric
[
im_numeric_add_trailing_zeros
[
expr
$total
_due+0
]
$rounding
_precision
]
""
$locale
]
set
discount_perc_pretty
$discount
_perc
set
surcharge_perc_pretty
$surcharge
_perc
# Get the right outer tag name, depending on the document type
set
document_type
"error"
switch
$cost
_type_id
{
3700
{
set document_type
"Invoice"
}
3702
{
set document_type
"Quote"
}
3704
{
set document_type
"Invoice"
}
3706
{
set document_type
"Order"
}
3724
{
set document_type
"DelNote"
}
}
# ---------------------------------------------------------------
...
...
@@ -98,7 +138,7 @@ set view_index 0
# ---------------------------------------------------------------
# Main Document Node
set
doc
[
dom createDocument
invoic
e
]
set
doc
[
dom createDocument
$document
_typ
e
]
set
main_node
[
$doc
documentElement
]
$main
_node setAttribute xmlns:cbc
"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-1.0"
...
...
@@ -110,15 +150,15 @@ $main_node setAttribute xsi:schemaLocation "urn:oasis:names:specification:ubl:sc
$main
_node appendXML
"<ID>
$cost
_
id
</ID>"
$main
_node appendXML
"<cbc:IssueDate>
$issue
_date</cbc:IssueDate>"
$main
_node appendXML
"<TaxPointDate>
$issue
_date</TaxPointDate>"
$main
_node appendXML
"<ID>
$cost
_
name
</ID>"
$main
_node appendXML
"<cbc:IssueDate>
$issue
_date
_pretty
</cbc:IssueDate>"
$main
_node appendXML
"<TaxPointDate>
$issue
_date
_pretty
</TaxPointDate>"
$main
_node appendXML
"
<cac:OrderReference>
<cac:BuyersID>
$customer
_id</cac:BuyersID>
<cac:SellersID>
$provider
_id</cac:SellersID>
<cbc:IssueDate>
$issue
_date</cbc:IssueDate>
<cbc:IssueDate>
$issue
_date
_pretty
</cbc:IssueDate>
</cac:OrderReference>"
$main
_node appendXML
"
...
...
@@ -168,6 +208,77 @@ $main_node appendXML "
</cac:PaymentTerms>
"
ns_return 200 text/xxx
[
$doc
asXML -indent 2 -escapeNonASCII
]
$main
_node appendXML
"
<cac:TaxTotal>
<cbc:TotalTaxAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
$vat
_amount_pretty</cbc:TotalTaxAmount>
<cac:TaxSubTotal>
<cbc:TaxableAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
$amount
</cbc:TaxableAmount>
<cbc:TaxAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
$vat
_amount_pretty</cbc:TaxAmount>
<cac:TaxCategory>
<cac:ID>STD</cac:ID>
<cbc:Percent>
$vat
</cbc:Percent>
<cac:TaxScheme>
<cac:TaxTypeCode>VAT</cac:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubTotal>
</cac:TaxTotal>
"
$main
_node appendXML
"
<cac:LegalTotal>
<cbc:LineExtensionTotalAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
$subtotal
_pretty</cbc:LineExtensionTotalAmount>
<cbc:TaxExclusiveTotalAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
$subtotal
_pretty</cbc:TaxExclusiveTotalAmount>
<cbc:TaxInclusiveTotalAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
$grand
_total_pretty</cbc:TaxInclusiveTotalAmount>
</cac:LegalTotal>
"
set
ctr 1
db_foreach invoice_items
{}
{
set amount_pretty
[
lc_numeric
[
im_numeric_add_trailing_zeros
[
expr
$amount
+0
]
$rounding
_precision
]
""
$locale
]
set item_units_pretty
[
lc_numeric
[
expr
$item
_units+0
]
""
$locale
]
set price_per_unit_pretty
[
lc_numeric
[
im_numeric_add_trailing_zeros
[
expr
$price
_per_unit+0
]
$rounding
_precision
]
""
$locale
]
$main
_node appendXML
"
<cac:
${document_type}
Line>
<cac:ID>
$ctr
</cac:ID>
<cbc:InvoicedQuantity quantityUnitCode=
\"
$item
_uom
\"
>
$item
_units_pretty</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
[
string
trim
$amount
_pretty
]
</cbc:LineExtensionAmount>
<cac:OrderLineReference>
<cac:BuyersLineID>
$ctr
</cac:BuyersLineID>
</cac:OrderLineReference>
<cac:Item>
<cbc:Description>
$item
_name</cbc:Description>
<cac:BuyersItemIdentification>
<cac:ID>
$ctr
</cac:ID>
</cac:BuyersItemIdentification>
<cac:SellersItemIdentification>
<cac:ID>32145-12</cac:ID>
</cac:SellersItemIdentification>
<cac:BasePrice>
<cbc:PriceAmount amountCurrencyCodeListVersionID=
\"
0.3
\"
amountCurrencyID=
\"
$currency
\"
>
$price
_per_unit_pretty</cbc:PriceAmount>
</cac:BasePrice>
</cac:Item>
</cac:
${document_type}
Line>
"
incr ctr
}
ns_return 200 text/xxx
[
$doc
asXML -indent 2
]
# ns_return 200 text/xxx [$doc asXML -indent 2 -escapeNonASCII
]
www/invoice.xml-postgresql.xql
deleted
100644 → 0
View file @
303ccf66
<?xml version="1.0"?>
<!DOCTYPE queryset PUBLIC "-//OpenACS//DTD XQL 1.0//EN" "/usr/share/emacs/DTDs/xql.dtd">
<!-- packages/intranet-invoices/www/view-postgresql.xql -->
<!-- @author Juanjo Ruiz (juanjoruizx@yahoo.es) -->
<!-- @creation-date 2004-10-08 -->
<!-- @arch-tag ffe2b337-c79b-4b45-bfcb-41a371866d36 -->
<!-- @cvs-id $Id$ -->
<queryset>
<rdbms>
<type>
postgresql
</type>
<version>
7.2
</version>
</rdbms>
<fullquery
name =
"invoice_items"
>
<querytext>
select
i.*,
p.*,
im_category_from_id(i.item_type_id) as item_type,
im_category_from_id(i.item_uom_id) as item_uom,
p.project_nr as project_short_name,
round(i.price_per_unit * i.item_units * :rf) / :rf as amount,
to_char(round(i.price_per_unit * i.item_units * :rf) / :rf, :cur_format) as amount_formatted
from
im_invoice_items i
LEFT JOIN im_projects p on i.project_id=p.project_id
where
i.invoice_id=:invoice_id
order by
i.sort_order,
i.item_type_id;
</querytext>
</fullquery>
<fullquery
name =
"calc_grand_total"
>
<querytext>
select i.*,
round(i.grand_total * :vat / 100 * :rf) / :rf as vat_amount,
round(i.grand_total * :tax / 100 * :rf) / :rf as tax_amount,
i.grand_total
+ round(i.grand_total * :vat / 100 * :rf) / :rf
+ round(i.grand_total * :tax / 100 * :rf) / :rf
as total_due
from
(select
max(i.currency) as currency,
sum(i.amount) as subtotal,
round(sum(i.amount) * :surcharge_perc::numeric) / 100.0 as surcharge_amount,
round(sum(i.amount) * :discount_perc::numeric) / 100.0 as discount_amount,
sum(i.amount)
+ round(sum(i.amount) * :surcharge_perc::numeric) / 100.0
+ round(sum(i.amount) * :discount_perc::numeric) / 100.0
as grand_total
from
(select ii.*,
round(ii.price_per_unit * ii.item_units * :rf) / :rf as amount
from im_invoice_items ii,
im_invoices i
where i.invoice_id = ii.invoice_id
and i.invoice_id = :invoice_id
) i
) i
order by sort_order
</querytext>
</fullquery>
</queryset>
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