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
d1bad61b
Commit
d1bad61b
authored
Apr 28, 2017
by
Patrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instroduce purchase.is_resale_price_fixed for products like crowfunding
parent
ddf9683a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
repanier/models/invoice.py
repanier/models/invoice.py
+27
-4
repanier/models/purchase.py
repanier/models/purchase.py
+5
-1
repanier/tools.py
repanier/tools.py
+1
-1
No files found.
repanier/models/invoice.py
View file @
d1bad61b
...
...
@@ -237,7 +237,7 @@ class CustomerInvoice(models.Model):
result_set
=
purchase
.
Purchase
.
objects
.
filter
(
permanence_id
=
self
.
permanence_id
,
customer_id
=
self
.
customer_id
customer_id
=
self
.
customer_id
,
).
order_by
(
'?'
).
aggregate
(
Sum
(
'customer_vat'
),
Sum
(
'deposit'
),
...
...
@@ -257,15 +257,38 @@ class CustomerInvoice(models.Model):
self
.
total_price_with_tax
.
amount
=
DECIMAL_ZERO
if
self
.
price_list_multiplier
!=
DECIMAL_ONE
:
total_price_with_tax_wo_deposit
=
self
.
total_price_with_tax
.
amount
-
self
.
total_deposit
.
amount
result_set
=
purchase
.
Purchase
.
objects
.
filter
(
permanence_id
=
self
.
permanence_id
,
customer_id
=
self
.
customer_id
,
is_resale_price_fixed
=
True
).
order_by
(
'?'
).
aggregate
(
Sum
(
'customer_vat'
),
Sum
(
'deposit'
),
Sum
(
'selling_price'
)
)
if
result_set
[
"customer_vat__sum"
]
is
not
None
:
total_vat
=
result_set
[
"customer_vat__sum"
]
else
:
total_vat
=
DECIMAL_ZERO
if
result_set
[
"deposit__sum"
]
is
not
None
:
total_deposit
=
result_set
[
"deposit__sum"
]
else
:
total_deposit
=
DECIMAL_ZERO
if
result_set
[
"selling_price__sum"
]
is
not
None
:
total_price_with_tax
=
result_set
[
"selling_price__sum"
]
else
:
total_price_with_tax
=
DECIMAL_ZERO
total_price_with_tax_wo_deposit
=
total_price_with_tax
-
total_deposit
self
.
delta_price_with_tax
.
amount
=
-
(
total_price_with_tax_wo_deposit
-
(
total_price_with_tax_wo_deposit
*
self
.
price_list_multiplier
).
quantize
(
TWO_DECIMALS
)
)
self
.
delta_vat
.
amount
=
-
(
self
.
total_vat
-
(
self
.
total_vat
.
amoun
t
*
self
.
price_list_multiplier
total_vat
-
(
total_va
t
*
self
.
price_list_multiplier
).
quantize
(
FOUR_DECIMALS
)
)
else
:
...
...
repanier/models/purchase.py
View file @
d1bad61b
...
...
@@ -105,6 +105,8 @@ class Purchase(models.Model):
help_text
=
_
(
"This multiplier is applied to each price automatically imported/pushed."
),
default
=
DECIMAL_ONE
,
max_digits
=
5
,
decimal_places
=
4
,
blank
=
True
,
validators
=
[
MinValueValidator
(
0
)])
is_resale_price_fixed
=
models
.
BooleanField
(
_
(
"the resale price is set by the producer"
),
default
=
False
)
comment
=
models
.
CharField
(
_
(
"comment"
),
max_length
=
100
,
default
=
EMPTY_STRING
,
blank
=
True
,
null
=
True
)
is_updated_on
=
models
.
DateTimeField
(
...
...
@@ -332,12 +334,14 @@ def purchase_pre_save(sender, **kwargs):
quantity
=
purchase
.
quantity_invoiced
delta_quantity
=
quantity
-
purchase
.
previous_quantity
if
purchase
.
is_box_content
:
purchase
.
is_resale_price_fixed
=
True
if
delta_quantity
!=
DECIMAL_ZERO
:
offeritem
.
OfferItem
.
objects
.
filter
(
id
=
purchase
.
offer_item_id
).
update
(
quantity_invoiced
=
F
(
'quantity_invoiced'
)
+
delta_quantity
,
)
else
:
if
purchase
.
offer_item
.
is_resale_price_fixed
\
purchase
.
is_resale_price_fixed
=
purchase
.
offer_item
.
is_resale_price_fixed
if
purchase
.
is_resale_price_fixed
\
or
purchase
.
offer_item
.
price_list_multiplier
<
DECIMAL_ONE
:
purchase
.
price_list_multiplier
=
DECIMAL_ONE
else
:
...
...
repanier/tools.py
View file @
d1bad61b
...
...
@@ -1443,7 +1443,7 @@ def clean_offer_item(permanence, queryset, reset_add_2_stock=False):
offer_item
.
manage_production
=
producer
.
manage_production
# Important : or product.is_box -> impact into Purchase.get_customer_unit_price
# The boxes prices are not subjects to price modifications
offer_item
.
is_resale_price_fixed
=
producer
.
is_resale_price_fixed
or
product
.
is_box
offer_item
.
is_resale_price_fixed
=
producer
.
is_resale_price_fixed
or
product
.
is_box
or
product
.
order_unit
>=
PRODUCT_ORDER_UNIT_DEPOSIT
offer_item
.
price_list_multiplier
=
DECIMAL_ONE
if
offer_item
.
is_resale_price_fixed
else
producer
.
price_list_multiplier
offer_item
.
stock
=
product
.
stock
if
reset_add_2_stock
:
...
...
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