Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
repanier
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chris
repanier
Commits
3d4f0b37
Commit
3d4f0b37
authored
May 02, 2017
by
Patrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Two pass to calculate invoice price
parent
6b888178
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
127 deletions
+100
-127
repanier/models/invoice.py
repanier/models/invoice.py
+19
-9
repanier/task/task_invoice.py
repanier/task/task_invoice.py
+81
-118
No files found.
repanier/models/invoice.py
View file @
3d4f0b37
...
...
@@ -227,7 +227,6 @@ class CustomerInvoice(models.Model):
self
.
calculate_delta_price
()
self
.
calculate_delta_transport
()
self
.
save
()
producer_invoice_buyinggroup
.
delta_price_with_tax
.
amount
+=
self
.
delta_price_with_tax
.
amount
producer_invoice_buyinggroup
.
delta_vat
.
amount
+=
self
.
delta_vat
.
amount
...
...
@@ -238,14 +237,24 @@ class CustomerInvoice(models.Model):
def
calculate_delta_price
(
self
):
getcontext
().
rounding
=
ROUND_HALF_UP
result_set
=
purchase
.
Purchase
.
objects
.
filter
(
permanence_id
=
self
.
permanence_id
,
customer_id
=
self
.
customer_id
,
).
order_by
(
'?'
).
aggregate
(
Sum
(
'customer_vat'
),
Sum
(
'deposit'
),
Sum
(
'selling_price'
)
)
if
self
.
customer_charged
is
None
:
result_set
=
purchase
.
Purchase
.
objects
.
filter
(
permanence_id
=
self
.
permanence_id
,
customer_id
=
self
.
customer_id
,
).
order_by
(
'?'
).
aggregate
(
Sum
(
'customer_vat'
),
Sum
(
'deposit'
),
Sum
(
'selling_price'
)
)
else
:
result_set
=
purchase
.
Purchase
.
objects
.
filter
(
permanence_id
=
self
.
permanence_id
,
customer_charged_id
=
self
.
customer_id
,
).
order_by
(
'?'
).
aggregate
(
Sum
(
'customer_vat'
),
Sum
(
'deposit'
),
Sum
(
'selling_price'
)
)
if
result_set
[
"customer_vat__sum"
]
is
not
None
:
self
.
total_vat
.
amount
=
result_set
[
"customer_vat__sum"
]
else
:
...
...
@@ -298,6 +307,7 @@ class CustomerInvoice(models.Model):
self
.
delta_price_with_tax
.
amount
=
DECIMAL_ZERO
self
.
delta_vat
.
amount
=
DECIMAL_ZERO
def
calculate_delta_transport
(
self
):
self
.
delta_transport
.
amount
=
DECIMAL_ZERO
...
...
repanier/task/task_invoice.py
View file @
3d4f0b37
This diff is collapsed.
Click to expand it.
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