const mongoose = require('mongoose');

const ticketSchema = new mongoose.Schema({
    sessionId: Number,
    transactionNo: String,
    paymentType: Number,
    issueTime: Date,
    currencyCode: String,
    totalCent: Number,
    total: Number,
    itemNumber: Number,
    reason: Object,
    discount: Object,
    taxData: Object,
    taxQrCode: String,
    invoiceId: String,
    items: [{
        productId: Number,
        prodName: String,
        prodNameTranslate: String,
        price: Number,
        priceCent: Number,
        vatRate: Number,
        quantity: Number,
        returnTicket: Boolean,
        ticketExpiryTime: Date,

        baggage: Number,
        priceBaggage: Number,
        baggageReturn: Number,

        riderExternalId: Number,
        riderName: String,
        origStop: String,
        origStopTranslate: String,
        destStop: String,
        destStopTranslate: String,
        origStopCode: String,
        destStopCode: String,
        origStationCode: String,
        destStationCode: String,
        routeId: Number,
        route: String,
        routeTranslated: String,
        fareItemCategory: String,
        tripId: String,
        routeIntercityId: String,
        zoneTraveled: Number,
        hotlisted: Boolean,

        accountId: String,
        accountNo: String,
        accountName: String,

        cardVersion: Number,
        cardUid: String,
        cardholderId: String,

        penaltyRefNumber: String,

        reservationCartId: String,
        reservationPassengerId: String,
        reservationJourneyId: String,
        reservationPassengerName: String,
        reservationPassengerPhoneNumber: String,
        reservationPassengerSeat: String,
        reservationBusStationFromTime: Date,
        reservationBusStationToTime: Date,
        reservationPassenger: Object,
        reservationDiscount: Object,
        reservationBaggage: Array,

        qrCode: String
    }]
});

const financialTransactionSchema = new mongoose.Schema({
    employeeId: String,
    sessionId: Number,
    transactionTime: Date,
    activityType: String,
    issuedFormatType: String,

    riderExternalId: Number,
    riderName: String,
    anonimusLuggage: String,
    numberOfPassengers: Number,

    fareItemIssuedNumber: Number,
    farePrice: Number,
    currencyCode: String,
    farePriceCurrency: Number,
    paymentMethod: String,
    paymentInstrument: String,
    cardTransactionNo: String,

    fareItemExternalId: Number,
    fareItemName: String,
    fareItemType: String,
    fareItemCategory: String,

    fareAdjustment: Object,

    ticketId: String,
    ticketItemId: String,

    prodName: String,
    productType: String,
    accountNo: String,

    cardVersion: Number,
    cardUid: String,
    cardholderId: String,

    penaltyRefNumber: String,

    waybillName: String,
    waybillNameTranslated: String
});

const organizationsSchema = new mongoose.Schema({
    organizationId: String,
    organizationName: String,
    organizationTypes: Array,
    vatNumber: String,
    businessName: String
});

const Ticket = mongoose.model('Ticket', ticketSchema);

const FinancialTransaction = mongoose.model('FinancialTransaction', financialTransactionSchema);

const Organizations = mongoose.model('Organizations', organizationsSchema);

module.exports = {
    Ticket,
    FinancialTransaction,
    Organizations
};
