"""Manual new/old choice, independent of the calculated product-age field.""" from services.db import query def snapshot_new_old(product_code, saved_value=None): """Preserve an existing pending snapshot during quantity/remark edits.""" if saved_value in ('是', '否'): return saved_value rows = query('SELECT planning_new_old FROM products WHERE product_code=%s', (product_code,)) return '是' if rows and rows[0].get('planning_new_old') == '是' else '否'