const mongoose = require("mongoose");



const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

// Store a random password reset code
const code = Math.floor(100000 + Math.random() * 900000);
const RoleSchema = new Schema({ name: String });
const moment = require('moment');


const tankersSchema = new mongoose.Schema({
    supplierId: { type: String, default: null },
    tankerName: { type: String, default: null },
    phoneNumber: { type: String, default: null },
    alternative_phoneNumber: { type: String, default: null },
    typeofwater: { type: String, default: null },
    price:{ type: String, default: null },
    capacity: { type: String},
    supplier_address: { type: String, default: null },
    supplier_name : { type: String, default: null },

    // price: {
    //     type: [String], 
    //     default: []
    //   },


});


const tankersbookingSchema = new mongoose.Schema({
    
    customerId: { type: String, default: null },
    tankName:{ type: String, default: null },
    tankLocation:{ type: String, default: null },
    tankerName: { type: String, default: null },
    bookingid: { type: String, default: null,unique: true  },
    supplierId:{type: String, default: null},
    dateOfOrder:   { type: String, default: null },
    expectedDateOfDelivery: { type: String, default: null },
    date:   { type: String, default: null },
    time:   { type: String, default: null },
    typeofwater: { type: String, default: null },
    capacity: { type: String, default: null },
    address: { type: String, default: null },   
    price: { type: String, default: null },
    payment_status :  { type: String, default: "due" },
    orderStatus: { type: String, default: "pending" },
    delivery_agent : { type: String, default: "null" },
    delivery_agent_mobile : { type: String, default: "null" },
    delivery_agent_alternative_mobile : { type: String, default: "null" },
    initial_water_level:{ type: String, default: "null" },
    final_water_level:{ type: String, default: "null" },
    start_time:{ type: String, default: "null" },
    stop_time:{ type: String, default: "null" },
    quantityDelivered: { type: String, default: null},
    amount_paid: { type: String, default: null },
    amount_due: { type: String, default: null },
    distrubance_price: { type: String, default: "none" },
    amount_difference: { type: String, default: "none" },
    payment_mode: { type: String, default: null },
    remarks : { type: String, default: null },
    customerPhone : { type: String, default: null },
    supplierPhone : { type: String, default: null },
    customerName : { type: String, default: null },
    supplierName : { type: String, default: null },
    tankerRunningStatus: { type: String, default: "0" },
    longitude: { type : Number,default: 0.0},
    latitude: {type: Number,default: 0.0},
    deliveredDate: { type: String, default: null },
    distrubance_status: { type: String, default: "0" },
});

const boreSchema = new mongoose.Schema({
    customerId: { type: String, default: null },
    InstallerId: { type: String, default: null },
    boreName: { type: String, default: null },
    capacity: { type: String, default: null },
    typeofwater: { type: String, default: null },
    description: { type: String, default: null },
    

});

const GovtPipeLineSchema = new mongoose.Schema({
    customerId: { type: String, default: null },
    Name: { type: String, default: null },
    capacity: { type: String, default: null },
    typeofwater: { type: String, default: null },
    description: { type: String, default: null },


});

const UserSupplierAccountsSchema = new mongoose.Schema({
    customerId: { type: String, default: null },
    supplierId: { type: String, default: null },
    amount_due: { type: String, default: null },
    amount_paid:{ type: String, default: null },
    amount_advance: { type: String, default: null },
    delivered_tankers: { type: String, default: null },

});



const Tanker = mongoose.model("Tanker", tankersSchema);
const Tankerbooking = mongoose.model("Tankerbooking", tankersbookingSchema);
const Bore = mongoose.model("Bore", boreSchema);
const GovtPipeLine = mongoose.model("GovtPipeLine", GovtPipeLineSchema);
const UserSupplierAccounts = mongoose.model("UserSupplierAccounts", UserSupplierAccountsSchema);


  
// Exporting our model objects
module.exports = {
    Tanker, Tankerbooking,Bore,GovtPipeLine,UserSupplierAccounts
}
