File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments