I'm developing a Billing Software for maintaining daily records. I'm using PyGTk(for UI) and MongoDB(NoSQL) database. I'm storing record of each bill in following format
{
"_id" : ObjectId("5b83f95a3859201d46385779"),
"date" : "27/08/2018",
"bill_number" : 7,
"bill_amount" : 85,
"payment_mode" : "Cash",
"bill_content" : [
{
"item_code" : 1,
"item_name" : "abc",
"item_count" : 1
},
{
"item_code" : 2,
"item_name" : "xyz",
"item_count" : 2
}
]
}
{
"_id" : ObjectId("5b83f95f3859201d4638577b"),
"date" : "27/08/2018",
"bill_number" : 8,
"bill_amount" : 125,
"payment_mode" : "Card",
"bill_content" : [
{
"item_code" : 3,
"item_name" : "xyz",
"item_count" : 2
},
{
"item_code" : 2,
"item_name" : "abc",
"item_count" : 1
}
]
}
{
"_id" : ObjectId("5b83f95f3859201d4638577b"),
"date" : "27/08/2018",
"bill_number" : 8,
"bill_amount" : 125,
"payment_mode" : "Online",
"bill_content" : [
{
"item_code" : 3,
"item_name" : "abc",
"item_count" : 1
},
{
"item_code" : 2,
"item_name" : "xyz",
"item_count" : 3
},
{
"item_code" : 1,
"item_name" : "pqr",
"item_count" : 1
}
]
}
I want the following things from the records:
- Daily Total Amount
- Sum of amount grouped by payment mode
- Count of each Item on daily basis(if possible)
Sample output
{
'date':'27/08/2018',
'total_amount': 335,
'payment_mode': [{'Cash': 85},{'Card': 125}, 'Online': 125],
'item_count': [{'abc':3},{'xyz':5},{'pqr':1}]
}
I'm new to NoSQL hence can't figure out to do all the things in one query. Please tell me if it's possible or not or if there's any better way to store the records.