Skip to content

Commit 4d3fcbe

Browse files
committed
user
1 parent 44012f8 commit 4d3fcbe

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

routes/user.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ function ActivityLog(activity_log) {
4545
})
4646
}
4747

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+
4856
Date.prototype.addHours= function(h,m){
4957
this.setHours(this.getHours()+h);
5058
this.setMinutes(this.getMinutes()+m);
@@ -617,8 +625,7 @@ router.post('/book_slot', verifyToken, (req, res, next) => {
617625
// }).catch(error=>{
618626
// console.log(error.response.data)
619627
// })
620-
621-
628+
622629

623630
//Send Mail
624631
// let mailBody = {
@@ -636,6 +643,7 @@ router.post('/book_slot', verifyToken, (req, res, next) => {
636643
// directions:directions,
637644
// sport_name:sport_name,
638645
// }
646+
639647
let mailBody = {
640648
name:values[0].name,
641649
date:moment(values[0].booking_date).format("dddd, MMM Do YYYY"),
@@ -646,12 +654,12 @@ router.post('/book_slot', verifyToken, (req, res, next) => {
646654
booking_id:values[0].booking_id,
647655
slot_time:datetime,
648656
quantity:1,
649-
total_amount:Math.round(result[0].amount),
650-
booking_amount:Math.round(result[0].booking_amount),
657+
total_amount:thousands_separators(Math.round(result[0].amount)),
658+
booking_amount:thousands_separators(Math.round(result[0].booking_amount)),
651659
directions:directions,
652660
sport_name:sport_name,
653-
venue_discount:Math.round(result[0].commission),
654-
coupon_amount:Math.round(result[0].coupon_amount),
661+
venue_discount:thousands_separators(Math.round(result[0].commission)),
662+
coupon_amount:thousands_separators(Math.round(result[0].coupon_amount)),
655663
venue_name:venue.venue.name
656664

657665
}
@@ -1073,7 +1081,7 @@ function isEmpty (object){
10731081
router.post('/cancel_booking/:id', verifyToken, (req, res, next) => {
10741082
Booking.findOne({booking_id:req.params.id}).then(booking=>{
10751083
Venue.findById({_id:booking.venue_id}).then(venue=>{
1076-
Admin.findById({venue:{$in:[booking.venue_id]}}).then(admins=>{
1084+
Admin.find({venue:{$in:[booking.venue_id]}}).then(admins=>{
10771085
if(booking.booking_type === "app" && req.body.refund_status){
10781086
axios.post('https://'+rzp_key+'@api.razorpay.com/v1/payments/'+booking.transaction_id+'/refund')
10791087
.then(response => {
@@ -2179,11 +2187,11 @@ router.post('/event_booking', verifyToken, (req, res, next) => {
21792187
balance:balance,
21802188
manager_name:event.event.organizer,
21812189
booking_id:booking_id,
2182-
coupon_discount:eventBooking.coupon_amount,
2190+
coupon_discount:thousandSeperators(Math.round(eventBooking.coupon_amount)),
21832191
game_type: game_type.toUpperCase(),
21842192
event_discount:0,
21852193
team_name:eventBooking.team_name,
2186-
final_price:amountTobePaid,
2194+
final_price:Math.round(amountTobePaid),
21872195
}
21882196

21892197
let to_emails = `${bookingOrder.event_id.event.email}, rajasekar@turftown.in`

0 commit comments

Comments
 (0)