Skip to content

Commit 25a4c42

Browse files
committed
ctransaction added in cancel booking with moinor change in schema
1 parent 95b1c6a commit 25a4c42

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

models/transaction.model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const transactionSchema = new Schema(
1212
type:String,
1313
enum: ["credit", "debit"]
1414
},
15-
slot_id:
15+
booking_id:
1616
{
1717
type:Schema.Types.ObjectId,
18-
ref:'Slot',
18+
ref:'Booking',
1919
},
2020
amount:{
2121
type:Schema.Types.Decimal128,

services/booking.service.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const NewBooking = async (bookingBody) => {
4242
type:'debit',
4343
amount:parseFloat(bookingBody.amount),
4444
remarks:'book_slot',
45-
slot_id:slot._id
45+
booking_id:result._id
4646
};
4747
await Transaction.create(transaction);
4848
return result;
@@ -119,8 +119,16 @@ const cancelBooking=async(id)=>
119119
var money=parseFloat(user.money);
120120
money=money+parseFloat(booking.amount/2);
121121
user.money=money;
122+
const transaction={
123+
user_id:user._id,
124+
type:'credit',
125+
amount:parseFloat(booking.amount/2),
126+
remarks:'refund',
127+
booking_id:booking._id
128+
};
129+
await Transaction.create(transaction);
122130
await booking.save();
123-
await user.save();
131+
await user.save();
124132
}
125133
}
126134
}

0 commit comments

Comments
 (0)