'use strict';

/** Seeder: PEVEETA materials (company_id = 2)
 *  Inserts a set of materials needed for the PEVEETA company (steel door manufacturing).
 */
module.exports = {
  up: async (queryInterface, Sequelize) => {
    const now = new Date();
    // base_uom_id: 1 = 'PC' (Piece) from UOM seeder
    const materials = [
      { company_id: 2, material_number: 'PEV-0001', description: 'HINGE', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0002', description: 'HINGE SCREW 6 MM', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0003', description: 'DEAD LOCK MORTISE 55MM', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0004', description: 'DEAD LOCK 70MM KEY CYLINDER', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0005', description: 'DEAD LOCK CYLINDER SCREW', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0006', description: 'DEAD LOCK MORTISE M4 X 12 SCREW', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0007', description: 'DEAD LOCK ONROSE', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0008', description: 'DEAD LOCK ONROSE M4 X 20 SCREW', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0009', description: 'DEAD LOCK STRIKE PLATE', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0010', description: 'DEAD LOCK STRIKE PLATE M4X12', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0011', description: 'ANCHOR BOLT M8X80', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0012', description: 'HOLE CAP', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0013', description: 'GLASS TUFF 300X300X5 MM (VISION)', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0014', description: 'M4 X 25 SCREW (VISION)', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0015', description: 'DOOR CLOSER', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0016', description: 'D HANDLE 300MM', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0017', description: 'DOWN SEAL', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0018', description: 'PLASTIC PACKER 5MM', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0019', description: 'PLASTIC PACKER 3MM', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0020', description: 'SILICON PUMPONS 5306 CLEAR', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0021', description: 'PEVEETA STICKER', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
      { company_id: 2, material_number: 'PEV-0022', description: 'PEVEETA KEY CHAIN', material_type: 'RAW_MATERIAL', base_uom_id: 1, status: 'ACTIVE', created_at: now, updated_at: now },
    ];

    return queryInterface.bulkInsert('material', materials, {});
  },

  down: async (queryInterface, Sequelize) => {
    const materialNumbers = [
      'PEV-0001','PEV-0002','PEV-0003','PEV-0004','PEV-0005','PEV-0006','PEV-0007','PEV-0008','PEV-0009','PEV-0010',
      'PEV-0011','PEV-0012','PEV-0013','PEV-0014','PEV-0015','PEV-0016','PEV-0017','PEV-0018','PEV-0019','PEV-0020',
      'PEV-0021','PEV-0022'
    ];
    return queryInterface.bulkDelete('material', { company_id: 2, material_number: materialNumbers }, {});
  }
};


