Variables Value Change According to “Ready To Pick”

In my implementation, Ready To Pick works as a signaling mechanism to let other module know when they could access the sub data in current module. As I working with Ready To Pick function previously, there is new implementation to add on upon clicks on Ready To Pick button.

First of all, in order to press “Ready To Pick” or “Undo Ready To Pick”, we will select a data/item set for example. In this item set, there is multiple list of item will it’s own attributes. Given availableItem and standbyItem as item’s attributes, new implementation is to alter value of attributes by incrementing or decrementing the value upon status of isReadyToPick (bool). Implementation must alter all the value for each item available in item set adding/subtracting itemQuantity.

i) Clicking “Ready To Pick” button when isReadyToPick = false, would change it to true and alter attributes value such as below:
foreach (item in itemSet)
{
item.availableItem -= item.itemQuantity;
item.standbyItem += item.itemQuantity;
}


ii) Clicking “Ready To Pick” button when isReadyToPick = true, would change it to false and alter attributes value such as below:
foreach (item in itemSet)
{
item.availableItem += item.itemQuantity;
item.standbyItem -= item.itemQuantity;
}

To avoid infinite increment or decrement, implementation is done in a transaction, to make sure the logic rollback if there is error. By using transaction, all value changes for isReadyToPick(bool), availableItem(int), standbyItem(int), itemQuantity(int) will be reverted upon any update failure.

Few tests is done to assert value change of availableItem(int), standbyItem (int). Tests assertion pass after “Ready To Pick” button is triggered, the value of attributes add or subtract value of itemQuantity.

After the implementation done, I shall continue implementation logic for situation when item.availableItem -= item.itemQuantity appears to be negative value.

Leave a Reply