const mongoose = require('mongoose')

const TransactionSchema = mongoose.Schema({
  // system structure
  user_id: { type: mongoose.ObjectId, ref: 'User' },
  agent_id: { type: mongoose.ObjectId, ref: 'Representation' },
  db_name: { type: String, enum: ['verity', 'panatech'] },

  // form info
  BusinessID: String,
  Description: String,
  cAddress1: String,
  TransCCustom1: String,
  cTel1: String,
  items: Array,
  //
  TempReceiptTransNumber: String,
  ItemReceptionTransNumber: String,
  TempReceiptTransDate: String,
  ItemReceptionTransDate: String,

  // agent operations
  seen: { type: Boolean, default: false },
  status: { type: String, enum: ['saved', 'recieved', 'ongoing', 'waiting', 'delivered'], default: 'saved' },
  statusHistory: [
    {
      status: String,
      date: Number
    }
  ],
  deliveryCode: String
})

module.exports = mongoose.model('Transaction', TransactionSchema)
