fix: CSV-экспорт Estimate игнорировал аплифт, всегда x1.3
Фронтенд не отправлял значение поля "Аплифт к estimate" в запрос экспорта, из-за чего бэкенд всегда падал на дефолт 1.3. Кроме того, applyDDPMarkup применял один и тот же коэффициент к Estimate, Склад и Конкуренты — теперь Склад/Конкуренты всегда x1.3, а Estimate — по пользовательскому аплифту. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
34cee5f874
commit
b087b7eb58
@@ -59,7 +59,7 @@ type ProjectPricingExportOptions struct {
|
|||||||
IncludeStock bool `json:"include_stock"`
|
IncludeStock bool `json:"include_stock"`
|
||||||
IncludeCompetitor bool `json:"include_competitor"`
|
IncludeCompetitor bool `json:"include_competitor"`
|
||||||
Basis string `json:"basis"` // "fob" or "ddp"; empty defaults to "fob"
|
Basis string `json:"basis"` // "fob" or "ddp"; empty defaults to "fob"
|
||||||
SaleMarkup float64 `json:"sale_markup"` // DDP multiplier; 0 defaults to 1.3
|
SaleMarkup float64 `json:"sale_markup"` // DDP uplift applied to Estimate only; 0 defaults to 1.3
|
||||||
ManualPrice *float64 `json:"manual_price"` // user-defined total price; distributed proportionally across rows
|
ManualPrice *float64 `json:"manual_price"` // user-defined total price; distributed proportionally across rows
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,11 +514,15 @@ func sortConfigItemsByCategoryMap(items models.ConfigItems, catOrder map[string]
|
|||||||
return sorted
|
return sorted
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyDDPMarkup(rows []ProjectPricingExportRow, factor float64) {
|
// stockCompetitorMarkupFactor is the fixed DDP multiplier applied to Stock and
|
||||||
|
// Competitor columns, independent of the user-configurable estimate uplift.
|
||||||
|
const stockCompetitorMarkupFactor = 1.3
|
||||||
|
|
||||||
|
func applyDDPMarkup(rows []ProjectPricingExportRow, estimateFactor float64) {
|
||||||
for i := range rows {
|
for i := range rows {
|
||||||
rows[i].Estimate = scaleFloatPtr(rows[i].Estimate, factor)
|
rows[i].Estimate = scaleFloatPtr(rows[i].Estimate, estimateFactor)
|
||||||
rows[i].Stock = scaleFloatPtr(rows[i].Stock, factor)
|
rows[i].Stock = scaleFloatPtr(rows[i].Stock, stockCompetitorMarkupFactor)
|
||||||
rows[i].Competitor = scaleFloatPtr(rows[i].Competitor, factor)
|
rows[i].Competitor = scaleFloatPtr(rows[i].Competitor, stockCompetitorMarkupFactor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5028,6 +5028,7 @@ async function exportPricingCSV(table) {
|
|||||||
const basis = table === 'sale' ? 'ddp' : 'fob';
|
const basis = table === 'sale' ? 'ddp' : 'fob';
|
||||||
const manualInputId = table === 'sale' ? 'pricing-custom-price-sale' : 'pricing-custom-price-buy';
|
const manualInputId = table === 'sale' ? 'pricing-custom-price-sale' : 'pricing-custom-price-buy';
|
||||||
const manualPrice = parseDecimalInput(document.getElementById(manualInputId)?.value || '');
|
const manualPrice = parseDecimalInput(document.getElementById(manualInputId)?.value || '');
|
||||||
|
const saleUplift = table === 'sale' ? parseDecimalInput(document.getElementById('pricing-uplift-sale')?.value || '') : 0;
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(`/api/configs/${configUUID}/export/pricing`, {
|
const resp = await fetch(`/api/configs/${configUUID}/export/pricing`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -5039,6 +5040,7 @@ async function exportPricingCSV(table) {
|
|||||||
include_stock: true,
|
include_stock: true,
|
||||||
include_competitor: true,
|
include_competitor: true,
|
||||||
basis: basis,
|
basis: basis,
|
||||||
|
sale_markup: saleUplift > 0 ? saleUplift : null,
|
||||||
manual_price: manualPrice > 0 ? manualPrice : null,
|
manual_price: manualPrice > 0 ? manualPrice : null,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user