server/src/Entity/booking.js
/**
    * Method to create the booking for the service without subscription.
    * @param vendorID: The vendorID
    * @param amount: The amount of booking.
    * @param bookingDate: The booking date.
    * @param bookingEndDate
    * @param bookingTime: The booking time.
    * @param bookingEndTime: The end time of the booking.
    * @param addressId: The address of the customer.
    * @param remarks: The booking remarks.
    * @param breedId
    * @param recurringBookings: The array containing the recurring dates and time.
    * @returns {Promise<Object>}: The booking id.
    */
Method to create the booking for the service without subscription.
@param vendorID: The vendorID
@param amount: The amount of booking.
@param bookingDate: The booking date.
@param bookingEndDate
@param bookingTime: The booking time.
@param bookingEndTime: The end time of the booking.
@param addressId: The address of the customer.
@param remarks: The booking remarks.
@param breedId
@param recurringBookings: The array containing the recurring dates and time.
@returns {Promise}: The booking id.
Method to create the booking for the service without subscription . @param vendorID : The vendorID @param amount : The amount of booking . @param bookingDate : The booking date . @param bookingEndDate @param bookingTime : The booking time . @param bookingEndTime : The end time of the booking . @param addressId : The address of the customer . @param remarks : The booking remarks . @param breedId @param recurringBookings : The array containing the recurring dates and time . @returns { Promise } : The booking id .
createServiceBooking(vendorID, amount, bookingDate, bookingEndDate,
                        bookingTime, bookingEndTime, addressId, remarks, breedId, recurringBookings) {
      return new Promise((resolve, reject) => {
         database.runSp(constants.SP_HANDLE_BOOKING, [constants.BOOKING_TYPE_SERVICE, this._customerId,
            0, this._serviceId, vendorID, amount, bookingDate,
            validators.validateUndefined(bookingEndDate) ? bookingEndDate : bookingDate,
            bookingTime, bookingEndTime, addressId,
            validators.validateNumber(breedId) ? breedId : 0,
            validators.validateString(remarks) ? remarks : "",
            0, 0]).then(async _resultSet => {
            try {
               const result = _resultSet[0][0];
               if (validators.validateUndefined(result) && result.id > 0) {
                  this._bookingId = result.id;
                  await this._notifyVendor(vendorID);
                  if (validators.validateUndefined(recurringBookings) && recurringBookings.length > 0) {
                     let recurringDates = [];
                     let recurringTimes = [];
                     let recurringEndTimes = [];
                     recurringBookings.forEach(oneBooking => {
                        recurringDates.push(oneBooking[constants.BOOKING_DATE]);
                        recurringTimes.push(oneBooking[constants.BOOKING_TIME]);
                        recurringEndTimes.push(oneBooking[constants.BOOKING_END_TIME]);
                     });
                     database.runSp(constants.SP_STORE_RECURRING_BOOKING, [recurringDates.join(","),
                        recurringTimes.join(","), recurringEndTimes.join(","), this._bookingId]).then(async _resultSet => {
                        const result = _resultSet[0][0];
                        resolve(result);
                     }).catch(err => {
                        printer.printError(err);
                        reject(err);
                     });
                  } else {
                     resolve(result);
                  }
               } else {
                  resolve({id: -1});
               }
            } catch (e) {
               printer.printError(e);
               reject(e);
            }
         }).catch(err => {
            printer.printError(err);
            reject(err);
         });
      });
   }
createServiceBooking ( vendorID , amount , bookingDate , bookingEndDate , bookingTime , bookingEndTime , addressId , remarks , breedId , recurringBookings ) { return new Promise ( ( resolve , reject ) => { database . runSp ( constants . SP_HANDLE_BOOKING , [ constants . BOOKING_TYPE_SERVICE , this . _customerId , 0 , this . _serviceId , vendorID , amount , bookingDate , validators . validateUndefined ( bookingEndDate ) ? bookingEndDate : bookingDate , bookingTime , bookingEndTime , addressId , validators . validateNumber ( breedId ) ? breedId : 0 , validators . validateString ( remarks ) ? remarks : "" , 0 , 0 ] ) . then ( async _resultSet => { try { const result = _resultSet [ 0 ] [ 0 ] ; if ( validators . validateUndefined ( result ) && result . id > 0 ) { this . _bookingId = result . id ; await this . _notifyVendor ( vendorID ) ; if ( validators . validateUndefined ( recurringBookings ) && recurringBookings . length > 0 ) { let recurringDates = [ ] ; let recurringTimes = [ ] ; let recurringEndTimes = [ ] ; recurringBookings . forEach ( oneBooking => { recurringDates . push ( oneBooking [ constants . BOOKING_DATE ] ) ; recurringTimes . push ( oneBooking [ constants . BOOKING_TIME ] ) ; recurringEndTimes . push ( oneBooking [ constants . BOOKING_END_TIME ] ) ; } ) ; database . runSp ( constants . SP_STORE_RECURRING_BOOKING , [ recurringDates . join ( "," ) , recurringTimes . join ( "," ) , recurringEndTimes . join ( "," ) , this . _bookingId ] ) . then ( async _resultSet => { const result = _resultSet [ 0 ] [ 0 ] ; resolve ( result ) ; } ) . catch ( err => { printer . printError ( err ) ; reject ( err ) ; } ) ; } else { resolve ( result ) ; } } else { resolve ( { id : - 1 } ) ; } } catch ( e ) { printer . printError ( e ) ; reject ( e ) ; } } ) . catch ( err => { printer . printError ( err ) ; reject ( err ) ; } ) ; } ) ; }
Method to create the booking for the service without subscription.
Method to create the booking for the service without subscription .
//await this._createPaymentForBooking(transactionId, amount);