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
46d9ed42
Commit
46d9ed42
authored
Feb 02, 2022
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ticket #1890 : Change way of displaying members pos order payments
parent
b67393d3
Pipeline
#1742
passed with stage
in 1 minute 38 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
21 deletions
+16
-21
models.py
sales/models.py
+7
-18
sales.js
sales/static/js/sales.js
+9
-3
No files found.
sales/models.py
View file @
46d9ed42
...
...
@@ -16,36 +16,27 @@ class CagetteSales(models.Model):
# Get pos orders
cond
=
[[
'date_order'
,
'>='
,
date_from
],
[
'date_order'
,
'<='
,
date_to
]]
fields
=
[
'partner_id'
,
'statement_ids'
]
fields
=
[
'partner_id'
,
'statement_ids'
,
'name'
]
orders
=
self
.
o_api
.
search_read
(
'pos.order'
,
cond
,
fields
)
# Get bank statements of these sessions
statements
=
[]
statements_partners
=
{}
statements_orders
=
{}
for
o
in
orders
:
statements
=
statements
+
o
[
"statement_ids"
]
for
s
in
o
[
"statement_ids"
]:
statements_partners
[
s
]
=
o
[
"partner_id"
][
1
]
statements_orders
[
s
]
=
o
[
"name"
]
# Get payment lines
cond
=
[[
'id'
,
'in'
,
statements
]]
fields
=
[
"amount"
,
"journal_id"
,
"create_date"
,
"date"
]
fields
=
[
"amount"
,
"journal_id"
,
"create_date"
]
payments
=
self
.
o_api
.
search_read
(
'account.bank.statement.line'
,
cond
,
fields
,
order
=
"create_date ASC"
,
limit
=
50000
)
item
=
None
try
:
for
payment
in
payments
:
# POS session can contain payments from another day (closing session on next morning, ...)
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
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
][
"payments"
]
.
append
({
"amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"journal_id"
:
payment
[
"journal_id"
]
})
else
:
item
=
{
res
.
append
({
"partner"
:
statements_partners
[
payment
[
"id"
]],
"create_date"
:
payment
[
"create_date"
],
"
date"
:
payment
[
"date"
],
"
pos_order_name"
:
statements_orders
[
payment
[
"id"
]
],
"total_amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"payments"
:
[
{
...
...
@@ -53,9 +44,7 @@ class CagetteSales(models.Model):
"journal_id"
:
payment
[
"journal_id"
]
}
]
}
res
.
append
(
item
)
})
except
Exception
as
e
:
coop_logger
.
error
(
"get_sales
%
s"
,
str
(
e
))
...
...
sales/static/js/sales.js
View file @
46d9ed42
...
...
@@ -38,17 +38,23 @@ function display_orders(orders) {
columns
:[
{
data
:
"create_date"
,
title
:
"Date
de vente
"
,
title
:
"Date
enregistrement
"
,
width
:
"10%"
},
{
data
:
"pos_order_name"
,
title
:
"Ref. Caisse"
,
width
:
"10%"
},
{
data
:
"partner"
,
title
:
"Membre"
,
width
:
"
5
0%"
width
:
"
4
0%"
},
{
data
:
"total_amount"
,
title
:
"Montant d
u panier
"
,
title
:
"Montant d
û
"
,
className
:
"dt-body-center"
,
render
:
function
(
data
)
{
return
parseFloat
(
data
).
toFixed
(
2
)
+
' €'
;
...
...
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