Open pulkitsinghal opened 8 years ago
[1:35 PM] Brandon Lehman: Glitch in fulfillment: [1:37 PM] Brandon Lehman: So, @pulkit, after removing via "Delete" button in Fulfillment, looking at items in box, then going back to remaining items; all deleted items are back in "remaining".
@elbrando - here is the rough script to start deleting reports:
// (1) remove the relevant lineitems based on report name which STARTS_WITH_THIS_PREFIX
db.getCollection('ReportModel')
.find({
name: {$regex: /^STARTS_WITH_THIS_PREFIX/i}
})
.forEach(function(elem){
//printjson(elem);
print(
'before delete, total # of lineitems for "' + elem.name + '": ' +
db.getCollection('StockOrderLineitemModel').count({"reportId":elem._id})
)
db.getCollection('StockOrderLineitemModel').remove({"reportId":elem._id});
print(
'after delete, total # of lineitems for "' + elem.name + '": ' +
db.getCollection('StockOrderLineitemModel').count({"reportId":elem._id})
)
});
// (2) remove the report itself which STARTS_WITH_THIS_PREFIX
db.getCollection('ReportModel')
.remove({
name: {$regex: /^STARTS_WITH_THIS_PREFIX/i}
});
If you want to remove by id
then instead of matching on:
name: {$regex: /^STARTS_WITH_THIS_PREFIX/i}
... just match on:
_id: ObjectId('YOUR_REPORT_ID')
You can also substitute name: {$exists:false}
to find all reports that do NOT have a name and just get rid of them and their corresponding lineitems. We can run this together if you'd like.
Ran this for you via robomongo:
// (1)
db.getCollection('ReportModel')
.find({
name: {$exists:false}
})
.forEach(function(row){
//printjson(row);
print(
'before delete, total # of lineitems for "' + row.name + '": ' +
db.getCollection('StockOrderLineitemModel').count({"reportId":row._id})
)
db.getCollection('StockOrderLineitemModel').remove({"reportId":row._id});
print(
'after delete, total # of lineitems for "' + row.name + '": ' +
db.getCollection('StockOrderLineitemModel').count({"reportId":row._id})
)
});
// (2)
db.getCollection('ReportModel')
.remove({
name: {$exists:false}
});
@elbrando - adding your comments here:
[Aug-3 9:05 AM] Brandon Lehman: 1) addon products to existing order. 2) separate supplies order. Newish UI methodology. This is for future reference
[9:11 AM] Brandon Lehman: 2 notes from receiving: 1) Tracking "variance" 2) Clerk login per store (clerks do most of stocking shipment)
These are in no particular order:
Show more...
mechanism ... they should be sorted such that the latest ones are on top.Order Id
column, please use theYYYY-MM-DD
format to show the date (created at)New Orders
In Process
?