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
bc5282fe
Commit
bc5282fe
authored
7 months ago
by
Jordi Isidro Llobet
Browse files
Options
Downloads
Patches
Plain Diff
no generar factures duplicades
parent
43c933a2
Branches
main
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
+14
-8
14 additions, 8 deletions
app/models.py
with
14 additions
and
8 deletions
app/models.py
+
14
−
8
View file @
bc5282fe
...
@@ -6,7 +6,6 @@ import requests
...
@@ -6,7 +6,6 @@ import requests
from
pandas
import
DataFrame
from
pandas
import
DataFrame
import
json
import
json
import
time
import
time
import
aiohttp
from
.database
import
Base
from
.database
import
Base
...
@@ -48,7 +47,7 @@ class ApiUser(Base):
...
@@ -48,7 +47,7 @@ class ApiUser(Base):
def
get_invoice_oc
(
con
,
id_billing_run
,
group_code
):
def
get_invoice_oc
(
con
,
id_billing_run
,
group_code
):
stm_group_code
=
""
if
group_code
is
None
else
"
and ocg.code=
'"
+
group_code
+
"'
"
stm_group_code
=
""
if
group_code
is
None
else
"
and ocg.code=
'"
+
group_code
+
"'
"
# factures a generar mirant que no estiguin ja generades.
statement
=
"""
statement
=
"""
select oi.description_cat, oi.code
select oi.description_cat, oi.code
, round(sum(oi.amount_without_tax),2) as preu
, round(sum(oi.amount_without_tax),2) as preu
...
@@ -63,7 +62,17 @@ def get_invoice_oc(con, id_billing_run, group_code):
...
@@ -63,7 +62,17 @@ def get_invoice_oc(con, id_billing_run, group_code):
where 1=1
where 1=1
and id_billing_run=
'"""
+
id_billing_run
+
"'
"
+
\
and id_billing_run=
'"""
+
id_billing_run
+
"'
"
+
\
stm_group_code
+
\
stm_group_code
+
\
"""
group by oi.description_cat, oi.code, oi.tax_percent , oi.billing_run_uuid, ocg.code
"""
and not exists
(
select *
from odoo_account_invoice ai
join odoo_contract_group cg on ai.contract_group_id =cg.id
where ocg.code = cg.code
and ai.billing_run_id = oi.id_billing_run::varchar
and ai.state<>
'
cancel
'
)
group by oi.description_cat, oi.code, oi.tax_percent , oi.billing_run_uuid, ocg.code
, oi.tax_code, oi.billing_account_code
, oi.tax_code, oi.billing_account_code
having sum(oi.amount_without_tax)<>0
"""
having sum(oi.amount_without_tax)<>0
"""
...
@@ -83,8 +92,6 @@ def get_invoice_oc(con, id_billing_run, group_code):
...
@@ -83,8 +92,6 @@ def get_invoice_oc(con, id_billing_run, group_code):
"
Content-Type
"
:
"
application/json
"
,
"
Content-Type
"
:
"
application/json
"
,
"
api-key
"
:
APIKEY
"
api-key
"
:
APIKEY
}
}
session
=
aiohttp
.
ClientSession
()
for
x
in
group
:
for
x
in
group
:
d
=
datetime
.
today
()
# datetime.today().strftime('%Y-%m-%d')
d
=
datetime
.
today
()
# datetime.today().strftime('%Y-%m-%d')
data
=
{
data
=
{
...
@@ -107,12 +114,11 @@ def get_invoice_oc(con, id_billing_run, group_code):
...
@@ -107,12 +114,11 @@ def get_invoice_oc(con, id_billing_run, group_code):
}
}
data
[
"
invoiceLines
"
].
append
(
invoiceline
)
data
[
"
invoiceLines
"
].
append
(
invoiceline
)
# print(data)
# print(data)
# r = requests.post(url=API_ENDPOINT, data=json.dumps(data), headers=head)
requests
.
post
(
url
=
API_ENDPOINT
,
data
=
json
.
dumps
(
data
),
headers
=
head
)
session
.
post
(
url
=
API_ENDPOINT
,
data
=
json
.
dumps
(
data
),
headers
=
head
)
session
.
detach
()
return
'
OK
'
#[dict(zip(columns, t)) for t in registries]
return
'
OK
'
#[dict(zip(columns, t)) for t in registries]
def
invoice_generate_oc_pdf
(
con
,
invoice
):
def
invoice_generate_oc_pdf
(
con
,
invoice
):
qry
=
"
insert into external.invoice_generator (id, name_invoice, status, dt_insert, dt_update) values (nextval(
'
external.seq_invoice_generator
'
),
'
{}
'
,
'
inici
'
, current_timestamp, current_timestamp)
"
.
format
(
invoice
)
qry
=
"
insert into external.invoice_generator (id, name_invoice, status, dt_insert, dt_update) values (nextval(
'
external.seq_invoice_generator
'
),
'
{}
'
,
'
inici
'
, current_timestamp, current_timestamp)
"
.
format
(
invoice
)
con
.
execute
(
qry
)
con
.
execute
(
qry
)
...
...
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