Overview
Runcitworks is the inventory management part of Quicktrack. It handles purchases, sales, expenses , products and work with said information to provide assets, current balances, and performance.
Runcitworks initially started out as a Excel Spreadsheet. All the calculation was done based on my research online. I am unable to confirm if this system conforms to account etiquette and practices, but so far this system has worked for me.
Architecture
Runcitworks is compromised of monthdata(s). A month data stores information about the month, including month, purchases, sales, previous_balances, expenses, products, starting_modal, cashout and profit_balance.
purchases, sales, previous_balances are based on the Transaction declaration, which includes date, product, quantity, unit_price, monthdata. expenses is very similar of Transaction, but instead of description, it uses product instead.
Provided these information, more complicated calculations can be performed. For example, assets is the total amount of everything not yet sold:
assets = totalPreviousBalance + totalPurchase + totalProfit - totalSale
However, it is a bit more complicated, since the amount sold includes the earning, we do need to substract it as well. On top of that, totalPurchase is a lost of all purchase within this month, and so it does not account for the balances left over from the previous month. That said, we will need totalPreviousBalance to account for that as well.
We can also calculate the performance of a product like so:
productPerformance = amountSold * productProfitPerItem
Again, in reality, it's a bit more complicated. To calculate the profit per item, we would need to loop through every single item sold, aggregate the amount (unit_price * quantity) then divide again by quantity. In the end, the code will look something like this:
productPerformance = (totalSoldAmount / totalSoldQuantity) - (totalBoughtAmount + totalPrevBalAmount) / (totalBoughtQuantity / totalPrevBalQuantity)
Not included is also function calls that goes through all Transaction and add them up. theses are grouped as getXByProduct() calls:
// ...
return {
// ...
accumulateAllTransactions, // base function
getTotalBoughtByProduct, // quantity bought
getTotalSoldByProduct, // quantity sold
getPreviousBalanceByProduct, // quantity previous bal
getCurrentBalanceByProduct, // current balance
calculateCurrentBalance, // for CashFlow.vue
getTotalPurchaseByProduct, // amount bought
getTotalSaleByProduct, // amount sold
getTotalPreviousBalanceValueByProduct, // amount prev bal
getPurchaseUnitPrice, // amount bought / quantity bought
getSaleUnitPrice, // amount sold / quantity sold
calculateProductPerformance, // profit per product
calculateAssets, // assets, $ of things left
}
This provides very useful information about the state of the business. In this case, I use it to sell some things here and there, and has provided useful data for me to work with.
State Management
Client state management is dealt with using global state. In this project, pinia is used, as it provided useful features at the time when Vue-3 was just freshly out of release-candidate, such as support for Composition API, it's modular design which allowed separation of concerns, along with built-in Typescript support.
Known Issues
Other than potential code optimization, one known issue about the system is floating-point precision error. One potential remedy is the utilization of BigNumber.js, which I've used in my other project Quicktrack Lite. I have lost my 50-cent precision after 3 months of use.