-- llx_scrap_reason_reset.sql
-- Full reset of llx_scrap_reason table.
-- Removes all rows (including old C-xx codes from previous migration) then
-- reloads the canonical data from scrap-reason.txt with global positions.
-- Safe to re-run.

TRUNCATE TABLE llx_scrap_reason;

INSERT INTO llx_scrap_reason (code, label, category, active, position) VALUES
-- M: Material Defects (0-4)
('M-00', 'Material Defects',                               'M', 1,  0),
('M-01', 'Score marks',                                    'M', 1,  1),
('M-02', 'Pitting',                                        'M', 1,  2),
('M-03', 'Corrosion',                                      'M', 1,  3),
('M-04', 'Delamination',                                   'M', 1,  4),
-- G: General Defect (5-14)
('G-00', 'General Defect',                                 'G', 1,  5),
('G-01', 'Scratches',                                      'G', 1,  6),
('G-02', 'Dents',                                          'G', 1,  7),
('G-03', 'Distortion',                                     'G', 1,  8),
('G-04', 'Setup Scrap',                                    'G', 1,  9),
('G-05', 'Handling Damage',                                'G', 1, 10),
('G-06', 'Missing rivnut',                                 'G', 1, 11),
('G-07', 'Missing BOP',                                    'G', 1, 12),
('G-08', 'Missed Operation',                               'G', 1, 13),
('G-09', 'Obsolete Parts',                                 'G', 1, 14),
-- F: Forming Defects (15-32)
('F-00', 'Forming Defects',                                'F', 1, 15),
('F-01', 'Incorrect shape',                                'F', 1, 16),
('F-02', 'Splits',                                         'F', 1, 17),
('F-03', 'Wrinkles',                                       'F', 1, 18),
('F-04', 'Cavitation',                                     'F', 1, 19),
('F-05', 'Underforming (Press Issue)',                     'F', 1, 20),
('F-06', 'Underforming (Blank position / blank pulled in', 'F', 1, 21),
('F-07', 'Out of flatness tolerance',                      'F', 1, 22),
('F-08', 'Thinning',                                       'F', 1, 23),
('F-09', 'Striations',                                     'F', 1, 24),
('F-10', 'Lumps / cosmetics',                              'F', 1, 25),
('F-11', 'Ghosted on repress',                             'F', 1, 26),
('F-12', 'Press issue',                                    'F', 1, 27),
('F-13', 'VPR',                                            'F', 1, 28),
('F-14', 'Excessive Dag',                                  'F', 1, 29),
('F-15', 'Failed material test',                           'F', 1, 30),
('F-16', 'Distortion',                                     'F', 1, 31),
('F-17', 'Development',                                    'F', 1, 32),
-- T: CNC Defects (33-43)
('T-00', 'CNC Defects',                                    'T', 1, 33),
('T-01', 'Drilled Incorrectly',                            'T', 1, 34),
('T-02', 'Over Linished',                                  'T', 1, 35),
('T-03', 'Undersize trim',                                 'T', 1, 36),
('T-04', 'Oversize trim',                                  'T', 1, 37),
('T-05', 'Setup',                                          'T', 1, 38),
('T-06', 'Holes out of spec',                              'T', 1, 39),
('T-07', 'Came off fixture',                               'T', 1, 40),
('T-08', 'Wrong program',                                  'T', 1, 41),
('T-09', 'Development',                                    'T', 1, 42),
('T-10', 'Damaged / Dented',                               'T', 1, 43),
-- L: Laser Defects (44-55)
('L-00', 'Laser Defects',                                  'L', 1, 44),
('L-01', 'Missing Feature',                                'L', 1, 45),
('L-02', 'Poor laser edge',                                'L', 1, 46),
('L-03', 'Misalignment',                                   'L', 1, 47),
('L-04', 'Incorrect shape to trim',                        'L', 1, 48),
('L-05', 'Short trim',                                     'L', 1, 49),
('L-06', 'Not Vacuumed',                                   'L', 1, 50),
('L-07', 'Laser tip setup',                                'L', 1, 51),
('L-08', 'Laser burn through',                             'L', 1, 52),
('L-09', 'Setup',                                          'L', 1, 53),
('L-10', 'Incorrect program',                              'L', 1, 54),
('L-11', 'Development',                                    'L', 1, 55);
