Skip to content
Snippets Groups Projects
Commit adc7af8a authored by Jordi Isidro Llobet's avatar Jordi Isidro Llobet
Browse files

accountingCode

parent 63b5018c
No related branches found
No related tags found
No related merge requests found
...@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment