Further Improvement of the Accept Command for Stock Take

In this week, the accept command of the stock take was further improve on. Firstly, the command will get both the existing item list with the line item for the stock take. From there, the algorithm will compare both the existing item and the new line item. After that, it will update the quantity to the new quantity. The item with zero quantity will automatically be remove from the existing.

Next, I need to rework the function which will update the item list. First, I need to change the parameter that it takes to a list. From there, I need to rework the logic so that I can take the list as the input and update all items at once. Moving on from there, I need to ensure that the update function transaction only run once after being called.

Lastly, I need to change the logic for the updating the existing and matching item so that the last checked date and the last checked by property will match the one in the stock take itself. I then need to do the unit testing to ensure that everything is working fine and as intended. I also completed the testing for most of the logic of the accept command.

Dealing with Minor Bugs Before Start Testing

After patching the new updates to the system, I had new tasks for this week which were mostly focused on fixing the unnecessary re-rendering. Fixing minor bugs across the system and editing some style with the assistance of a real device as opposed to emulator. and encountering  new issues in the Decimal text box component.

I began debugging the code to fix the re-rendering bug by focusing on the Pick and Pack views, where it was primarily occurring. Initially, I attempted to create a render counter that counts each time a render occurred, which was really useful. It demonstrates that whenever the Data is requested from the API, it is rendered twice. Thanks to Mr. Peter’s explanation, I see now that it was due to an unnecessary application of useState; replacing it with useRef resolved the issue.

Afterwards, I fixed a few issues that were occurring in unpack view. I added the implementation of the error message for scanning the incorrect item and made sure it doesn’t interfere with the existing functionality. In addition, the Focus implementation in other views was not functioning while mounting, and also I managed to get that fixed.

As usual, no work week can pass without some Focus implementation challenges being encountered. After extensive experience with all sorts of errors encountered while implementing the focus in various ways. Nonetheless, I ran into another logic issue with the focus implementation, this time in the Decimal Text Box component.

To wind things up, I was successful this week in fixing a few minor problems, as well as one significant one, such as the render bug. Next, fix the focus bug in the Decimal component before beginning the testing tasks for the upcoming week.

Successful Update

This week’s efforts have been concentrated on perfecting the focus feature and putting it into action. I was introduced to a new type of react native hooks, and the old logic was discarded in favor of the new. By the end of the week, the update had been successfully patched, and the overall result was encouraging.

Fixing last week’s bugs and running through all of the scripts to make sure the focus moves from one box to another as intended, was where I started this week. In addition, after consulting with Mr. Peter and digging into the code, we realize that using Boolean to implement the focus is problematic and leaves behind obvious problems. To that end, he advised that I study the useReducer hook and try to execute the focus with it.

Following that, I gained an understanding of the useReducer concept, structure and implementation, which is typically utilized for complex state logic. However, I met some difficulties to apply the focus implementation in the reducer because we are using a separate component so that was more complex than I expected.

Next, Mr. Peter devised the optimal solution by implementing the focus in a function using ref and invoking it. Compared to the previous usage of a timer that was unpredictable or a boolean that was producing bugs, calling one function by passing the box ref only was far more efficient.

Lastly, after implementing the new solution on every screen, I had to modify the keyboard toggle logic to operate well with the text box focus. I also altered the styles a bit to make the content fit more with the device. And with my supervisor’s confirmation on the current version so I eventually patched the update successfully with all improvements and bugs addressed.

Implementation of the Stock Take Command

After finishing up the logic of the update command and doing the unit testing as well, I moved on to the accept command. The accept command involve a few logic where the accept command will take the list of item in stock take and compare it to the existing item location and update the stock quantity. To ensure that the process of updating the stock quantity of the item location is not executed properly, the entire logic is put inside of transaction so that any error that occurred will roll back any changes made.

Next, in order to compare the item in stock take and existing item location, an algorithm was needed. After doing some research online, I found LINQ to be somewhat suitable for the job. Then, I tried to implement the LINQ and tested it out and it worked. During the testing of the accept command, I encounter an error where another transaction was being created while the first transaction was still going on. After discussing with Mr. Peter, I was able to fix the error.

Lastly, after some discussion with Mr. Peter regarding the logic of the accept command, I needed change it so that the update process can be done much more faster. I also needed to stress test the LINQ algorithm to see how long it will take for the algorithm process a large amount of data.

Incomplete Upgrade

In order to effectively upgrade the application version this week, it was necessary to resolve all bugs associated with the new text box component. New difficulties prevented me from completing the task, and the outcome did not meet expectations.

First, I encountered a new problem in an old component that is mostly used for selecting the quantity option. The defect is that the quantity value accepts only the auto value. In addition, I spent time resolving the error in which I replaced OnChangeText with SetQuantity. The idea sounded successful at first, until I realised that it could not be tested. Therefore, I had to look for a different approach that could be tested.

After that, it was necessary for me to configure the newly added reusable component on each screen that makes use of it. This is where I ran into issues; the focus has been adjusted and is  totally dependent on the timer. But in the code, it was completely sloppy causing distractions. Furthermore, I needed to refactor all the related code from the beginning to find the desirable outcome. So, the current usage of It is depending on user interactions with the system.

This week, I ensured that every screen is compatible with the new component. However, this does not indicate that everything is perfect, as there is always a failure when a negative event occurs. I tried my best to make it function before the end of the week, but I was unsuccessful. Therefore, my main task is to update the incorrect scenario script and ensure that all displays follow the same coding sequence.

Further Development of The Stock Take Feature

In this week, I managed to complete the create command of the stock take API. Moving on to the next part, I managed to finish the update and delete command together with the queries as well. In the delete command, the command will take the stock take id as an input. A unit test was done to ensure that the delete command was working properly.

After that, the queries for the stock take was either query to get the list of stock take or get the stock take by the id. Similarly, unit test was also made for the queries as well. In the get stock take list query, the stock take will have an item count to show to the user how many there are in the stock take. While, get stock take by id will have the list of item display with it.

Lastly, the logic of the update command was rework again after discussing with Mr.Peter. The rework was to ensure that every time the stock take item is updated that it wouldn’t crash the software. Currently, I’m still working on the reworking the logic of the update command, After that is done, I only have the accept command left for the stock take.

The Reusable Controlled TextBox

This week, I have mostly concentrated on fixing last week’s issues and cleaning out redundant and unnecessary lines of code. The keyboard toggle, specifically the focusing function, was mostly affected by a bug last week. Consequently, it was my responsibility to ensure that focus functions properly and smoothly as required.

First, the focus functions was separated for each text box and connected with its reference, and the usage of them were very unorder and not following certain sequence. Moreover, the submit functions holds unwanted codes that may just make conflicts and make it harder to understand and maintenance. Therefore, creating the reusable keyboard toggle component solved the issue but unfortunately the focusing function still not addressed.

Subsequently, in an effort to resolve the issue, I attempted many times to alter the logic, but to no effect. Mr. Peter provided me with an additional solution to this issue by combining the textbox and keyboard toggle into a single component. Fortunately, after several testing and tweaks, everything ultimately worked as planned.

In the end, this week was helpful for me in a different way because I was able to make a new component and combine two existing components into a reusable one. Making the set ups and configuring the props gave me more understandability,  which will allow me to make faster decisions while dealing with the code.

Implementation of Stock Take Feature

After finishing the stock feature of the sandbox application, I was assigned to create the stock take feature next. Inside the stock take feature will have the create, update, delete and accepted commands together with the get stock take list and get stock take by id queries. The first thing that I need to work on was the create the entity relationship diagram (ERD).

After finalizing the ERD, I moved on to creating the API of the stock take. The part that I am currently working on is the create stock take command. After figuring out what the user need to input for the create command, I moved on to the create command handler. After completing the command handler, I moved on to the validation and the response of the command.

Next, I created the unit testing for the create command and tested out the POST method of the create command. After running the test, the test resulted in a bad gateway result. Then I went to debug the code itself. After sometime, I found out that in the create command handler there was a null exception when I tried to map the child class of the stock take. Currently I am working on trying to resolve the bug.