entirius-django-pricemanager 4.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.
Files changed (113) hide show
  1. entirius_django_pricemanager-4.0.0/.gitattributes +2 -0
  2. entirius_django_pricemanager-4.0.0/.github/workflows/ci.yml +49 -0
  3. entirius_django_pricemanager-4.0.0/.github/workflows/publish.yml +18 -0
  4. entirius_django_pricemanager-4.0.0/.gitignore +33 -0
  5. entirius_django_pricemanager-4.0.0/.license-header.txt +3 -0
  6. entirius_django_pricemanager-4.0.0/.pre-commit-config.yaml +39 -0
  7. entirius_django_pricemanager-4.0.0/AGENTS.md +161 -0
  8. entirius_django_pricemanager-4.0.0/CLAUDE.md +1 -0
  9. entirius_django_pricemanager-4.0.0/LICENSE +373 -0
  10. entirius_django_pricemanager-4.0.0/Makefile +16 -0
  11. entirius_django_pricemanager-4.0.0/PKG-INFO +74 -0
  12. entirius_django_pricemanager-4.0.0/README.md +38 -0
  13. entirius_django_pricemanager-4.0.0/docs/erd-config.yaml +31 -0
  14. entirius_django_pricemanager-4.0.0/pyproject.toml +77 -0
  15. entirius_django_pricemanager-4.0.0/src/django_pricemanager/__init__.py +0 -0
  16. entirius_django_pricemanager-4.0.0/src/django_pricemanager/admin.py +228 -0
  17. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/__init__.py +0 -0
  18. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/__init__.py +0 -0
  19. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/pagination.py +11 -0
  20. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/permissions.py +12 -0
  21. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/urls.py +52 -0
  22. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/views/__init__.py +0 -0
  23. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/views/channel_views.py +219 -0
  24. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/views/price_views.py +528 -0
  25. entirius_django_pricemanager-4.0.0/src/django_pricemanager/api/admin/views/tax_class_views.py +251 -0
  26. entirius_django_pricemanager-4.0.0/src/django_pricemanager/apps.py +16 -0
  27. entirius_django_pricemanager-4.0.0/src/django_pricemanager/bi.py +39 -0
  28. entirius_django_pricemanager-4.0.0/src/django_pricemanager/domains/__init__.py +1 -0
  29. entirius_django_pricemanager-4.0.0/src/django_pricemanager/domains/abstract/__init__.py +1 -0
  30. entirius_django_pricemanager-4.0.0/src/django_pricemanager/domains/abstract/pricemanager.py +31 -0
  31. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/__init__.py +0 -0
  32. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/commands/__init__.py +0 -0
  33. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/commands/backfill_demo_price_history.py +99 -0
  34. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/commands/import-pricelist-from-csv.py +45 -0
  35. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/commands/import-taxclass-from-csv.py +35 -0
  36. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/commands/manage-pricelists.py +47 -0
  37. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/commands/migrate_to_current_price.py +63 -0
  38. entirius_django_pricemanager-4.0.0/src/django_pricemanager/management/commands/pricemanager-garbage-collector.py +27 -0
  39. entirius_django_pricemanager-4.0.0/src/django_pricemanager/migrations/0001_squashed_0024_remove_currentprice_supplier_cost_fields.py +747 -0
  40. entirius_django_pricemanager-4.0.0/src/django_pricemanager/migrations/__init__.py +0 -0
  41. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/__init__.py +15 -0
  42. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/attr_representation.py +28 -0
  43. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/channel.py +50 -0
  44. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/choices.py +20 -0
  45. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/current_price.py +139 -0
  46. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/current_price_attribute.py +19 -0
  47. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/customer_representation.py +19 -0
  48. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/managers/__init__.py +1 -0
  49. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/managers/country.py +43 -0
  50. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/managers/price.py +61 -0
  51. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/pm_settings.py +39 -0
  52. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/price.py +135 -0
  53. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/price_history.py +45 -0
  54. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/pricelist.py +84 -0
  55. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/product_representation.py +28 -0
  56. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/purchase_cost.py +39 -0
  57. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/sale_channel.py +58 -0
  58. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/tax_class.py +26 -0
  59. entirius_django_pricemanager-4.0.0/src/django_pricemanager/models/tax_rate.py +38 -0
  60. entirius_django_pricemanager-4.0.0/src/django_pricemanager/output.py +130 -0
  61. entirius_django_pricemanager-4.0.0/src/django_pricemanager/output_bundle.py +38 -0
  62. entirius_django_pricemanager-4.0.0/src/django_pricemanager/output_custom.py +169 -0
  63. entirius_django_pricemanager-4.0.0/src/django_pricemanager/repository/__init__.py +1 -0
  64. entirius_django_pricemanager-4.0.0/src/django_pricemanager/repository/repository.py +376 -0
  65. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/__init__.py +0 -0
  66. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/requests/__init__.py +0 -0
  67. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/requests/channel.py +42 -0
  68. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/requests/price.py +55 -0
  69. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/requests/tax_class.py +32 -0
  70. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/responses/__init__.py +0 -0
  71. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/responses/channel.py +68 -0
  72. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/responses/price.py +137 -0
  73. entirius_django_pricemanager-4.0.0/src/django_pricemanager/schemas/responses/tax_class.py +44 -0
  74. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/__init__.py +1 -0
  75. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/channel_sync_service.py +36 -0
  76. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/garbage_collector.py +130 -0
  77. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/migration_service.py +242 -0
  78. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/price_edit_service.py +360 -0
  79. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/price_output_service.py +108 -0
  80. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/pricelist_service.py +481 -0
  81. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/product_representation_service.py +94 -0
  82. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/product_representation_service_attr.py +60 -0
  83. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/sale_channel_service.py +14 -0
  84. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/supplier_cost_service.py +154 -0
  85. entirius_django_pricemanager-4.0.0/src/django_pricemanager/services/tax_class_service.py +28 -0
  86. entirius_django_pricemanager-4.0.0/src/django_pricemanager/settings.py +37 -0
  87. entirius_django_pricemanager-4.0.0/src/django_pricemanager/signals/__init__.py +0 -0
  88. entirius_django_pricemanager-4.0.0/src/django_pricemanager/signals/dispatch.py +42 -0
  89. entirius_django_pricemanager-4.0.0/src/django_pricemanager/signals/handlers.py +26 -0
  90. entirius_django_pricemanager-4.0.0/src/django_pricemanager/signals/killswitch.py +67 -0
  91. entirius_django_pricemanager-4.0.0/src/django_pricemanager/signals/supplier_cost.py +105 -0
  92. entirius_django_pricemanager-4.0.0/src/django_pricemanager/tasks.py +136 -0
  93. entirius_django_pricemanager-4.0.0/src/django_pricemanager/urls.py +9 -0
  94. entirius_django_pricemanager-4.0.0/src/django_pricemanager/views.py +65 -0
  95. entirius_django_pricemanager-4.0.0/src/django_pricemanager/workers.py +236 -0
  96. entirius_django_pricemanager-4.0.0/tests/__init__.py +0 -0
  97. entirius_django_pricemanager-4.0.0/tests/conftest.py +195 -0
  98. entirius_django_pricemanager-4.0.0/tests/factories.py +132 -0
  99. entirius_django_pricemanager-4.0.0/tests/settings.py +37 -0
  100. entirius_django_pricemanager-4.0.0/tests/test_admin_api.py +615 -0
  101. entirius_django_pricemanager-4.0.0/tests/test_country_generation.py +133 -0
  102. entirius_django_pricemanager-4.0.0/tests/test_csv_import.py +133 -0
  103. entirius_django_pricemanager-4.0.0/tests/test_models.py +162 -0
  104. entirius_django_pricemanager-4.0.0/tests/test_output_compatibility.py +137 -0
  105. entirius_django_pricemanager-4.0.0/tests/test_price_edit_service.py +144 -0
  106. entirius_django_pricemanager-4.0.0/tests/test_price_history.py +213 -0
  107. entirius_django_pricemanager-4.0.0/tests/test_race_conditions.py +69 -0
  108. entirius_django_pricemanager-4.0.0/tests/test_signals.py +237 -0
  109. entirius_django_pricemanager-4.0.0/tests/test_slash_sku_routing.py +36 -0
  110. entirius_django_pricemanager-4.0.0/tests/test_supplier_cost_e2e.py +70 -0
  111. entirius_django_pricemanager-4.0.0/tests/test_supplier_cost_receiver.py +106 -0
  112. entirius_django_pricemanager-4.0.0/tests/urls.py +9 -0
  113. entirius_django_pricemanager-4.0.0/uv.lock +1286 -0
@@ -0,0 +1,2 @@
1
+ # uv.lock is generated — collapse it in diffs and exclude from language stats.
2
+ uv.lock linguist-generated=true
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [develop]
6
+ pull_request:
7
+ branches: [master, develop]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: astral-sh/setup-uv@v4
15
+ - run: uv sync --frozen --all-extras
16
+ - run: uv run ruff check .
17
+ - run: uv run ruff format --check .
18
+ - run: uv run pre-commit run insert-license --all-files
19
+
20
+ test:
21
+ runs-on: ubuntu-latest
22
+ needs: lint
23
+ services:
24
+ postgres:
25
+ image: postgres:16
26
+ env:
27
+ POSTGRES_PASSWORD: postgres
28
+ ports: ['5432:5432']
29
+ options: >-
30
+ --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 5
31
+ env:
32
+ DATABASE_URL: postgresql://postgres:postgres@localhost/test
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+ - uses: astral-sh/setup-uv@v4
36
+ - run: uv sync --frozen --all-extras
37
+ - run: uv run pytest -x -q
38
+
39
+ secret-scan:
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+ with:
44
+ fetch-depth: 0
45
+ - name: gitleaks
46
+ run: |
47
+ V=v8.30.0 # keep equal to the gitleaks rev in .pre-commit-config.yaml
48
+ curl -sSL "https://github.com/gitleaks/gitleaks/releases/download/${V}/gitleaks_${V#v}_linux_x64.tar.gz" | sudo tar -xz -C /usr/local/bin gitleaks
49
+ gitleaks git --redact -v
@@ -0,0 +1,18 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi # GH environment bound to the PyPI trusted publisher
11
+ permissions:
12
+ id-token: write # OIDC - short-lived PyPI token, no stored secrets
13
+ contents: read
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: astral-sh/setup-uv@v4
17
+ - run: uv build
18
+ - run: uv publish --trusted-publishing always
@@ -0,0 +1,33 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+
8
+ # Virtualenv / uv
9
+ .venv/
10
+ .python-version
11
+
12
+ # Django (test project artifacts)
13
+ db.sqlite3
14
+ db.sqlite3-journal
15
+ *.log
16
+
17
+ # Test / coverage
18
+ .pytest_cache/
19
+ .coverage
20
+ htmlcov/
21
+ coverage.xml
22
+
23
+ # Tooling caches
24
+ .ruff_cache/
25
+ .mypy_cache/
26
+
27
+ # IDE / OS
28
+ .idea/
29
+ .vscode/
30
+ .DS_Store
31
+
32
+ # Secret scanning (forbidden-names blocklist - local symlink, never committed)
33
+ .gitleaks.toml
@@ -0,0 +1,3 @@
1
+ This Source Code Form is subject to the terms of the Mozilla Public
2
+ License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
@@ -0,0 +1,39 @@
1
+ repos:
2
+ - repo: https://github.com/Lucas-C/pre-commit-hooks
3
+ rev: v1.5.6
4
+ hooks:
5
+ - id: insert-license
6
+ files: \.py$
7
+ exclude: (^|/)__init__\.py$
8
+ args:
9
+ - --license-filepath
10
+ - .license-header.txt
11
+ - --comment-style
12
+ - "#"
13
+
14
+ - repo: https://github.com/astral-sh/ruff-pre-commit
15
+ rev: v0.15.20
16
+ hooks:
17
+ - id: ruff-check
18
+ args: [--fix]
19
+ - id: ruff-format
20
+
21
+ - repo: local
22
+ hooks:
23
+ - id: require-canonical-gitleaks-config
24
+ name: require canonical .gitleaks.toml (forbidden-names)
25
+ entry: bash -c 'grep -q "forbidden-names" .gitleaks.toml 2>/dev/null || { echo "Missing or non-canonical .gitleaks.toml - symlink the config per the internal secret-scanning standard"; exit 1; }'
26
+ language: system
27
+ always_run: true
28
+ pass_filenames: false
29
+ - id: gitleaks-config-untracked
30
+ name: .gitleaks.toml must stay gitignored
31
+ entry: bash -c '! git ls-files --error-unmatch .gitleaks.toml 2>/dev/null || { echo ".gitleaks.toml is tracked - add it to .gitignore"; exit 1; }'
32
+ language: system
33
+ always_run: true
34
+ pass_filenames: false
35
+
36
+ - repo: https://github.com/gitleaks/gitleaks
37
+ rev: v8.30.0
38
+ hooks:
39
+ - id: gitleaks
@@ -0,0 +1,161 @@
1
+ # AGENTS.md
2
+
3
+ Price management for the Volkanos ecommerce platform — distribution `entirius-django-pricemanager`,
4
+ Django app `django_pricemanager`. Product pricing across countries, currencies, channels, and tax
5
+ regimes. Transitioning from snapshot model (PriceList/Price) to CurrentPrice + PriceHistory
6
+ architecture.
7
+
8
+ **Tech:** Python >=3.11, Django >=5.0, DRF, Pydantic v2, drf-spectacular, Celery, PostgreSQL
9
+
10
+ ## Commands
11
+
12
+ | Command | Meaning |
13
+ |---|---|
14
+ | `make install` | sync dependencies (uv, incl. extras) |
15
+ | `make check` | lint + format-check (ruff) |
16
+ | `make fix` | auto-fix lint + format |
17
+ | `make test` | test suite (pytest + pytest-django) |
18
+
19
+ ## Conventions
20
+
21
+ - English only: code, docs, commits, branches, PRs.
22
+ - MPL-2.0: every non-trivial source file carries the license header (pre-commit inserts it).
23
+ - Toolchain: uv + ruff + hatchling + pytest; all config in `pyproject.toml`; `uv.lock` committed.
24
+ - Git flow: `master` (production) + `develop` (integration); changes land via PR; semver tag on `master`.
25
+ - Never rename the package / Django app_label / DB table prefix `django_pricemanager` — it is a schema contract.
26
+ - Migrations are part of the public contract — never edit an already released migration.
27
+ - Default: do not commit — git is the user's call.
28
+
29
+ ## Architecture
30
+
31
+ ```
32
+ src/django_pricemanager/
33
+ ├── models/
34
+ │ ├── current_price.py # One live price per product/channel/country/currency
35
+ │ ├── price_history.py # Append-only audit log of all price changes
36
+ │ ├── current_price_attribute.py # M2M through for attribute pricing
37
+ │ ├── choices.py # SOURCE_CHOICES constant
38
+ │ ├── channel.py # Channel (calculate_direction, calculate_countries)
39
+ │ ├── sale_channel.py # SaleChannel (legacy, internal routing)
40
+ │ ├── pricelist.py # PriceList (legacy snapshot container)
41
+ │ ├── price.py # Price + PriceAttribute (legacy)
42
+ │ ├── tax_rate.py # TaxRate (tax_class × country)
43
+ │ ├── tax_class.py # TaxClass
44
+ │ ├── product_representation.py # ProductRepresentation (sku + tax_class)
45
+ │ ├── attr_representation.py # AttributeRepresentation
46
+ │ ├── customer_representation.py # CustomerRepresentation (B2B tiers)
47
+ │ └── managers/ # PriceManager, CountryAwareManager
48
+ ├── schemas/
49
+ │ ├── requests/ # Pydantic request schemas
50
+ │ └── responses/ # Pydantic response schemas (from_attributes)
51
+ ├── services/
52
+ │ ├── price_edit_service.py # D1 FULL VATOSS edit flow
53
+ │ ├── channel_sync_service.py # Sync channels from PIM
54
+ │ ├── price_output_service.py # CurrentPrice read layer (compatibility)
55
+ │ ├── migration_service.py # Data migration from snapshots
56
+ │ ├── pricelist_service.py # CSV import + pricelist retrieval
57
+ │ ├── garbage_collector.py # Legacy cleanup (deprecated)
58
+ │ └── ...
59
+ ├── api/admin/
60
+ │ ├── views/ # 3 ViewSets (price, channel, tax_class) — currencies live in django-regional since 3.1.0
61
+ │ ├── urls.py # v2 endpoints
62
+ │ ├── pagination.py # AdminPageNumberPagination
63
+ │ └── permissions.py # JWTAuthentication + IsAdminUser
64
+ ├── output.py # Public read API for matrix/checkout
65
+ ├── output_bundle.py # Bundle pricing output
66
+ ├── output_custom.py # Attribute pricing output
67
+ ├── management/commands/ # CLI commands
68
+ ├── tasks.py # Celery tasks
69
+ ├── workers.py # Background workers
70
+ └── settings.py # Module settings
71
+ ```
72
+
73
+ ## Data Model
74
+
75
+ ### Core (v3 — CurrentPrice architecture)
76
+
77
+ | Entity | Key Fields | Relationships |
78
+ |--------|-----------|---------------|
79
+ | CurrentPrice | net_value, gross_value, special_*, source | FK: product, channel, country, currency, tax_rate, customer_representation; M2M: attrs |
80
+ | PurchaseCost | net_cost, supplier_idx | FK: product, channel, country, currency (BaseModel timestamps). Buy-side cost — independent of the sell price; written only by the supplier-cost receiver. Margin = CurrentPrice.net_value vs PurchaseCost.net_cost. |
81
+ | PriceHistory | net_value, gross_value, special_*, source, changed_by | FK: product, channel, country, currency, tax_rate |
82
+ | CurrentPriceAttribute | — | Through table: current_price × attr |
83
+
84
+ ### Legacy (deprecated, kept for dual-write transition)
85
+
86
+ | Entity | Key Fields | Relationships |
87
+ |--------|-----------|---------------|
88
+ | PriceList | status, source_file | FK: sale_channel, currency, country |
89
+ | Price | net_value, gross_value, special_* | FK: pricelist, product, tax_rate, product_parent; M2M: attrs |
90
+ | SaleChannel | price_source, is_only_for_verified_user | FK: channel, country, customer_representation |
91
+
92
+ ### Shared
93
+
94
+ | Entity | Key Fields | Relationships |
95
+ |--------|-----------|---------------|
96
+ | Channel | idx, name, calculate_direction | M2M: calculate_countries |
97
+ | TaxClass | idx, name | — |
98
+ | TaxRate | rate | FK: tax_class, country; unique: (tax_class, country) |
99
+ | ProductRepresentation | sku | FK: tax_class |
100
+
101
+ Note: `Currency` lives in `django_regional` (model: `django_regional.Currency`, fields: `iso3`, `name_en`, `name_pl`, `symbol`). PM models FK to it directly. The local PM Currency table was removed in migration `0021_currency_to_regional`.
102
+
103
+ ## API Contract
104
+
105
+ All endpoints: `api/pricemanager/v2/admin/` with JWTAuthentication + IsAdminUser.
106
+
107
+ | Method | Path | Description |
108
+ |--------|------|-------------|
109
+ | GET | `/{ch}/prices/` | List prices (paginated, filterable) |
110
+ | GET | `/{ch}/prices/{sku}/` | Price detail per country |
111
+ | POST | `/{ch}/prices/{sku}/preview/` | Preview price change (read-only) |
112
+ | PATCH | `/{ch}/prices/{sku}/` | Save price change (propagates to all countries) |
113
+ | GET | `/{ch}/prices/{sku}/history/` | Price history per SKU |
114
+ | GET | `/channels/` | List channels |
115
+ | GET | `/channels/{idx}/` | Channel detail + stats |
116
+ | POST | `/channels/` | Create channel |
117
+ | PATCH | `/channels/{idx}/` | Update channel |
118
+ | DELETE | `/channels/{idx}/` | Delete channel |
119
+ | POST | `/channels/sync/` | Sync from PIM |
120
+ | GET | `/tax-classes/` | List tax classes |
121
+ | GET | `/tax-classes/{idx}/` | Tax class + rates |
122
+ | POST | `/tax-classes/` | Create tax class |
123
+ | PATCH | `/tax-classes/{idx}/` | Update tax class |
124
+ | DELETE | `/tax-classes/{idx}/` | Delete tax class |
125
+ | POST | `/tax-classes/{idx}/rates/` | Add tax rate |
126
+ | PATCH | `/tax-classes/{idx}/rates/{iso2}/` | Update tax rate (triggers recalc) |
127
+ | DELETE | `/tax-classes/{idx}/rates/{iso2}/` | Remove tax rate |
128
+
129
+ Currencies are exposed by `django-regional` admin API at `/api/regional/v2/admin/currencies/` (read-only since 1.7.0). The legacy PM CRUD endpoints (`/api/pricemanager/v2/admin/currencies/...`) were removed in 3.1.0.
130
+
131
+ ## Testing
132
+
133
+ Postgres required. Tests read `DATABASE_URL` (default
134
+ `postgresql://postgres:postgres@localhost:5432/test` — matches the CI service). Run via `make test`.
135
+
136
+ ## Commands
137
+
138
+ | Command | Purpose |
139
+ |---------|---------|
140
+ | `migrate_to_current_price` | Data migration from snapshots to CurrentPrice |
141
+ | `import-pricelist-from-csv` | Import prices from CSV |
142
+ | `import-taxclass-from-csv` | Import tax rates from CSV |
143
+ | `manage-pricelists` | Generate pricelists for countries (legacy) |
144
+ | `pricemanager-garbage-collector` | Cleanup old pricelists (deprecated) |
145
+
146
+ ## Signal Receivers
147
+
148
+ | Receiver | Signal | Purpose |
149
+ |---|---|---|
150
+ | `signals.handlers.on_current_price_save` | `post_save(CurrentPrice)` | Enqueue Matrix read-model sync (no-op when killswitch denies the channel) |
151
+ | `signals.handlers.on_current_price_delete` | `post_delete(CurrentPrice)` | Same sync trigger on delete |
152
+ | `signals.supplier_cost.on_supplier_cost_updated` | `django_suppliers.signals.cost_updated_signal` | Write preferred-supplier cost to the dedicated **`PurchaseCost`** store — NEVER to `CurrentPrice`. A supplier cost is what we PAY, not what we sell for, so it never creates a sellable price; the product stays unpriced until an operator sets a CurrentPrice (margin = CurrentPrice.net_value vs PurchaseCost.net_cost). Soft import of django_suppliers — no-op when suppliers app is absent. Gates: ignored when link missing / link non-preferred, skipped when product/channel/currency resolution fails, idempotent when net_cost matches. Paths emit an audit row (sources `cost_signal_received`, `cost_ignored_non_preferred`, `cost_ignored_no_link`, `cost_skipped_resolution_failed`). Wrapped in `transaction.on_commit` per D32. Business logic in `services.supplier_cost_service.apply_supplier_cost` so it can be unit-tested without registering django_suppliers. |
153
+
154
+ ## Gotchas
155
+
156
+ - `calculate_direction` on Channel controls whether admin edits net or gross — CMS must respect this.
157
+ - PriceHistory uses `default=timezone.now` (not `auto_now_add`) so backfill can set custom timestamps.
158
+ - Two partial UniqueConstraints on CurrentPrice for general vs B2B tier prices (PostgreSQL NULL handling).
159
+ - `product_parent` in unique constraint — a product can have both regular and bundle component prices.
160
+ - Feature flags `PRICEMANAGER_DUAL_WRITE` and `PRICEMANAGER_READ_FROM_CURRENT` control phased rollout.
161
+ - Legacy `output.py` functions keep identical signatures — consumers (matrix, checkout) don't change.
@@ -0,0 +1 @@
1
+ @AGENTS.md