|
@@ -0,0 +1,303 @@
|
|
|
|
|
+const { dict } = require('@alancnet/material-framework/lib/util')
|
|
|
|
|
+
|
|
|
|
|
+const users = async (db) => {
|
|
|
|
|
+ const C = require('../../controllers')
|
|
|
|
|
+ const { User, StaffMember, Terminal, Role, Client } = db
|
|
|
|
|
+
|
|
|
|
|
+ const DEVELOPER = await db.upsert(Role, {
|
|
|
|
|
+ name: 'Developer',
|
|
|
|
|
+ key: 'DEV',
|
|
|
|
|
+ permissions: C.auth.permissions.permissions.join(',')
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const terminals = dict(await Terminal.findAll())
|
|
|
|
|
+ const roles = dict(await Role.findAll())
|
|
|
|
|
+
|
|
|
|
|
+ const [alan] = await db.fill(User,
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Alan Colon',
|
|
|
|
|
+ email: 'alancnet@gmail.com',
|
|
|
|
|
+ password: 'hello',
|
|
|
|
|
+ roles: [
|
|
|
|
|
+ 'MANAGER',
|
|
|
|
|
+ 'DEV'
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ ['email']
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const [ adam, bear, charlie, dustin, evelynn, frank, gary, harry ] =
|
|
|
|
|
+ await db.fill(StaffMember,
|
|
|
|
|
+ [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Adam Alvarez',
|
|
|
|
|
+ terminal: 'LAX',
|
|
|
|
|
+ laborCategory: 'WAREHOUSE',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Bear Biggs',
|
|
|
|
|
+ terminal: 'LAX',
|
|
|
|
|
+ laborCategory: 'ADMIN',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Charlie Chavez',
|
|
|
|
|
+ terminal: 'LAX',
|
|
|
|
|
+ laborCategory: 'OPS',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Dustin Dearly',
|
|
|
|
|
+ terminal: 'LAX',
|
|
|
|
|
+ laborCategory: 'DELIVERY',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Evelynn Ebert',
|
|
|
|
|
+ terminal: 'LAS',
|
|
|
|
|
+ laborCategory: 'WAREHOUSE',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Frank Fudgley',
|
|
|
|
|
+ terminal: 'LAS',
|
|
|
|
|
+ laborCategory: 'ADMIN',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Gary Gospel',
|
|
|
|
|
+ terminal: 'LAS',
|
|
|
|
|
+ laborCategory: 'OPS',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Harry Havenworth',
|
|
|
|
|
+ terminal: 'LAS',
|
|
|
|
|
+ laborCategory: 'DELIVERY',
|
|
|
|
|
+ wage: 15
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ ['name']
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const laxLabor = {
|
|
|
|
|
+ workdays: [
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: adam.id, hours: null },
|
|
|
|
|
+ { staffMemberId: bear.id, hours: null },
|
|
|
|
|
+ { staffMemberId: charlie.id, hours: null },
|
|
|
|
|
+ { staffMemberId: dustin.id, hours: null }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: adam.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: bear.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: charlie.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: dustin.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: adam.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: bear.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: charlie.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: dustin.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: adam.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: bear.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: charlie.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: dustin.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: adam.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: bear.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: charlie.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: dustin.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: adam.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: bear.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: charlie.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: dustin.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: adam.id, hours: null },
|
|
|
|
|
+ { staffMemberId: bear.id, hours: null },
|
|
|
|
|
+ { staffMemberId: charlie.id, hours: null },
|
|
|
|
|
+ { staffMemberId: dustin.id, hours: null }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const lasLabor = {
|
|
|
|
|
+ workdays: [
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: evelynn.id, hours: null },
|
|
|
|
|
+ { staffMemberId: frank.id, hours: null },
|
|
|
|
|
+ { staffMemberId: gary.id, hours: null },
|
|
|
|
|
+ { staffMemberId: harry.id, hours: null }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: evelynn.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: frank.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: gary.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: harry.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: evelynn.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: frank.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: gary.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: harry.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: evelynn.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: frank.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: gary.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: harry.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: evelynn.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: frank.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: gary.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: harry.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: evelynn.id, hours: 5 },
|
|
|
|
|
+ { staffMemberId: frank.id, hours: 10 },
|
|
|
|
|
+ { staffMemberId: gary.id, hours: 15 },
|
|
|
|
|
+ { staffMemberId: harry.id, hours: 20 }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ labor: [
|
|
|
|
|
+ { staffMemberId: evelynn.id, hours: null },
|
|
|
|
|
+ { staffMemberId: frank.id, hours: null },
|
|
|
|
|
+ { staffMemberId: gary.id, hours: null },
|
|
|
|
|
+ { staffMemberId: harry.id, hours: null }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const [ lax, las ] = await db.fill(Client, [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Los Angeles Total',
|
|
|
|
|
+ key: 'LAX',
|
|
|
|
|
+ terminal: 'LAX'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Las Vegas Total',
|
|
|
|
|
+ key: 'LAS',
|
|
|
|
|
+ terminal: 'LAS'
|
|
|
|
|
+ }
|
|
|
|
|
+ ])
|
|
|
|
|
+
|
|
|
|
|
+ const lasServices = {
|
|
|
|
|
+ workdays: [
|
|
|
|
|
+ { services: [ { clientId: las.id, cartons: null } ] },
|
|
|
|
|
+ { services: [ { clientId: las.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: las.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: las.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: las.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: las.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: las.id, cartons: null } ] }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const laxServices = {
|
|
|
|
|
+ workdays: [
|
|
|
|
|
+ { services: [ { clientId: lax.id, cartons: null } ] },
|
|
|
|
|
+ { services: [ { clientId: lax.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: lax.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: lax.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: lax.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: lax.id, cartons: 1000 } ] },
|
|
|
|
|
+ { services: [ { clientId: lax.id, cartons: null } ] }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for (let week of ['2018-07-08', '2018-07-01', '2018-06-24']) {
|
|
|
|
|
+ await C.labor.patch({
|
|
|
|
|
+ body: lasLabor,
|
|
|
|
|
+ params: {
|
|
|
|
|
+ terminal: 'LAS',
|
|
|
|
|
+ week
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ status() { return this },
|
|
|
|
|
+ end() { return this }
|
|
|
|
|
+ })
|
|
|
|
|
+ await C.labor.patch({
|
|
|
|
|
+ body: laxLabor,
|
|
|
|
|
+ params: {
|
|
|
|
|
+ terminal: 'LAX',
|
|
|
|
|
+ week
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ status() { return this },
|
|
|
|
|
+ end() { return this }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ await C.services.patch({
|
|
|
|
|
+ body: lasServices,
|
|
|
|
|
+ params: {
|
|
|
|
|
+ terminal: 'LAS',
|
|
|
|
|
+ week
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ status() { return this },
|
|
|
|
|
+ end() { return this }
|
|
|
|
|
+ })
|
|
|
|
|
+ await C.services.patch({
|
|
|
|
|
+ body: laxServices,
|
|
|
|
|
+ params: {
|
|
|
|
|
+ terminal: 'LAX',
|
|
|
|
|
+ week
|
|
|
|
|
+ },
|
|
|
|
|
+ }, {
|
|
|
|
|
+ status() { return this },
|
|
|
|
|
+ end() { return this }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ console.log('done')
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const seed = async (db) => {
|
|
|
|
|
+ await users(db)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+module.exports = Object.assign(seed, {
|
|
|
|
|
+ seed,
|
|
|
|
|
+ users
|
|
|
|
|
+})
|