Bug 621

Summary: Inventory database will not update after checkout procedure
Product: CS3343 2021/09 POS System Reporter: chakfpoon2-c
Component: functionAssignee: chakfpoon2-c
Status: RESOLVED FIXED    
Severity: critical    
Priority: ---    
Version: 0.0.1   
Hardware: PC   
OS: Windows   

Description chakfpoon2-c 2021-11-29 12:05:30 HKT
The inventory database won't update the quantities after the checkout procedure has ended.
================================================================================
Please input your Worker ID for logging in the system...
1
Please input your Member ID for logging in the system...
1234
---Welcome to Morx Supermarket---
---To continue, please proceed your actions---
Input (1) for accessing Inventory System
Input (2) for accessing Checkout System
Input (3) for accessing Sales System
Input (4) for accessing Membership System
Input (5) for switching member
Input (6) to exit
1
---Hi aiden, Welcome to Inventory Management System.---
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
3
Type                          Product Name        Quantity  Marked Price($)/unit
CookingIngredients            Salt                200       20.00     
Drinks                        Coke                1000      10.00     
Food                          candies             400       30.00     
Pharamacy                     Calcium Blocks      200       150.00    
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
4
---To continue, please proceed your actions---
Input (1) for accessing Inventory System
Input (2) for accessing Checkout System
Input (3) for accessing Sales System
Input (4) for accessing Membership System
Input (5) for switching member
Input (6) to exit
2
---Welcome to Checkout System, aiden.---
Input commands for further management:
Input (1) for Checkout
Input (2) for refund
Input (3) for exit
1
No                  Description         Quantity            Price($)            
1                   candies             100                 3000.0              
2                   Calcium Blocks      100                 15000.0             
Please input (0) for proceed to checkout
Please input (1) for remove products
Please input (2) for modify quantities of products
Please input (3) to cancel the checkout process
0
The total amount is: $17100.00
Please Input the amount of dollars that the customers paid
17100
Total changes is $0.00
The Order Reference Number is 2021-11-297
Input commands for further management:
Input (1) for Checkout
Input (2) for refund
Input (3) for exit
3
Exiting...
---To continue, please proceed your actions---
Input (1) for accessing Inventory System
Input (2) for accessing Checkout System
Input (3) for accessing Sales System
Input (4) for accessing Membership System
Input (5) for switching member
Input (6) to exit
1
---Hi aiden, Welcome to Inventory Management System.---
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
3
Type                          Product Name        Quantity  Marked Price($)/unit
CookingIngredients            Salt                200       20.00     
Drinks                        Coke                1000      10.00     
Food                          candies             400       30.00     
Pharamacy                     Calcium Blocks      200       150.00    
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
Comment 1 chakfpoon2-c 2021-11-29 12:11:26 HKT
The problem has been solved by adding a command to delete product quantities after checkout procedure from inventory database.
================================================================================	public Sales confirmSales(Cart c, Member member, String orderRefNo, Employee employee) {
		double sellingPrice = applyDiscount(c.getAllPrice(), member);
		if (member.getMembership() instanceof membership.NonMembership) {
			Sales sales = new Sales(c.getProduct(), c.getQuantity(), LocalDate.now(), employee, c.getAllPrice(),
					sellingPrice, orderRefNo);
			Product product = c.getProduct();
			this.invenDB.deductInventoryofProductsFromQueue(c.getQuantity(), product);
			this.salesDB.add(sales);
			product.addSales(sales);
			return sales;
		}
		MemberSale s = new MemberSale(c.getProduct(), c.getQuantity(), LocalDate.now(), employee, c.getAllPrice(),
				applyDiscount(c.getAllPrice(), member), orderRefNo, member);
		member.addAccumulatedSpending(sellingPrice);
		member.addProductToCompletedCart(c, orderRefNo, s.getSalesCode());
		Product p = c.getProduct();
		this.invenDB.deductInventoryofProductsFromQueue(c.getQuantity(), p);
		this.salesDB.add(s);
		p.addSales((Sales) s);
		return (Sales) s;
	}
================================================================================
Please input your Worker ID for logging in the system...
1
Please input your Member ID for logging in the system...
1234
---Welcome to Morx Supermarket---
---To continue, please proceed your actions---
Input (1) for accessing Inventory System
Input (2) for accessing Checkout System
Input (3) for accessing Sales System
Input (4) for accessing Membership System
Input (5) for switching member
Input (6) to exit
1
---Hi aiden, Welcome to Inventory Management System.---
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
3
Type                          Product Name        Quantity  Marked Price($)/unit
CookingIngredients            Salt                200       20.00     
Drinks                        Coke                1000      10.00     
Food                          candies             400       30.00     
Pharamacy                     Calcium Blocks      200       150.00    
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
4
---To continue, please proceed your actions---
Input (1) for accessing Inventory System
Input (2) for accessing Checkout System
Input (3) for accessing Sales System
Input (4) for accessing Membership System
Input (5) for switching member
Input (6) to exit
2
---Welcome to Checkout System, aiden.---
Input commands for further management:
Input (1) for Checkout
Input (2) for refund
Input (3) for exit
1
No                  Description         Quantity            Price($)            
1                   candies             100                 3000.0              
2                   Calcium Blocks      100                 15000.0             
Please input (0) for proceed to checkout
Please input (1) for remove products
Please input (2) for modify quantities of products
Please input (3) to cancel the checkout process
0
The total amount is: $17100.00
Please Input the amount of dollars that the customers paid
17100
Total changes is $0.00
The Order Reference Number is 2021-11-297
Input commands for further management:
Input (1) for Checkout
Input (2) for refund
Input (3) for exit
3
Exiting...
---To continue, please proceed your actions---
Input (1) for accessing Inventory System
Input (2) for accessing Checkout System
Input (3) for accessing Sales System
Input (4) for accessing Membership System
Input (5) for switching member
Input (6) to exit
1
---Hi aiden, Welcome to Inventory Management System.---
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
3
Type                          Product Name        Quantity  Marked Price($)/unit
CookingIngredients            Salt                200       20.00     
Drinks                        Coke                1000      10.00     
Food                          candies             300       30.00     
Pharamacy                     Calcium Blocks      100       150.00    
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit