Complete guide to adding, viewing, updating, and managing inventory items for Sales Managers and Salespersons
The Inventory Management system provides real-time synchronization between managers and their sales team, ensuring everyone has up-to-date information on product availability and sales performance.
Each inventory item contains the following information:
public class InventoryItem { private String itemName; private int total_available; // Total quantity available private int sold; // Quantity sold private int profit; // Profit per unit public InventoryItem(String itemName, int total_available, int sold, int profit) { this.itemName = itemName; this.total_available = total_available; this.sold = sold; this.profit = profit; }}
Source: InventoryItem.java:1-42
The profit field represents the profit margin per unit sold, not the total profit. Total profit is calculated as sold * profit.
Managers can add new products to the inventory, which automatically propagates to all salespersons on their team.
1
Access Add Item Dialog
From the Manager dashboard, tap the floating action button (FAB) in the bottom-right corner.
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Show dialog to add item }});
Source: ManagerMain.java:114-117
2
Enter Item Details
In the dialog, provide:
Item Name: Product name or SKU
Quantity: Initial available quantity
Profit per Unit: Profit margin for each item sold
The quantity picker uses a MeterView component for easy number selection.
3
Validate and Save
The system validates all fields are filled:
String item = itemName.getText().toString();String q1 = String.valueOf(q.getValue());int profitAmount = Integer.parseInt(profit.getText().toString());if(TextUtils.isEmpty(item) || TextUtils.isEmpty(q1)) { Toast.makeText(getApplicationContext(), "Please fill all the details!", Toast.LENGTH_LONG).show();} else { int quant = Integer.parseInt(q1); it = new InventoryItem(item, quant, 0, profitAmount); String key = databaseRef.child(id).child("Inventory").push().getKey(); databaseRef.child(id).child("Inventory").child(key).setValue(it);}
Source: ManagerMain.java:137-152
4
Auto-Distribution to Team
The item is automatically added to all salespersons under this manager:
Salespersons log sales through an intuitive dialog:
1
Open Selling Dialog
Tap the floating action button on the Salesperson dashboard:
fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<String> itemlist = getItemList(id, role); // Show selling dialog }});
Source: SalespersonMain.java:93-97
2
Select Item and Quantity
The dialog provides:
AutoCompleteTextView: Search and select from available items
MeterView: Set quantity sold
final AutoCompleteTextView autoCompleteTextView;final MeterView numberPicker;ArrayAdapter<String> adapter = new ArrayAdapter<String>( mView.getContext(), R.layout.support_simple_spinner_dropdown_item, itemlist);autoCompleteTextView.setThreshold(1);autoCompleteTextView.setAdapter(adapter);
Source: SalespersonMain.java:107-110
3
Validation
The system validates the sale:
sold = numberPicker.getValue();final String itemName = autoCompleteTextView.getText().toString();if(TextUtils.isEmpty(itemName) || sold == 0) { Toast.makeText(getApplicationContext(), "Please fill all the details!", Toast.LENGTH_LONG).show();}// Check if sold quantity exceeds availableif(it1.getTotal_available() < sold) { Toast.makeText(getApplicationContext(), "Sold can't be greater than items remaining!", Toast.LENGTH_LONG).show(); sold = 0;}
Source: SalespersonMain.java:166-169
4
Update Inventory
The sale updates multiple locations:1. Salesperson’s sold count:
InventoryItem it = new InventoryItem( itemName, it1.getTotal_available(), sold + it1.getSold(), // Add to existing sold it1.getProfit());databaseReference1.child(id).child("Inventory") .child(snapshot1.getKey()).setValue(it);
Source: SalespersonMain.java:171-1722. Manager’s sold count:
InventoryItem itNew = new InventoryItem( itemName, it1.getTotal_available(), it1.getSold() + sold, // Increment manager's sold it1.getProfit());databaseReference.child(snapshot.getKey()) .child("Inventory").child(snapshot1.getKey()).setValue(itNew);
Source: SalespersonMain.java:342-3433. All team members’ available quantity:
InventoryItem it = new InventoryItem( itemName, it1.getTotal_available() - sold, // Reduce available for all it1.getSold(), it1.getProfit());