Calculation Function
Posted: 2020-04-07 17:52
I am using the ledger demo for a project, and there is function I am having issues with regarding the calculation of the balance.
The current transaction balance hook is coded like this:
*/
$postive_transactions = "'Incoming'";
/* get sum of all item transactions and update item balance */
if($item){
$item_balance = sqlValue("select sum(if(transaction_type in ({$postive_transactions}), quantity, -1 * quantity)) from transactions where item={$item}");
sql("update items set balance='{$item_balance}' where id={$item}", $eo);
I need the drop down to apply these three logic:
Option 1) Incoming - the quantity will add to the balance
option 2) Burned - the quantity will delete from the balance
Option 3) Outgoing - the quantity will do nothing.
Any help would be great!!!
The current transaction balance hook is coded like this:
*/
$postive_transactions = "'Incoming'";
/* get sum of all item transactions and update item balance */
if($item){
$item_balance = sqlValue("select sum(if(transaction_type in ({$postive_transactions}), quantity, -1 * quantity)) from transactions where item={$item}");
sql("update items set balance='{$item_balance}' where id={$item}", $eo);
I need the drop down to apply these three logic:
Option 1) Incoming - the quantity will add to the balance
option 2) Burned - the quantity will delete from the balance
Option 3) Outgoing - the quantity will do nothing.
Any help would be great!!!