ui: add B2B olmayan stok (orphans) page
This commit is contained in:
@@ -1168,19 +1168,22 @@ func productSeriesResolvePGVariant(ctx context.Context, pg *sql.DB, productCode,
|
||||
dim3ID = sql.NullInt64{Int64: id, Valid: true}
|
||||
}
|
||||
|
||||
// Only treat variants as ready if they exist in authoritative item-dim combos.
|
||||
// Only treat variants as ready if they exist in authoritative item-dim combos (mmitem_dim).
|
||||
// This prevents writing series assignments for stock variants that don't exist on the PG side.
|
||||
dim3Key := int64(0)
|
||||
if dim3ID.Valid {
|
||||
if dim3ID.Valid && dim3ID.Int64 > 1000 {
|
||||
dim3Key = dim3ID.Int64
|
||||
}
|
||||
var exists int
|
||||
if err := pg.QueryRowContext(ctx, `
|
||||
SELECT 1
|
||||
FROM mk_mmitem_dim_combo
|
||||
WHERE product_code=$1 AND dim1=$2 AND dim3_key=$3
|
||||
FROM mmitem_dim
|
||||
WHERE mmitem_id=$1
|
||||
AND is_active=TRUE
|
||||
AND val1=$2
|
||||
AND COALESCE(CASE WHEN val3 IS NOT NULL AND val3 > 1000 THEN val3 ELSE 0 END, 0) = $3
|
||||
LIMIT 1
|
||||
`, strings.TrimSpace(productCode), dim1ID, dim3Key).Scan(&exists); err != nil {
|
||||
`, mmitemID, dim1ID, dim3Key).Scan(&exists); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return 0, 0, sql.NullInt64{}, false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user