-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
128 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
"""For raw products (fruits, vegetables, etc.), the price is either | ||
per unit or per kilogram. This enum is used to store this information. | ||
""" | ||
TYPE_PRODUCT = "PRODUCT" # product_code | ||
TYPE_CATEGORY = "CATEGORY" # OFF category_tag (raw product) | ||
TYPE_LIST = [TYPE_PRODUCT, TYPE_CATEGORY] | ||
TYPE_CHOICES = [(key, key) for key in TYPE_LIST] | ||
|
||
|
||
""" | ||
PRICE_PER | ||
For raw products (TYPE_CATEGORY) (fruits, vegetables, etc.), | ||
the price is either per unit or per kilogram. | ||
""" | ||
PRICE_PER_UNIT = "UNIT" | ||
PRICE_PER_KILOGRAM = "KILOGRAM" | ||
|
||
PRICE_PER_LIST = [PRICE_PER_UNIT, PRICE_PER_KILOGRAM] | ||
PRICE_PER_CHOICES = [(key, key) for key in PRICE_PER_LIST] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 5.1 on 2024-11-26 09:48 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def set_price_type_category(apps, schema_editor): | ||
Price = apps.get_model("prices", "Price") | ||
# Price.objects.filter(product_code__isnull=False).update(type="PRODUCT") | ||
Price.objects.filter(category_tag__isnull=False).update(type="CATEGORY") | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("prices", "0003_price_receipt_quantity"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="price", | ||
name="type", | ||
field=models.CharField( | ||
choices=[("PRODUCT", "PRODUCT"), ("CATEGORY", "CATEGORY")], | ||
default="PRODUCT", # used only for the migration | ||
max_length=20, | ||
), | ||
preserve_default=False, | ||
), | ||
migrations.RunPython(set_price_type_category), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters