@@ -37,6 +37,9 @@ const Venue = require('../models/venue');
3737const Admin = require ( '../models/admin' ) ;
3838const Ads = require ( '../models/ads' )
3939const rzp_key = require ( '../scripts/rzp' )
40+ const indianRupeeComma = ( value ) => {
41+ return value . toLocaleString ( 'EN-IN' ) ;
42+ }
4043
4144function ActivityLog ( activity_log ) {
4245 let user = activity_log . user_type === "user" ?User :Admin
@@ -45,14 +48,6 @@ function ActivityLog(activity_log) {
4548 } )
4649}
4750
48- function thousands_separators ( num )
49- {
50- let num_parts = num . toString ( ) . split ( "." ) ;
51- num_parts [ 0 ] = num_parts [ 0 ] . replace ( / \B (? = ( \d { 3 } ) + (? ! \d ) ) / g, "," ) ;
52- return num_parts . join ( "." ) ;
53- }
54-
55-
5651Date . prototype . addHours = function ( h , m ) {
5752 this . setHours ( this . getHours ( ) + h ) ;
5853 this . setMinutes ( this . getMinutes ( ) + m ) ;
@@ -625,7 +620,8 @@ router.post('/book_slot', verifyToken, (req, res, next) => {
625620 // }).catch(error=>{
626621 // console.log(error.response.data)
627622 // })
628-
623+
624+
629625
630626 //Send Mail
631627 // let mailBody = {
@@ -643,7 +639,12 @@ router.post('/book_slot', verifyToken, (req, res, next) => {
643639 // directions:directions,
644640 // sport_name:sport_name,
645641 // }
646-
642+ function thousands_separators ( num )
643+ {
644+ let num_parts = num . toString ( ) . split ( "." ) ;
645+ num_parts [ 0 ] = num_parts [ 0 ] . replace ( / \B (? = ( \d { 3 } ) + (? ! \d ) ) / g, "," ) ;
646+ return num_parts . join ( "." ) ;
647+ }
647648 let mailBody = {
648649 name :values [ 0 ] . name ,
649650 date :moment ( values [ 0 ] . booking_date ) . format ( "dddd, MMM Do YYYY" ) ,
@@ -654,12 +655,12 @@ router.post('/book_slot', verifyToken, (req, res, next) => {
654655 booking_id :values [ 0 ] . booking_id ,
655656 slot_time :datetime ,
656657 quantity :1 ,
657- total_amount :thousands_separators ( Math . round ( result [ 0 ] . amount ) ) ,
658- booking_amount :thousands_separators ( Math . round ( result [ 0 ] . booking_amount ) ) ,
658+ total_amount :indianRupeeComma ( Math . round ( result [ 0 ] . amount ) ) ,
659+ booking_amount :indianRupeeComma ( Math . round ( result [ 0 ] . booking_amount ) ) ,
659660 directions :directions ,
660661 sport_name :sport_name ,
661- venue_discount :thousands_separators ( Math . round ( result [ 0 ] . commission ) ) ,
662- coupon_amount :thousands_separators ( Math . round ( result [ 0 ] . coupon_amount ) ) ,
662+ venue_discount :indianRupeeComma ( Math . round ( result [ 0 ] . commission ) ) ,
663+ coupon_amount :indianRupeeComma ( Math . round ( result [ 0 ] . coupon_amount ) ) ,
663664 venue_name :venue . venue . name
664665
665666 }
@@ -1081,7 +1082,7 @@ function isEmpty (object){
10811082router . post ( '/cancel_booking/:id' , verifyToken , ( req , res , next ) => {
10821083 Booking . findOne ( { booking_id :req . params . id } ) . then ( booking => {
10831084 Venue . findById ( { _id :booking . venue_id } ) . then ( venue => {
1084- Admin . find ( { venue :{ $in :[ booking . venue_id ] } } ) . then ( admins => {
1085+ Admin . findById ( { venue :{ $in :[ booking . venue_id ] } } ) . then ( admins => {
10851086 if ( booking . booking_type === "app" && req . body . refund_status ) {
10861087 axios . post ( 'https://' + rzp_key + '@api.razorpay.com/v1/payments/' + booking . transaction_id + '/refund' )
10871088 . then ( response => {
@@ -2187,11 +2188,11 @@ router.post('/event_booking', verifyToken, (req, res, next) => {
21872188 balance :balance ,
21882189 manager_name :event . event . organizer ,
21892190 booking_id :booking_id ,
2190- coupon_discount :thousandSeperators ( Math . round ( eventBooking . coupon_amount ) ) ,
2191+ coupon_discount :eventBooking . coupon_amount ,
21912192 game_type : game_type . toUpperCase ( ) ,
21922193 event_discount :0 ,
21932194 team_name :eventBooking . team_name ,
2194- final_price :Math . round ( amountTobePaid ) ,
2195+ final_price :amountTobePaid ,
21952196 }
21962197
21972198 let to_emails = `${ bookingOrder . event_id . event . email } , rajasekar@turftown.in`
0 commit comments