implement fifo-v2 to transfer stock pakan

This commit is contained in:
giovanni
2026-02-23 11:05:39 +07:00
parent c3930ab555
commit 0b35012413
4 changed files with 229 additions and 21 deletions
@@ -199,18 +199,18 @@ func (s *fifoStockV2Service) buildGatherSubquery(rule routeRule, trait traitRule
}
if rule.ScopeSQL != nil && strings.TrimSpace(*rule.ScopeSQL) != "" {
whereParts = append(whereParts, fmt.Sprintf("(%s)", strings.TrimSpace(*rule.ScopeSQL)))
whereParts = append(whereParts, fmt.Sprintf("(%s)", normalizeScopeSQL(*rule.ScopeSQL)))
}
subquery := fmt.Sprintf(`
SELECT
? AS source_table,
? AS legacy_type_key,
? AS function_code,
?::text AS source_table,
?::text AS legacy_type_key,
?::text AS function_code,
src.%s AS source_id,
src.%s AS product_warehouse_id,
%s AS sort_at,
? AS sort_priority,
?::int AS sort_priority,
%s AS quantity,
%s AS used_quantity,
%s AS pending_quantity,