Update bible: competitors API endpoints and pricelist deletion/competitor sections
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
| GET | `/pricelists` | Pricelists | Pricelist listing |
|
||||
| GET | `/pricelists/:id` | PricelistDetail | Single pricelist view |
|
||||
| GET | `/vendor-mappings` | VendorMappings | Vendor mapping UI |
|
||||
| GET | `/admin/competitors` | Competitors | Competitor management UI |
|
||||
| GET | `/partials/components` | ComponentsPartial | Components partial |
|
||||
| GET/POST | `/setup` | Setup | DB connection setup |
|
||||
|
||||
@@ -71,6 +72,22 @@
|
||||
|
||||
---
|
||||
|
||||
## Competitors (`/api/competitors/*`)
|
||||
|
||||
| Method | URL | Description |
|
||||
|--------|-----|-------------|
|
||||
| GET | `/api/competitors` | List all competitors with unique p/n + total quote counts |
|
||||
| POST | `/api/competitors` | Create competitor |
|
||||
| GET | `/api/competitors/:id` | Get competitor by ID |
|
||||
| PUT | `/api/competitors/:id` | Update competitor (name, delivery_basis, currency, discount, column_mapping) |
|
||||
| DELETE | `/api/competitors/:id` | Delete competitor |
|
||||
| PATCH | `/api/competitors/:id/active` | Set is_active |
|
||||
| POST | `/api/competitors/:id/import` | Import Excel quote file (returns task_id, type: `competitor_import`) |
|
||||
| POST | `/api/competitors/pricelist` | Rebuild combined competitor pricelist from all stored quotes (returns task_id) |
|
||||
| POST | `/api/competitors/parse-headers` | Parse XLSX headers/preview for column mapping UI |
|
||||
|
||||
---
|
||||
|
||||
## Tasks (polling)
|
||||
|
||||
| Method | URL | Description |
|
||||
|
||||
@@ -129,3 +129,22 @@ Task type: `TaskTypePricelistCreate`.
|
||||
- Service: `internal/services/pricelist/service.go`
|
||||
- Warehouse calc: `internal/warehouse/snapshot.go`
|
||||
- Handler: `internal/handlers/pricelist.go`
|
||||
|
||||
---
|
||||
|
||||
## Pricelist Deletion Guard
|
||||
|
||||
`CountUsage(id)` checks `qt_configurations` for references across **all three** pricelist columns:
|
||||
`pricelist_id`, `warehouse_pricelist_id`, `competitor_pricelist_id`.
|
||||
|
||||
A pricelist is only deletable when all three counts are zero.
|
||||
|
||||
---
|
||||
|
||||
## Competitor Pricelist
|
||||
|
||||
- **Source**: `competitor`
|
||||
- **Rebuilt via**: `POST /api/competitors/pricelist` (task type: `competitor_import`)
|
||||
- **Logic**: Latest quote per `(competitor_id, partnumber)` across ALL active competitors → apply each competitor's `expected_discount_pct` → `weighted_median` per lot → insert into `qt_pricelist_items`
|
||||
- **price_method**: `weighted_median`, **price_period_days**: `0`
|
||||
- Quotes stored in `partnumber_log_competitors`; unmapped p/ns recorded in `qt_vendor_partnumber_seen` with `source_type = 'competitor:<code>'`
|
||||
|
||||
Reference in New Issue
Block a user