Calculation Function

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
utony
Veteran Member
Posts: 93
Joined: 2020-04-03 18:37

Calculation Function

Post by utony » 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!!!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Calculation Function

Post by pbottcher » 2020-04-08 21:23

Hi,

can you please explain what ledger demo you use?
Where is that code from?

Which dropdown are you refering to?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply