lfs-bulk-prices 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lfs_bulk_prices-2.0.0/LICENSE.txt +27 -0
- lfs_bulk_prices-2.0.0/MANIFEST.in +4 -0
- lfs_bulk_prices-2.0.0/PKG-INFO +62 -0
- lfs_bulk_prices-2.0.0/README.md +43 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/__init__.py +3 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/admin.py +4 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/apps.py +33 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/calculator.py +25 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/locale/de/LC_MESSAGES/django.mo +0 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/locale/de/LC_MESSAGES/django.po +61 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/0001_initial.py +24 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/0002_auto_20151116_0957.py +38 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/0003_auto_20151116_0958.py +23 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/0004_auto_20151116_1008.py +23 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/0005_auto_20151117_1947.py +22 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/0006_auto_20151124_1100.py +27 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/0007_auto_20151125_0801.py +18 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/migrations/__init__.py +0 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/models.py +19 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/static/lfs_bulk_prices/frontend.js +19 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/static/lfs_bulk_prices/manage.js +209 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/templates/lfs_bulk_prices/manage/tab.html +152 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/templatetags/__init__.py +0 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/templatetags/lfs_bulk_prices_tags.py +219 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/tests/__init__.py +0 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/tests/settings.py +50 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/tests/test_manage_tab.py +104 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/tests/urls.py +9 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/urls.py +10 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices/views.py +87 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices.egg-info/PKG-INFO +62 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices.egg-info/SOURCES.txt +35 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices.egg-info/dependency_links.txt +1 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices.egg-info/requires.txt +1 -0
- lfs_bulk_prices-2.0.0/lfs_bulk_prices.egg-info/top_level.txt +1 -0
- lfs_bulk_prices-2.0.0/pyproject.toml +41 -0
- lfs_bulk_prices-2.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2015, Kai Diefenbach - IQ++
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
documentation and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
* Neither the name of the author nor the names of other contributors may
|
|
15
|
+
be used to endorse or promote products derived from this software
|
|
16
|
+
without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lfs-bulk-prices
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Bulk prices (price tiers by quantity) for LFS
|
|
5
|
+
Author: Kai Diefenbach
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Source, https://github.com/diefenbach/lfs-bulk-prices
|
|
8
|
+
Keywords: django,e-commerce,online-shop
|
|
9
|
+
Classifier: Environment :: Web Environment
|
|
10
|
+
Classifier: Framework :: Django
|
|
11
|
+
Classifier: Framework :: Django :: 5.2
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE.txt
|
|
17
|
+
Requires-Dist: django-lfs<2,>=1.0
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# lfs-bulk-prices
|
|
21
|
+
|
|
22
|
+
Bulk prices for [LFS](https://github.com/diefenbach/django-lfs): price tiers by quantity ("from 10 pieces 8.50 €").
|
|
23
|
+
|
|
24
|
+
- A price calculator, `BulkPricesCalculator`, that picks the tier for the ordered amount.
|
|
25
|
+
- A **Bulk prices** tab on the product management page, shown for products that use this calculator.
|
|
26
|
+
- Template tags and a small script for the product page that show the tiers and update the price when the
|
|
27
|
+
customer changes the amount. lfs-theme includes them when the add-on is installed.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pip install lfs-bulk-prices # or, in lfs-project: uv sync --extra bulk-prices
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
# settings.py
|
|
37
|
+
INSTALLED_APPS = [..., "lfs_bulk_prices"]
|
|
38
|
+
|
|
39
|
+
LFS_PRICE_CALCULATORS = [
|
|
40
|
+
["lfs.gross_price.calculator.GrossPriceCalculator", _("Price includes tax")],
|
|
41
|
+
["lfs.net_price.calculator.NetPriceCalculator", _("Price excludes tax")],
|
|
42
|
+
["lfs_bulk_prices.calculator.BulkPricesCalculator", _("Bulk prices")],
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
# urls.py
|
|
46
|
+
urlpatterns += [path("bulk-prices/", include("lfs_bulk_prices.urls"))]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then run `python manage.py migrate`. In the management interface choose the price calculator "Bulk prices" for a
|
|
50
|
+
product (or for the shop as default); the product then gets the **Bulk prices** tab.
|
|
51
|
+
|
|
52
|
+
## Tests
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
pytest
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The tests use `lfs_bulk_prices.tests.settings` and need django-lfs with its required add-ons installed.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
BSD-3-Clause, see `LICENSE.txt`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# lfs-bulk-prices
|
|
2
|
+
|
|
3
|
+
Bulk prices for [LFS](https://github.com/diefenbach/django-lfs): price tiers by quantity ("from 10 pieces 8.50 €").
|
|
4
|
+
|
|
5
|
+
- A price calculator, `BulkPricesCalculator`, that picks the tier for the ordered amount.
|
|
6
|
+
- A **Bulk prices** tab on the product management page, shown for products that use this calculator.
|
|
7
|
+
- Template tags and a small script for the product page that show the tiers and update the price when the
|
|
8
|
+
customer changes the amount. lfs-theme includes them when the add-on is installed.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pip install lfs-bulk-prices # or, in lfs-project: uv sync --extra bulk-prices
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
# settings.py
|
|
18
|
+
INSTALLED_APPS = [..., "lfs_bulk_prices"]
|
|
19
|
+
|
|
20
|
+
LFS_PRICE_CALCULATORS = [
|
|
21
|
+
["lfs.gross_price.calculator.GrossPriceCalculator", _("Price includes tax")],
|
|
22
|
+
["lfs.net_price.calculator.NetPriceCalculator", _("Price excludes tax")],
|
|
23
|
+
["lfs_bulk_prices.calculator.BulkPricesCalculator", _("Bulk prices")],
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
# urls.py
|
|
27
|
+
urlpatterns += [path("bulk-prices/", include("lfs_bulk_prices.urls"))]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then run `python manage.py migrate`. In the management interface choose the price calculator "Bulk prices" for a
|
|
31
|
+
product (or for the shop as default); the product then gets the **Bulk prices** tab.
|
|
32
|
+
|
|
33
|
+
## Tests
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
pytest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The tests use `lfs_bulk_prices.tests.settings` and need django-lfs with its required add-ons installed.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
BSD-3-Clause, see `LICENSE.txt`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""App configuration: registers the bulk prices tab on the product management page."""
|
|
2
|
+
|
|
3
|
+
from django.apps import AppConfig
|
|
4
|
+
from django.http import HttpRequest
|
|
5
|
+
from django.utils.translation import gettext_lazy as _
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def uses_bulk_prices(request: HttpRequest, product) -> bool:
|
|
9
|
+
"""Return whether ``product`` is priced with the bulk prices calculator (its own or its parent's)."""
|
|
10
|
+
from .calculator import BulkPricesCalculator
|
|
11
|
+
|
|
12
|
+
return isinstance(product.get_price_calculator(request), BulkPricesCalculator)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class LfsBulkPricesConfig(AppConfig):
|
|
16
|
+
"""Adds the "Bulk prices" tab to products that use the bulk prices calculator."""
|
|
17
|
+
|
|
18
|
+
name = "lfs_bulk_prices"
|
|
19
|
+
verbose_name = _("Bulk prices")
|
|
20
|
+
|
|
21
|
+
def ready(self) -> None:
|
|
22
|
+
"""Register the product tab."""
|
|
23
|
+
from lfs.manage.products.tabs import ProductTab, register_product_tab
|
|
24
|
+
|
|
25
|
+
register_product_tab(
|
|
26
|
+
ProductTab(
|
|
27
|
+
key="bulk_prices",
|
|
28
|
+
label=_("Bulk prices"),
|
|
29
|
+
url_name="lfs_manage_product_bulk_prices",
|
|
30
|
+
template="lfs_bulk_prices/manage/tab.html",
|
|
31
|
+
show=uses_bulk_prices,
|
|
32
|
+
)
|
|
33
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from lfs.gross_price.calculator import GrossPriceCalculator
|
|
2
|
+
from .models import BulkPrice
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BulkPricesCalculator(GrossPriceCalculator):
|
|
6
|
+
""" """
|
|
7
|
+
|
|
8
|
+
def get_price(self, with_properties=True, amount=1):
|
|
9
|
+
""" """
|
|
10
|
+
# If a variant has no price calculator the price calculator from the parent is used.
|
|
11
|
+
# See also product.get_price_calculator().
|
|
12
|
+
#
|
|
13
|
+
# Once we are here, we have to check which bulk prices are applicable.
|
|
14
|
+
# That means, if a variant has no bulk prices at all, the bulk prices from the parent are used.
|
|
15
|
+
|
|
16
|
+
# First, determine the relevant product (use parent for variants if necessary)
|
|
17
|
+
target_product = self.product
|
|
18
|
+
if self.product.is_variant() and not BulkPrice.objects.filter(product=self.product).exists():
|
|
19
|
+
target_product = self.product.get_parent()
|
|
20
|
+
|
|
21
|
+
for bulk_price in BulkPrice.objects.filter(product=target_product).order_by("-amount"):
|
|
22
|
+
if amount >= bulk_price.amount:
|
|
23
|
+
return bulk_price.price_absolute
|
|
24
|
+
|
|
25
|
+
return 0.0
|
|
Binary file
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
|
2
|
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
3
|
+
# This file is distributed under the same license as the PACKAGE package.
|
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
5
|
+
#
|
|
6
|
+
msgid ""
|
|
7
|
+
msgstr ""
|
|
8
|
+
"Project-Id-Version: 1.0\n"
|
|
9
|
+
"Report-Msgid-Bugs-To: \n"
|
|
10
|
+
"POT-Creation-Date: 2015-11-24 13:01+0100\n"
|
|
11
|
+
"PO-Revision-Date: 2015-11-24 12:59+0100\n"
|
|
12
|
+
"Last-Translator: Kai Diefenbach <kai.diefenbach@iqpp.de>\n"
|
|
13
|
+
"Language-Team: DE <kai.diefenbach@iqpp.de>\n"
|
|
14
|
+
"Language: De\n"
|
|
15
|
+
"MIME-Version: 1.0\n"
|
|
16
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
|
17
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
18
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
19
|
+
|
|
20
|
+
#: models.py:16
|
|
21
|
+
msgid "Product"
|
|
22
|
+
msgstr "Produkt"
|
|
23
|
+
|
|
24
|
+
#: models.py:17 templates/lfs_bulk_prices/lfs_bulk_prices.html:13
|
|
25
|
+
msgid "Amount"
|
|
26
|
+
msgstr "Anzahl"
|
|
27
|
+
|
|
28
|
+
#: models.py:18
|
|
29
|
+
msgid "Price absolute"
|
|
30
|
+
msgstr "Absoluter Preis"
|
|
31
|
+
|
|
32
|
+
#: models.py:19
|
|
33
|
+
msgid "Price percentual"
|
|
34
|
+
msgstr "Prozentualer Preis"
|
|
35
|
+
|
|
36
|
+
#: templates/lfs_bulk_prices/lfs_bulk_prices.html:4
|
|
37
|
+
msgid "Bulk prices"
|
|
38
|
+
msgstr "Staffelpreise"
|
|
39
|
+
|
|
40
|
+
msgid "Bulk prices calculator"
|
|
41
|
+
msgstr "Staffelpreise"
|
|
42
|
+
|
|
43
|
+
#: templates/lfs_bulk_prices/lfs_bulk_prices.html:16
|
|
44
|
+
msgid "Absolute"
|
|
45
|
+
msgstr "Absolut"
|
|
46
|
+
|
|
47
|
+
#: templates/lfs_bulk_prices/lfs_bulk_prices.html:19
|
|
48
|
+
msgid "Percentual"
|
|
49
|
+
msgstr "Prozentual"
|
|
50
|
+
|
|
51
|
+
#: templates/lfs_bulk_prices/lfs_bulk_prices.html:68
|
|
52
|
+
msgid "Save"
|
|
53
|
+
msgstr "Speichern"
|
|
54
|
+
|
|
55
|
+
#: templates/lfs_bulk_prices/lfs_bulk_prices.html:69
|
|
56
|
+
msgid "Reset"
|
|
57
|
+
msgstr "Zurücksetzen"
|
|
58
|
+
|
|
59
|
+
#: views.py:44
|
|
60
|
+
msgid "Duplicated prices have been removed."
|
|
61
|
+
msgstr "Doppelte Preise wurden entfernt."
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import models, migrations
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
operations = [
|
|
9
|
+
migrations.CreateModel(
|
|
10
|
+
name="BulkPrice",
|
|
11
|
+
fields=[
|
|
12
|
+
("id", models.AutoField(verbose_name="ID", serialize=False, auto_created=True, primary_key=True)),
|
|
13
|
+
("price", models.DecimalField(verbose_name="Price", max_digits=10, decimal_places=2)),
|
|
14
|
+
("product", models.ForeignKey(to="catalog.Product", on_delete=models.CASCADE)),
|
|
15
|
+
],
|
|
16
|
+
options={
|
|
17
|
+
"ordering": ("price",),
|
|
18
|
+
},
|
|
19
|
+
),
|
|
20
|
+
migrations.AlterUniqueTogether(
|
|
21
|
+
name="bulkprice",
|
|
22
|
+
unique_together=set([("product", "price")]),
|
|
23
|
+
),
|
|
24
|
+
]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("lfs_bulk_prices", "0001_initial"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name="bulkprice",
|
|
15
|
+
options={"ordering": ("amount",)},
|
|
16
|
+
),
|
|
17
|
+
migrations.RenameField(
|
|
18
|
+
model_name="bulkprice",
|
|
19
|
+
old_name="price",
|
|
20
|
+
new_name="price_total",
|
|
21
|
+
),
|
|
22
|
+
migrations.AddField(
|
|
23
|
+
model_name="bulkprice",
|
|
24
|
+
name="amount",
|
|
25
|
+
field=models.SmallIntegerField(default=1),
|
|
26
|
+
preserve_default=False,
|
|
27
|
+
),
|
|
28
|
+
migrations.AddField(
|
|
29
|
+
model_name="bulkprice",
|
|
30
|
+
name="price_percentual",
|
|
31
|
+
field=models.DecimalField(default=0, verbose_name="Price", max_digits=10, decimal_places=2),
|
|
32
|
+
preserve_default=False,
|
|
33
|
+
),
|
|
34
|
+
migrations.AlterUniqueTogether(
|
|
35
|
+
name="bulkprice",
|
|
36
|
+
unique_together=set([("product", "price_total")]),
|
|
37
|
+
),
|
|
38
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("lfs_bulk_prices", "0002_auto_20151116_0957"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name="bulkprice",
|
|
15
|
+
name="price_percentual",
|
|
16
|
+
field=models.DecimalField(default=0.0, verbose_name="Price", max_digits=10, decimal_places=2),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name="bulkprice",
|
|
20
|
+
name="price_total",
|
|
21
|
+
field=models.DecimalField(default=0.0, verbose_name="Price", max_digits=10, decimal_places=2),
|
|
22
|
+
),
|
|
23
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("lfs_bulk_prices", "0003_auto_20151116_0958"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name="bulkprice",
|
|
15
|
+
name="price_percentual",
|
|
16
|
+
field=models.FloatField(default=0.0, verbose_name="Price percentual"),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name="bulkprice",
|
|
20
|
+
name="price_total",
|
|
21
|
+
field=models.FloatField(default=0.0, verbose_name="Price absolute"),
|
|
22
|
+
),
|
|
23
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("lfs_bulk_prices", "0004_auto_20151116_1008"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.RenameField(
|
|
14
|
+
model_name="bulkprice",
|
|
15
|
+
old_name="price_total",
|
|
16
|
+
new_name="price_absolute",
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterUniqueTogether(
|
|
19
|
+
name="bulkprice",
|
|
20
|
+
unique_together=set([("product", "price_absolute")]),
|
|
21
|
+
),
|
|
22
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("lfs_bulk_prices", "0005_auto_20151117_1947"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name="bulkprice",
|
|
15
|
+
name="amount",
|
|
16
|
+
field=models.SmallIntegerField(verbose_name="Amount"),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name="bulkprice",
|
|
20
|
+
name="product",
|
|
21
|
+
field=models.ForeignKey(verbose_name="Product", to="catalog.Product", on_delete=models.CASCADE),
|
|
22
|
+
),
|
|
23
|
+
migrations.AlterUniqueTogether(
|
|
24
|
+
name="bulkprice",
|
|
25
|
+
unique_together=set([("product", "price_absolute"), ("product", "amount")]),
|
|
26
|
+
),
|
|
27
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("lfs_bulk_prices", "0006_auto_20151124_1100"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name="bulkprice",
|
|
15
|
+
name="amount",
|
|
16
|
+
field=models.FloatField(verbose_name="Amount"),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
from django.utils.translation import gettext_lazy as _
|
|
3
|
+
from lfs.catalog.models import Product
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BulkPrice(models.Model):
|
|
7
|
+
""" """
|
|
8
|
+
|
|
9
|
+
class Meta:
|
|
10
|
+
ordering = ("amount",)
|
|
11
|
+
unique_together = (
|
|
12
|
+
("product", "price_absolute"),
|
|
13
|
+
("product", "amount"),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
product = models.ForeignKey(Product, verbose_name=_("Product"), on_delete=models.CASCADE)
|
|
17
|
+
amount = models.FloatField(_("Amount"))
|
|
18
|
+
price_absolute = models.FloatField(_("Price absolute"), default=0.0)
|
|
19
|
+
price_percentual = models.FloatField(_("Price percentual"), default=0.0)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
2
|
+
document.addEventListener('keyup', function(event) {
|
|
3
|
+
if (event.target.matches('.product input[name=quantity]')) {
|
|
4
|
+
var url = event.target.getAttribute('bulk_prices_update_url');
|
|
5
|
+
var amount = event.target.value;
|
|
6
|
+
|
|
7
|
+
fetch(url + '?amount=' + encodeURIComponent(amount))
|
|
8
|
+
.then(response => response.json())
|
|
9
|
+
.then(data => {
|
|
10
|
+
document.querySelectorAll('.standard-price-value').forEach(element => {
|
|
11
|
+
element.innerHTML = data['standard_price'];
|
|
12
|
+
});
|
|
13
|
+
document.querySelectorAll('.base-price .money').forEach(element => {
|
|
14
|
+
element.innerHTML = data['base_price'];
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|