Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BI Som Connexio Api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Business Intelligence
Som Connexió
BI Som Connexio Api
Commits
adc7af8a
Commit
adc7af8a
authored
1 year ago
by
Jordi Isidro Llobet
Browse files
Options
Downloads
Patches
Plain Diff
accountingCode
parent
63b5018c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models.py
+7
-3
7 additions, 3 deletions
app/models.py
with
7 additions
and
3 deletions
app/models.py
+
7
−
3
View file @
adc7af8a
...
@@ -52,12 +52,14 @@ def get_invoice_oc(con, billing_run_uuid):
...
@@ -52,12 +52,14 @@ def get_invoice_oc(con, billing_run_uuid):
,sum(oi.amount_tax) as amount_tax
,sum(oi.amount_tax) as amount_tax
,sum(oi.amount_with_tax) as amount_with_tax
,sum(oi.amount_with_tax) as amount_with_tax
, oi.tax_percent, ocg.code as group_code, oi.tax_code
, oi.tax_percent, ocg.code as group_code, oi.tax_code
, oi.billing_account_code
from external.opencell_invoices oi
from external.opencell_invoices oi
join odoo_contract_contract occ on oi.odoo_code = occ.code
join odoo_contract_contract occ on oi.odoo_code = occ.code
join odoo_contract_group ocg on occ.contract_group_id = ocg.id
join odoo_contract_group ocg on occ.contract_group_id = ocg.id
where 1=1
where 1=1
and billing_run_uuid=
'"""
+
billing_run_uuid
+
"'
"
+
\
and billing_run_uuid=
'"""
+
billing_run_uuid
+
"'
"
+
\
"""
group by oi.description_cat, oi.code, oi.tax_percent , oi.billing_run_uuid, ocg.code, oi.tax_code
"""
group by oi.description_cat, oi.code, oi.tax_percent , oi.billing_run_uuid, ocg.code
, oi.tax_code, oi.billing_account_code
having sum(oi.amount_without_tax)<>0
"""
having sum(oi.amount_without_tax)<>0
"""
# statement = """
# statement = """
...
@@ -74,7 +76,8 @@ def get_invoice_oc(con, billing_run_uuid):
...
@@ -74,7 +76,8 @@ def get_invoice_oc(con, billing_run_uuid):
# having sum(oi.amount_without_tax)<>0
# having sum(oi.amount_without_tax)<>0
# """
# """
columns
=
[
'
description_cat
'
,
'
code
'
,
'
preu
'
,
'
amount_tax
'
,
'
amount_with_tax
'
,
'
tax_percent
'
,
'
group_code
'
,
'
tax_code
'
]
columns
=
[
'
description_cat
'
,
'
code
'
,
'
preu
'
,
'
amount_tax
'
,
'
amount_with_tax
'
,
'
tax_percent
'
,
'
group_code
'
,
'
tax_code
'
,
'
billing_account_code
'
]
registries
=
con
.
execute
(
statement
)
registries
=
con
.
execute
(
statement
)
df
=
DataFrame
(
registries
.
fetchall
())
df
=
DataFrame
(
registries
.
fetchall
())
...
@@ -92,6 +95,7 @@ def get_invoice_oc(con, billing_run_uuid):
...
@@ -92,6 +95,7 @@ def get_invoice_oc(con, billing_run_uuid):
for
index
,
row
in
df2
.
iterrows
():
for
index
,
row
in
df2
.
iterrows
():
invoiceline
=
{
invoiceline
=
{
"
description
"
:
row
[
'
description_cat
'
],
"
description
"
:
row
[
'
description_cat
'
],
"
accountingCode
"
:
row
[
'
billing_account_code
'
],
"
amountWithoutTax
"
:
float
(
round
(
row
[
'
preu
'
],
2
)),
"
amountWithoutTax
"
:
float
(
round
(
row
[
'
preu
'
],
2
)),
"
amountWithTax
"
:
float
(
round
(
row
[
'
amount_with_tax
'
],
2
)),
"
amountWithTax
"
:
float
(
round
(
row
[
'
amount_with_tax
'
],
2
)),
"
amountTax
"
:
float
(
round
(
row
[
'
amount_tax
'
],
2
)),
"
amountTax
"
:
float
(
round
(
row
[
'
amount_tax
'
],
2
)),
...
@@ -101,7 +105,7 @@ def get_invoice_oc(con, billing_run_uuid):
...
@@ -101,7 +105,7 @@ def get_invoice_oc(con, billing_run_uuid):
data
[
"
invoiceLines
"
].
append
(
invoiceline
)
data
[
"
invoiceLines
"
].
append
(
invoiceline
)
print
(
data
)
print
(
data
)
APIKEY
=
os
.
environ
.
get
(
'
APIKEY
'
)
APIKEY
=
os
.
environ
.
get
(
'
APIKEY
'
)
# TODO
fer la crida a odoo per cada grup_code de billing_run_id
# TODO
variable d'endpoint
API_ENDPOINT
=
"
https://sc-preprod-odoo.coopdevs.org/api/invoice
"
API_ENDPOINT
=
"
https://sc-preprod-odoo.coopdevs.org/api/invoice
"
head
=
{
head
=
{
"
accept
"
:
"
application/json
"
,
"
accept
"
:
"
application/json
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment