Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
cooperatic-foodcoops
third-party
Commits
b67393d3
Commit
b67393d3
authored
Feb 02, 2022
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ticket 1933 : In sales extraction, distingue Memmber and Associated People
parent
82ff458b
Pipeline
#1741
passed with stage
in 1 minute 39 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
models.py
sales/models.py
+15
-15
sales.js
sales/static/js/sales.js
+2
-5
No files found.
sales/models.py
View file @
b67393d3
...
@@ -14,28 +14,28 @@ class CagetteSales(models.Model):
...
@@ -14,28 +14,28 @@ class CagetteSales(models.Model):
def
get_sales
(
self
,
date_from
,
date_to
):
def
get_sales
(
self
,
date_from
,
date_to
):
res
=
[]
res
=
[]
# Get pos sessions
# Get pos orders
cond
=
[[
'stop_at'
,
'>='
,
date_from
],
[
'stop_at'
,
'<='
,
date_to
],
[
'state'
,
'='
,
"closed"
]]
cond
=
[[
'date_order'
,
'>='
,
date_from
],
[
'date_order'
,
'<='
,
date_to
]]
fields
=
[]
fields
=
[
'partner_id'
,
'statement_ids'
]
sessions
=
self
.
o_api
.
search_read
(
'pos.session'
,
cond
,
fields
)
orders
=
self
.
o_api
.
search_read
(
'pos.order'
,
cond
,
fields
)
# Get bank statements of these sessions
# Get bank statements of these sessions
statements
=
[]
statements
=
[]
for
s
in
sessions
:
statements_partners
=
{}
statements
=
statements
+
s
[
"statement_ids"
]
for
o
in
orders
:
statements
=
statements
+
o
[
"statement_ids"
]
for
s
in
o
[
"statement_ids"
]:
statements_partners
[
s
]
=
o
[
"partner_id"
][
1
]
# Get payment lines
# Get payment lines
cond
=
[[
'
statement_
id'
,
'in'
,
statements
]]
cond
=
[[
'id'
,
'in'
,
statements
]]
fields
=
[
"
partner_id"
,
"
amount"
,
"journal_id"
,
"create_date"
,
"date"
]
fields
=
[
"amount"
,
"journal_id"
,
"create_date"
,
"date"
]
payments
=
self
.
o_api
.
search_read
(
'account.bank.statement.line'
,
cond
,
fields
,
order
=
"create_date ASC"
,
limit
=
50000
)
payments
=
self
.
o_api
.
search_read
(
'account.bank.statement.line'
,
cond
,
fields
,
order
=
"create_date ASC"
,
limit
=
50000
)
item
=
None
item
=
None
try
:
try
:
for
payment
in
payments
:
for
payment
in
payments
:
# POS session can contain payments from another day (closing session on next morning, ...)
# POS session can contain payments from another day (closing session on next morning, ...)
if
payment
[
"date"
]
>=
date_from
and
payment
[
"date"
]
<=
date_to
:
if
payment
[
"date"
]
>=
date_from
and
payment
[
"date"
]
<=
date_to
:
# If the consecutive payment in the results is from the same partner on the same day, we consider it's the same basket
# If the consecutive payment in the results is from the same partner on the same day, we consider it's the same basket
if
item
is
not
None
and
item
[
"partner
_id"
][
0
]
==
payment
[
"partner_id"
][
0
]
and
item
[
"date"
]
==
payment
[
"date"
]:
if
item
is
not
None
and
item
[
"partner
"
]
==
statements_partners
[
payment
[
"id"
]
]
and
item
[
"date"
]
==
payment
[
"date"
]:
res
[
len
(
res
)
-
1
][
"total_amount"
]
+=
round
(
float
(
payment
[
"amount"
]),
2
)
res
[
len
(
res
)
-
1
][
"total_amount"
]
+=
round
(
float
(
payment
[
"amount"
]),
2
)
res
[
len
(
res
)
-
1
][
"payments"
]
.
append
({
res
[
len
(
res
)
-
1
][
"payments"
]
.
append
({
"amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
...
@@ -43,7 +43,7 @@ class CagetteSales(models.Model):
...
@@ -43,7 +43,7 @@ class CagetteSales(models.Model):
})
})
else
:
else
:
item
=
{
item
=
{
"partner
_id"
:
payment
[
"partner_id"
],
"partner
"
:
statements_partners
[
payment
[
"id"
]
],
"create_date"
:
payment
[
"create_date"
],
"create_date"
:
payment
[
"create_date"
],
"date"
:
payment
[
"date"
],
"date"
:
payment
[
"date"
],
"total_amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"total_amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
...
@@ -51,12 +51,12 @@ class CagetteSales(models.Model):
...
@@ -51,12 +51,12 @@ class CagetteSales(models.Model):
{
{
"amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"journal_id"
:
payment
[
"journal_id"
]
"journal_id"
:
payment
[
"journal_id"
]
}
}
]
]
}
}
res
.
append
(
item
)
res
.
append
(
item
)
except
Exception
as
e
:
except
Exception
as
e
:
pass
coop_logger
.
error
(
"get_sales
%
s"
,
str
(
e
))
return
res
return
res
sales/static/js/sales.js
View file @
b67393d3
...
@@ -42,12 +42,9 @@ function display_orders(orders) {
...
@@ -42,12 +42,9 @@ function display_orders(orders) {
width
:
"10%"
width
:
"10%"
},
},
{
{
data
:
"partner
_id
"
,
data
:
"partner"
,
title
:
"Membre"
,
title
:
"Membre"
,
width
:
"50%"
,
width
:
"50%"
render
:
function
(
data
)
{
return
data
[
1
];
}
},
},
{
{
data
:
"total_amount"
,
data
:
"total_amount"
,
...
...
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