Showing
2 changed files
with
7 additions
and
3 deletions
| ... | @@ -12,9 +12,10 @@ const TakeMedicineHistorySchema = new Schema ({ | ... | @@ -12,9 +12,10 @@ const TakeMedicineHistorySchema = new Schema ({ |
| 12 | ref : 'BottleMedicine', | 12 | ref : 'BottleMedicine', |
| 13 | required : true, | 13 | required : true, |
| 14 | }, | 14 | }, |
| 15 | - temperature : { type : Number, default : 0 }, | 15 | + temperature : { type : Number, default : 0, }, |
| 16 | - humidity : { type : Number, default : 0 }, | 16 | + humidity : { type : Number, default : 0, }, |
| 17 | - dosage : { type : Number, default : 0 }, | 17 | + dosage : { type : Number, default : 0, }, |
| 18 | + balance : { type : Number, default : 0, }, | ||
| 18 | }); | 19 | }); |
| 19 | 20 | ||
| 20 | 21 | ... | ... |
| ... | @@ -59,11 +59,14 @@ const bottleInfoUpdate = async(data) => { | ... | @@ -59,11 +59,14 @@ const bottleInfoUpdate = async(data) => { |
| 59 | const dosage = Math.round((lastTotalWeight - totalWeight) / parseFloat(eachWeight)); | 59 | const dosage = Math.round((lastTotalWeight - totalWeight) / parseFloat(eachWeight)); |
| 60 | 60 | ||
| 61 | if(dosage > 0) { | 61 | if(dosage > 0) { |
| 62 | + const balance = Math.round(totalWeight / parseFloat(eachWeight)); | ||
| 63 | + | ||
| 62 | const takeMedicineHist = new TakeMedicineHist({ | 64 | const takeMedicineHist = new TakeMedicineHist({ |
| 63 | bmId : bottleMedicine._id, | 65 | bmId : bottleMedicine._id, |
| 64 | temperature, | 66 | temperature, |
| 65 | humidity, | 67 | humidity, |
| 66 | dosage, | 68 | dosage, |
| 69 | + balance, | ||
| 67 | }); | 70 | }); |
| 68 | await takeMedicineHist.save(); | 71 | await takeMedicineHist.save(); |
| 69 | } | 72 | } | ... | ... |
-
Please register or login to post a comment