server/src/Entity/booking.js
/**
    * Method to create a booking for the subscription plan.
    * @param subscriptionID: The subscription plan id.
    * @param amount: The total amount for the subscription.
    * @param transactionId: The transaction id.
    * @returns {Promise<Number|Object>}: The booking id, else error.
    */
Method to create a booking for the subscription plan.
@param subscriptionID: The subscription plan id.
@param amount: The total amount for the subscription.
@param transactionId: The transaction id.
@returns {Promise}: The booking id, else error.
Method to create a booking for the subscription plan . @param subscriptionID : The subscription plan id . @param amount : The total amount for the subscription . @param transactionId : The transaction id . @returns { Promise } : The booking id else error .
createSubscriptionBooking(subscriptionID, amount, transactionId) {
      return new Promise((resolve, reject) => {
         database.runSp(constants.SP_HANDLE_BOOKING, [constants.BOOKING_TYPE_SUBSCRIPTION, this._customerId, subscriptionID,
            0, 0, amount, generator.generateCurrentDateOnly(), '', '', '', 0, '', 0, 0]).then(async _resultSet => {
            try {
               const result = _resultSet[0][0];
               if (validators.validateUndefined(result) && result.id > 0) {
                  this._bookingId = result.id;
                  await this._createPaymentForBooking(transactionId, amount);
                  resolve(result);
               } else {
                  resolve({id: -1});
               }
            } catch (e) {
               printer.printError(e);
               reject(e);
            }
         }).catch(err => {
            printer.printError(err);
            reject(err);
         });
      });
   }
createSubscriptionBooking ( subscriptionID , amount , transactionId ) { return new Promise ( ( resolve , reject ) => { database . runSp ( constants . SP_HANDLE_BOOKING , [ constants . BOOKING_TYPE_SUBSCRIPTION , this . _customerId , subscriptionID , 0 , 0 , amount , generator . generateCurrentDateOnly ( ) , '' , '' , '' , 0 , '' , 0 , 0 ] ) . then ( async _resultSet => { try { const result = _resultSet [ 0 ] [ 0 ] ; if ( validators . validateUndefined ( result ) && result . id > 0 ) { this . _bookingId = result . id ; await this . _createPaymentForBooking ( transactionId , amount ) ; resolve ( result ) ; } else { resolve ( { id : - 1 } ) ; } } catch ( e ) { printer . printError ( e ) ; reject ( e ) ; } } ) . catch ( err => { printer . printError ( err ) ; reject ( err ) ; } ) ; } ) ; }
Method to create a booking for the subscription plan.
Method to create a booking for the subscription plan .