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
83db0aad
Commit
83db0aad
authored
Feb 02, 2022
by
François C.
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_cooperatic' into '#1925-ACL-multiple-down-key-cause-error'
# Conflicts: # orders/static/js/orders_helper.js
parents
6065759d
46d9ed42
Pipeline
#1745
passed with stage
in 1 minute 37 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
55 deletions
+72
-55
orders_helper.js
orders/static/js/orders_helper.js
+17
-9
views.py
outils/views.py
+27
-10
models.py
sales/models.py
+18
-29
sales.js
sales/static/js/sales.js
+10
-7
No files found.
orders/static/js/orders_helper.js
View file @
83db0aad
...
...
@@ -705,6 +705,8 @@ function save_products_npa_minimal_stock(product, inputs) {
actions
.
minimal_stock
=
input
.
val
()
}
});
openModal
();
$
.
ajax
({
type
:
"POST"
,
url
:
"/products/update_npa_and_minimal_stock"
,
...
...
@@ -715,6 +717,20 @@ function save_products_npa_minimal_stock(product, inputs) {
success
:
()
=>
{
const
index
=
products
.
findIndex
(
p
=>
p
.
id
==
product
.
id
);
products
[
index
].
minimal_stock
=
actions
.
minimal_stock
;
if
(
actions
.
npa
.
length
>
0
)
{
// Remove NPA products
products
.
splice
(
index
,
1
);
update_main_screen
();
debounceFunction
(
update_cdb_order
);
}
check_products_data
()
.
then
(()
=>
{
update_cdb_order
();
update_main_screen
();
closeModal
();
// Give time for modal to fade
setTimeout
(
function
()
{
$
(
".actions_buttons_area .right_action_buttons"
).
notify
(
...
...
@@ -726,15 +742,7 @@ function save_products_npa_minimal_stock(product, inputs) {
}
);
},
500
);
products
[
index
].
minimal_stock
=
actions
.
minimal_stock
;
if
(
actions
.
npa
.
length
>
0
)
{
// Remove NPA products
products
.
splice
(
index
,
1
);
update_main_screen
();
debounceFunction
(
update_cdb_order
);
}
closeModal
();
});
},
error
:
function
(
data
)
{
let
msg
=
"erreur serveur lors de la sauvegarde"
.
...
...
outils/views.py
View file @
83db0aad
...
...
@@ -189,34 +189,51 @@ class ExportPOS(View):
kept_sessions_id
.
append
(
s
[
'id'
])
key
=
y
+
'-'
+
m
+
'-'
+
d
if
not
(
key
in
totals
):
totals
[
key
]
=
{
'CB'
:
0
,
'CSH'
:
0
,
'CHQ'
:
0
,
'TOTAL'
:
0
}
totals
[
key
]
=
{
'CB'
:
0
,
'CSH'
:
0
,
'CHQ'
:
0
,
'CB_DEJ'
:
0
,
'CHQ_DEJ'
:
0
,
'TOTAL'
:
0
}
sub_total
=
0
cb
=
chq
=
csh
=
0
cb
=
chq
=
csh
=
cbd
=
chqd
=
0
for
p
in
s
[
'payments'
]:
# p['name'] is a sequence generated string
# Test order is important as CHEQDEJ contains CHEQ for ex.
# p['journal'] could be used but easier to change in Odoo interface
sub_amount
=
round
(
p
[
'total_amount'
],
2
)
if
'CSH'
in
p
[
'name'
]:
csh
=
round
(
p
[
'total_amount'
],
2
)
csh
=
sub_amount
elif
'CHEQDEJ'
in
p
[
'name'
]:
chqd
=
sub_amount
elif
'CHEQ'
in
p
[
'name'
]:
chq
=
round
(
p
[
'total_amount'
],
2
)
chq
=
sub_amount
elif
'CBDEJ'
in
p
[
'name'
]:
cbd
=
sub_amount
elif
'CB'
in
p
[
'name'
]:
cb
=
round
(
p
[
'total_amount'
],
2
)
sub_total
+=
round
(
p
[
'total_amount'
],
2
)
cb
=
sub_amount
sub_total
+=
sub_amount
totals
[
key
][
'CB'
]
+=
cb
totals
[
key
][
'CSH'
]
+=
csh
totals
[
key
][
'CHQ'
]
+=
chq
totals
[
key
][
'CB_DEJ'
]
+=
cbd
totals
[
key
][
'CHQ_DEJ'
]
+=
chqd
totals
[
key
][
'TOTAL'
]
+=
round
(
sub_total
,
2
)
details_lines
.
append
([
mois
,
s
[
'mm_dates'
][
'min'
],
s
[
'mm_dates'
][
'min'
],
s
[
'caisse'
],
s
[
'name'
],
cb
,
csh
,
chq
,
sub_total
])
cb
,
csh
,
chq
,
cbd
,
chqd
,
sub_total
])
wb
=
Workbook
()
ws1
=
wb
.
create_sheet
(
"Totaux "
+
mois
,
0
)
ws2
=
wb
.
create_sheet
(
"Détails "
+
mois
,
1
)
ws1
.
append
([
'date'
,
'CB'
,
'CSH'
,
'CHQ'
,
'Total'
])
ws1
.
append
([
'date'
,
'CB'
,
'CSH'
,
'CHQ'
,
'
CB_DEJ'
,
'CHQ_DEJ'
,
'
Total'
])
for
day
in
sorted
(
totals
):
cb
=
totals
[
day
][
'CB'
]
csh
=
totals
[
day
][
'CSH'
]
chq
=
totals
[
day
][
'CHQ'
]
cbd
=
totals
[
day
][
'CB_DEJ'
]
chqd
=
totals
[
day
][
'CHQ_DEJ'
]
total
=
totals
[
day
][
'TOTAL'
]
ws1
.
append
([
day
,
cb
,
csh
,
chq
,
total
])
ws2
.
append
([
'mois'
,
'min_date'
,
'max_date'
,
'Caisse'
,
'session'
,
'CB'
,
'CSH'
,
'CHQ'
,
'total'
])
ws1
.
append
([
day
,
cb
,
csh
,
chq
,
cbd
,
chqd
,
total
])
ws2
.
append
([
'mois'
,
'min_date'
,
'max_date'
,
'Caisse'
,
'session'
,
'CB'
,
'CSH'
,
'CHQ'
,
'
CB_DEJ'
,
'CHQ_DEJ'
,
'
total'
])
for
row
in
details_lines
:
ws2
.
append
(
row
)
wb_name
=
'export_sessions__'
+
mois
+
'.xlsx'
...
...
sales/models.py
View file @
83db0aad
...
...
@@ -14,38 +14,29 @@ class CagetteSales(models.Model):
def
get_sales
(
self
,
date_from
,
date_to
):
res
=
[]
# Get pos sessions
cond
=
[[
'stop_at'
,
'>='
,
date_from
],
[
'stop_at'
,
'<='
,
date_to
],
[
'state'
,
'='
,
"closed"
]]
fields
=
[]
sessions
=
self
.
o_api
.
search_read
(
'pos.session'
,
cond
,
fields
)
# Get pos orders
cond
=
[[
'date_order'
,
'>='
,
date_from
],
[
'date_order'
,
'<='
,
date_to
]]
fields
=
[
'partner_id'
,
'statement_ids'
,
'name'
]
orders
=
self
.
o_api
.
search_read
(
'pos.order'
,
cond
,
fields
)
# Get bank statements of these sessions
statements
=
[]
for
s
in
sessions
:
statements
=
statements
+
s
[
"statement_ids"
]
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
=
[[
'
statement_
id'
,
'in'
,
statements
]]
fields
=
[
"
partner_id"
,
"amount"
,
"journal_id"
,
"create_date"
,
"
date"
]
cond
=
[[
'id'
,
'in'
,
statements
]]
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_id"
][
0
]
==
payment
[
"partner_id"
][
0
]
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
=
{
"partner_id"
:
payment
[
"partner_id"
],
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,10 +44,8 @@ class CagetteSales(models.Model):
"journal_id"
:
payment
[
"journal_id"
]
}
]
}
res
.
append
(
item
)
})
except
Exception
as
e
:
pass
coop_logger
.
error
(
"get_sales
%
s"
,
str
(
e
))
return
res
sales/static/js/sales.js
View file @
83db0aad
...
...
@@ -38,20 +38,23 @@ function display_orders(orders) {
columns
:[
{
data
:
"create_date"
,
title
:
"Date
de vente
"
,
title
:
"Date
enregistrement
"
,
width
:
"10%"
},
{
data
:
"partner_id"
,
data
:
"pos_order_name"
,
title
:
"Ref. Caisse"
,
width
:
"10%"
},
{
data
:
"partner"
,
title
:
"Membre"
,
width
:
"50%"
,
render
:
function
(
data
)
{
return
data
[
1
];
}
width
:
"40%"
},
{
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