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
0
Merge Requests
0
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
Alexis AOUN
third-party
Commits
ae0b9f20
Commit
ae0b9f20
authored
May 14, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sales export
parent
4922c3e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
33 deletions
+42
-33
models.py
sales/models.py
+24
-21
sales.css
sales/static/css/sales.css
+5
-2
sales.js
sales/static/js/sales.js
+10
-9
index.html
templates/sales/index.html
+3
-1
No files found.
sales/models.py
View file @
ae0b9f20
...
...
@@ -32,27 +32,30 @@ class CagetteSales(models.Model):
item
=
None
try
:
for
payment
in
payments
:
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"
],
"create_date"
:
payment
[
"create_date"
],
"date"
:
payment
[
"date"
],
"total_amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"payments"
:
[
{
"amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"journal_id"
:
payment
[
"journal_id"
]
}
]
}
res
.
append
(
item
)
# 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"
],
"create_date"
:
payment
[
"create_date"
],
"date"
:
payment
[
"date"
],
"total_amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"payments"
:
[
{
"amount"
:
round
(
float
(
payment
[
"amount"
]),
2
),
"journal_id"
:
payment
[
"journal_id"
]
}
]
}
res
.
append
(
item
)
except
Exception
as
e
:
pass
...
...
sales/static/css/sales.css
View file @
ae0b9f20
...
...
@@ -20,4 +20,7 @@
.select_sales_date_input
{
border-radius
:
5px
;
}
\ No newline at end of file
.btn_export_movements
{
margin-top
:
10px
;
}
\ No newline at end of file
sales/static/js/sales.js
View file @
ae0b9f20
...
...
@@ -32,14 +32,13 @@ function display_orders(orders) {
if
(
orders_table
)
{
orders_table
.
destroy
();
}
console
.
log
(
orders
);
orders_table
=
$
(
'#orders_table'
).
DataTable
({
data
:
orders
,
columns
:[
{
data
:
"create_date"
,
title
:
"Date"
,
title
:
"Date
de vente
"
,
width
:
"10%"
},
{
...
...
@@ -61,7 +60,6 @@ function display_orders(orders) {
{
data
:
"payments"
,
title
:
"Paiements"
,
className
:
"dt-body-center"
,
orderable
:
false
,
render
:
function
(
data
)
{
let
res
=
'<ul>'
;
...
...
@@ -79,8 +77,15 @@ function display_orders(orders) {
"asc"
]
],
dom
:
'rtip'
,
iDisplayLength
:
25
,
buttons
:
[
{
extend
:
'excelHtml5'
,
text
:
'Export en Excel'
,
className
:
'btn--primary btn_export_movements'
}
],
dom
:
'<lr<t>ip><"clear"><B>'
,
iDisplayLength
:
100
,
language
:
{
url
:
'/static/js/datatables/french.json'
}
});
...
...
@@ -188,8 +193,4 @@ $(document).ready(function() {
event
.
preventDefault
();
get_sales
();
});
// $('#dates_selection_button').click(function() {
// get_sales();
// });
});
templates/sales/index.html
View file @
ae0b9f20
...
...
@@ -11,7 +11,9 @@
<script type="
text
/
javascript
"
src=
"{% static 'jquery-ui-1.12.1/jquery-ui.min.js' %}?v="
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/jquery.dataTables.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/dataTables.plugins.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/datatables.buttons.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/buttons.html5.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/jszip.min.js' %}"
></script>
{% endblock %}
{% block content %}
...
...
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