You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
db.query(`UPDATE ${TYPE==='B' ? Tables.ORDERS : Tables.NON_BSCS_ORDERS} SET ${data}, ${OrderColumns.EDIT_DATE} = NOW() WHERE id = ?`,[value,ID],(error,results)=>{
503
-
// If has an error
504
-
if(error){
505
-
Log.e(error.message);
506
-
callback(ErrorTypes.DB_ERROR);
507
-
return;
508
-
}
510
+
// If has an error
511
+
if(error===ErrorTypes.DB_ERROR){
512
+
Log.e(`Student #${order?.student_id}: Error getting order while updating stock number`,true);
513
+
update();
514
+
return;
515
+
}
509
516
510
-
// If no results
511
-
if(results.affectedRows===0){
512
-
callback(ErrorTypes.DB_EMPTY_RESULT);
513
-
return;
514
-
}
517
+
// If no results
518
+
if(error===ErrorTypes.DB_EMPTY_RESULT){
519
+
Log.e(`Student #${order?.student_id}: Error getting order while updating stock number because order #${id} not found!`,true);
Log.w(`Student #${order?.student_id}: Product has no stock while decrementing stock`,true);
592
+
// Callback error
593
+
callback(ErrorTypes.DB_PRODUCT_NO_STOCK);
594
+
});
595
+
596
+
return;
597
+
}
598
+
599
+
// Otherwise, just return success
600
+
update();
601
+
});
602
+
603
+
return;
604
+
}
605
+
606
+
functionupdate(){
607
+
// Query the database
608
+
db.query(`UPDATE ${TYPE==='B' ? Tables.ORDERS : Tables.NON_BSCS_ORDERS} SET ${data}, ${OrderColumns.EDIT_DATE} = NOW() WHERE id = ?`,[value,ID],(error,results)=>{
609
+
// If has an error
610
+
if(error){
611
+
Log.e(error.message);
612
+
callback(ErrorTypes.DB_ERROR);
613
+
return;
614
+
}
615
+
616
+
// If no results
617
+
if(results.affectedRows===0){
618
+
callback(ErrorTypes.DB_EMPTY_RESULT);
619
+
return;
620
+
}
621
+
622
+
// Otherwise, return success
623
+
callback(null,getDatestamp());
624
+
});
625
+
}
626
+
627
+
// Otherwise, call update
628
+
update();
519
629
}
520
630
521
631
/**
@@ -648,14 +758,14 @@ export class Order extends DatabaseModel {
0 commit comments