Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-19 14:46:32 +03:00
parent 10f90cbaf3
commit 539ca4b587
5 changed files with 66 additions and 0 deletions

View File

@@ -384,6 +384,25 @@ WHERE is_active = TRUE
Dim3 sql.NullInt64 Dim3 sql.NullInt64
} }
hasDim3Combo := func(dims []dimCombo) bool {
for _, d := range dims {
if d.Dim3.Valid && d.Dim3.Int64 > 0 {
return true
}
}
return false
}
filterDim3Combos := func(dims []dimCombo) []dimCombo {
out := make([]dimCombo, 0, len(dims))
for _, d := range dims {
if d.Dim3.Valid && d.Dim3.Int64 > 0 {
out = append(out, d)
}
}
return out
}
type sdprcWriteRow struct { type sdprcWriteRow struct {
Currency string `json:"currency"` Currency string `json:"currency"`
SdprcGrpID int `json:"sdprcgrp_id"` SdprcGrpID int `json:"sdprcgrp_id"`
@@ -578,6 +597,9 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
d3 = sql.NullInt64{Int64: id, Valid: true} d3 = sql.NullInt64{Int64: id, Valid: true}
resolvedDim3++ resolvedDim3++
} }
if strings.TrimSpace(dim3Code) != "" && !d3.Valid {
continue
}
key := fmt.Sprintf("%d|%d", d1, func() int64 { key := fmt.Sprintf("%d|%d", d1, func() int64 {
if d3.Valid { if d3.Valid {
return d3.Int64 return d3.Int64
@@ -1071,6 +1093,9 @@ VALUES (
if d, err := loadDimsFromMssqlStock(code); err != nil { if d, err := loadDimsFromMssqlStock(code); err != nil {
logger.Error("save:pg:dims:mssql:error", "product_code", code, "err", err) logger.Error("save:pg:dims:mssql:error", "product_code", code, "err", err)
} else if len(d) > 0 { } else if len(d) > 0 {
if hasDim3Combo(d) {
dims = filterDim3Combos(dims)
}
seenDims := make(map[string]struct{}, len(dims)+len(d)) seenDims := make(map[string]struct{}, len(dims)+len(d))
merged := make([]dimCombo, 0, len(dims)+len(d)) merged := make([]dimCombo, 0, len(dims)+len(d))
dim3Value := func(v sql.NullInt64) int64 { dim3Value := func(v sql.NullInt64) int64 {

View File

@@ -1039,6 +1039,7 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
msVariants := make([]msVariantRow, 0, 1024) msVariants := make([]msVariantRow, 0, 1024)
colorTokensByItem := make(map[int64][]string, len(itemIDs)) colorTokensByItem := make(map[int64][]string, len(itemIDs))
dim3TokensByItem := make(map[int64][]string, len(itemIDs)) dim3TokensByItem := make(map[int64][]string, len(itemIDs))
itemHasMssqlDim3 := make(map[int64]bool, len(itemIDs))
for msRows.Next() { for msRows.Next() {
var itemCode, colorCode, dim1Code, dim3Code string var itemCode, colorCode, dim1Code, dim3Code string
var qty sql.NullFloat64 var qty sql.NullFloat64
@@ -1064,6 +1065,9 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
}) })
addToken(colorTokensByItem, itemID, colorCode) addToken(colorTokensByItem, itemID, colorCode)
addToken(dim3TokensByItem, itemID, dim3Code) addToken(dim3TokensByItem, itemID, dim3Code)
if strings.TrimSpace(dim3Code) != "" {
itemHasMssqlDim3[itemID] = true
}
} }
if err := msRows.Err(); err != nil { if err := msRows.Err(); err != nil {
msRows.Close() msRows.Close()
@@ -1074,6 +1078,11 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
inferredDim1 := buildInferredMap("dimval1", colorTokensByItem, itemDim1Candidates) inferredDim1 := buildInferredMap("dimval1", colorTokensByItem, itemDim1Candidates)
inferredDim3 := buildInferredMap("dimval3", dim3TokensByItem, itemDim3Candidates) inferredDim3 := buildInferredMap("dimval3", dim3TokensByItem, itemDim3Candidates)
for key, row := range tmpMap {
if itemHasMssqlDim3[row.ItemID] && row.Dim3Key == 0 {
delete(tmpMap, key)
}
}
resolveProductDimID := func(itemID int64, column string, token string, inferred map[string]int64) (int64, bool) { resolveProductDimID := func(itemID int64, column string, token string, inferred map[string]int64) (int64, bool) {
token = strings.ToUpper(normalizeDimParam(token)) token = strings.ToUpper(normalizeDimParam(token))
if token == "" { if token == "" {
@@ -1113,6 +1122,9 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
if id, ok := resolveProductDimID(itemID, "dimval3", dim3Code, inferredDim3); ok { if id, ok := resolveProductDimID(itemID, "dimval3", dim3Code, inferredDim3); ok {
d3k = id d3k = id
} }
if strings.TrimSpace(dim3Code) != "" && d3k <= 0 {
continue
}
key := fmt.Sprintf("%d|%d|%d", itemID, d1, d3k) key := fmt.Sprintf("%d|%d|%d", itemID, d1, d3k)
prev, ok := tmpMap[key] prev, ok := tmpMap[key]
if !ok { if !ok {

View File

@@ -104,6 +104,13 @@
:disable="pageBusy" :disable="pageBusy"
@click="leftDetailsExpanded = !leftDetailsExpanded" @click="leftDetailsExpanded = !leftDetailsExpanded"
/> />
<q-toggle
v-model="showInStockOnly"
dense
color="primary"
label="Sadece stogu olanlar"
:disable="pageBusy"
/>
</div> </div>
<div class="toolbar-group"> <div class="toolbar-group">
@@ -641,6 +648,7 @@ const columnFilters = ref({})
const columnFilterSearch = ref({}) const columnFilterSearch = ref({})
const selectedPriceOptions = ref(['usd5', 'try5']) const selectedPriceOptions = ref(['usd5', 'try5'])
const leftDetailsExpanded = ref(true) const leftDetailsExpanded = ref(true)
const showInStockOnly = ref(false)
const rows = ref([]) const rows = ref([])
const loading = ref(false) const loading = ref(false)
@@ -1262,6 +1270,9 @@ const filteredRows = computed(() => {
const variantSet = selectedVariantCodeSet.value const variantSet = selectedVariantCodeSet.value
const localFilters = columnFilters.value || {} const localFilters = columnFilters.value || {}
let list = rows.value || [] let list = rows.value || []
if (showInStockOnly.value) {
list = list.filter((row) => Number(row?.stockQty ?? 0) > 0)
}
if (campaignSet.size > 0) { if (campaignSet.size > 0) {
list = list.filter((row) => campaignSet.has(toText(row?.campaignLabel))) list = list.filter((row) => campaignSet.has(toText(row?.campaignLabel)))
} }

View File

@@ -106,6 +106,13 @@
</q-item> </q-item>
</q-list> </q-list>
</q-btn-dropdown> </q-btn-dropdown>
<q-toggle
v-model="showInStockOnly"
dense
color="primary"
label="Sadece stogu olanlar"
:disable="pageBusy"
/>
</div> </div>
<div class="toolbar-group"> <div class="toolbar-group">
@@ -1245,6 +1252,7 @@ const selectedCurrencies = ref(['USD', 'EUR', 'TRY'])
const exportAllLoading = ref(false) const exportAllLoading = ref(false)
const showSelectedOnly = ref(false) const showSelectedOnly = ref(false)
const leftDetailsExpanded = ref(true) const leftDetailsExpanded = ref(true)
const showInStockOnly = ref(false)
const calcLoadingMap = ref({}) const calcLoadingMap = ref({})
const bulkCalcLoading = ref(false) const bulkCalcLoading = ref(false)
const saving = ref(false) const saving = ref(false)
@@ -1528,6 +1536,7 @@ function rowSelectionKey (row) {
const filteredRows = computed(() => { const filteredRows = computed(() => {
return rows.value.filter((row) => { return rows.value.filter((row) => {
if (showSelectedOnly.value && !selectedMap.value[rowSelectionKey(row)]) return false if (showSelectedOnly.value && !selectedMap.value[rowSelectionKey(row)]) return false
if (showInStockOnly.value && Number(row?.stockQty ?? 0) <= 0) return false
for (const { field } of multiFilterColumns) { for (const { field } of multiFilterColumns) {
// Server-backed filters already reload full dataset (all pages) from backend. // Server-backed filters already reload full dataset (all pages) from backend.
// Keep only non-server multi filters (e.g. brandGroupSelection) as local page filter. // Keep only non-server multi filters (e.g. brandGroupSelection) as local page filter.

View File

@@ -106,6 +106,13 @@
</q-item> </q-item>
</q-list> </q-list>
</q-btn-dropdown> </q-btn-dropdown>
<q-toggle
v-model="showInStockOnly"
dense
color="primary"
label="Sadece stogu olanlar"
:disable="pageBusy"
/>
<div class="row items-center q-gutter-xs"> <div class="row items-center q-gutter-xs">
<q-chip <q-chip
@@ -1302,6 +1309,7 @@ const selectedPriceOptions = ref(priceOptionOptions.map((x) => x.value))
const exportAllLoading = ref(false) const exportAllLoading = ref(false)
const showSelectedOnly = ref(false) const showSelectedOnly = ref(false)
const leftDetailsExpanded = ref(true) const leftDetailsExpanded = ref(true)
const showInStockOnly = ref(false)
// Keep the old calc state around (not used on this screen) to avoid touching shared helpers. // Keep the old calc state around (not used on this screen) to avoid touching shared helpers.
const calcLoadingMap = ref({}) const calcLoadingMap = ref({})
@@ -1602,6 +1610,7 @@ function rowSelectionKey (row) {
const filteredRows = computed(() => { const filteredRows = computed(() => {
return rows.value.filter((row) => { return rows.value.filter((row) => {
if (showSelectedOnly.value && !selectedMap.value[rowSelectionKey(row)]) return false if (showSelectedOnly.value && !selectedMap.value[rowSelectionKey(row)]) return false
if (showInStockOnly.value && Number(row?.stockQty ?? 0) <= 0) return false
for (const { field } of multiFilterColumns) { for (const { field } of multiFilterColumns) {
// Server-backed filters already reload full dataset (all pages) from backend. // Server-backed filters already reload full dataset (all pages) from backend.
// Keep only non-server multi filters (e.g. brandGroupSelection) as local page filter. // Keep only non-server multi filters (e.g. brandGroupSelection) as local page filter.