/
Stock Variance Posting : Pseudo Code

Stock Variance Posting : Pseudo Code

Pseudocode for Finland Stock Variation postings Custom GL Plugin:

  1. Check if SuiteApp License is valid. If not, exit.

  2. If Transaction Type is ITEM RECEIPT:

    1. if Created From is PURCHASE ORDER:

      1. Run an item search and store asset accounts of items with type assembly, inventory, kit, and item group.

      2. Run an account search and get the Stock Value Variation Account (custrecord_stock_variation_account) for each account.

      3. Get Default Account For Stock Variation Postings (account) by searching for account where Default Account For Stock Variation Postings (custrecord_sta_stockvaluevariation_acct) is TRUE

      4. Get Entity’s Purchases Within Fiscal Year Account (account) by getting the value of Purchases Within Fiscal Year Account from the Entity’s record.

      5. Get Default Account For Purchases Within Fiscal Year (account) by searching for account where Default Account For Purchases Within Fiscal Year (custrecord_default_expenses_within_fy) is TRUE

      6. For each GL line:

        1. Get Debit Amount

        2. Get Account.

        3. Get Line Memo

        4. If Debit Amount > 0 and Account is an asset account and Line Memo is 'Cost of Sales Adjustment'.

          1. Get Class, Department, and Location.

          2. If the Stock Value Variation Account is set for the Account, use this as Stock Variation Account for GL line to be added

          3. Else if the Stock Value Variation Account is not set for the Account, use the Default Account For Stock Variation Postings as Stock Variation Account for GL line to be added.

          4. If Purchases Within Fiscal Year Account is set for the Entity:

            1. Use this as expense account for GL line to be added

            2. Use “Purchases from vendor in accounting period.“ as Debit Memo.

          5. Else

            1. Use Default Account For Purchases Within Fiscal Year as expense account for GL line to be added

            2. Use “Ostot tilikauden aikana.“ as Debit Memo.

          6. Add new custom debit GL line

            1. Set Debit Amount

            2. Set expense account from above

            3. Set Debit Memo from above

            4. Set Class, Department, Location from above

          7. Add new custom credit GL line

            1. Set Credit Amount

            2. Set Account as Stock Variation Account from above

            3. Set Class, Department, Location from above

            4. Set Memo as “Varaston muutos.“

  3. If Transaction Type is VENDOR BILL:

    1. For each line in the item sublist:

      1. Run an item search and store asset accounts of items with type assembly, inventory, kit, and item group.

      2. Run an account search and get the Stock Value Variation Account (custrecord_stock_variation_account) for each account.

      3. Get Default Account For Stock Variation Postings (account) by searching for account where Default Account For Stock Variation Postings (custrecord_sta_stockvaluevariation_acct) is TRUE

      4. Get Entity’s Purchases Within Fiscal Year Account (account) by getting the value of Purchases Within Fiscal Year Account from the Entity’s record.

      5. Get Default Account For Purchases Within Fiscal Year (account) by searching for account where Default Account For Purchases Within Fiscal Year (custrecord_default_expenses_within_fy) is TRUE

      6. For each GL line:

        1. Get Debit Amount

        2. Get Account.

        3. If Debit Amount > 0 and Account is an asset account:

          1. Get Class, Department, and Location

          2. If the Stock Value Variation Account is set for the Account, use this as Stock Variation Account for GL line to be added.

          3. Else if the Stock Value Variation Account is not set for the Account, use the Default Account For Stock Variation Postings as Stock Variation Account for GL line to be added.

          4. If Purchases Within Fiscal Year Account is set for the Entity:

            1. Use this as expense account for GL line to be added

            2. Use “Purchases from vendor in accounting period.“ as Debit Memo.

          5. Else

            1. Use Default Account For Purchases Within Fiscal Year as expense account for GL line to be added

            2. Use “Ostot tilikauden aikana.“ as Debit Memo.

          6. Add new custom debit GL line

            1. Set Debit Amount

            2. Set expense account from above

            3. Set Debit Memo from above

            4. Set Department, Location from above

          7. Add new custom credit GL line

            1. Set Credit Amount

            2. Set Account as Stock Variation Account from above

            3. Set Memo as “Varaston muutos.“

            4. Set Class, Department, Location from above

  4. If Transaction Type is ITEM FULFILLMENT:

    1. If Created From Type is VENDOR RETURN AUTHORIZATION:

      1. Run an account search and get the Stock Value Variation Account (custrecord_stock_variation_account) for each account.

      2. Get Default Account For Stock Variation Postings (account) by searching for account where Default Account For Stock Variation Postings (custrecord_sta_stockvaluevariation_acct) is TRUE

      3. Get Entity’s Purchases Within Fiscal Year Account (account) by getting the value of Purchases Within Fiscal Year Account from the Entity’s record.

      4. Get Default Account For Purchases Within Fiscal Year (account) by searching for account where Default Account For Purchases Within Fiscal Year (custrecord_default_expenses_within_fy) is TRUE

      5. For each GL line:

        1. Get Credit Amount

        2. Get Debit Amount

        3. Get Line Memo

        4. If Credit Amount > 0 and Line Memo is “Cost of Sales Adjustment“:

          1. Get Class, Department, Location

          2. Get Account

          3. f the Stock Value Variation Account is set for the Account, use this as Stock Variation Account for GL line to be added.

          4. Else if the Stock Value Variation Account is not set for the Account, use the Default Account For Stock Variation Postings as Stock Variation Account for GL line to be added.

          5. If Purchases Within Fiscal Year Account is set for the Entity:

            1. Use this as expense account for GL line to be added

            2. Use “Purchases from vendor in accounting period.“ as Debit Memo.

          6. Else

            1. Use Default Account For Purchases Within Fiscal Year as expense account for GL line to be added

            2. Use “Ostot tilikauden aikana.“ as Debit Memo.

          7. Add new custom debit GL line

            1. Set Debit Amount

            2. Set Account as Stock Variation Account from above

            3. Set Debit Memo from above

            4. Set Class, Department, Location from above

          8. Add new custom credit GL line

            1. Set Credit Amount

            2. Set Account as expense account from above

            3. Set Memo as “Varaston muutos.“

            4. Set Class, Department, Location from above

  5. If Transaction Type is WORK ORDER ISSUE;

    1. For each GL line:

      1. Get Credit Amount

      2. If Credit Amount > 0:

        1. Get Class, Department, Location

        2. Get Account

        3. Get Default Account For Stock Variation Postings (account) by searching for account where Default Account For Stock Variation Postings (custrecord_sta_stockvaluevariation_acct) is TRUE

        4. Get Default Account For WIP VARIANCE (account) by searching for account where Default Account For WIP Variance (custrecord_default_wip_variance_account) is TRUE

        5. f the Stock Value Variation Account is set for the Account, use this as Stock Variation Account for GL line to be added.

        6. Else if the Stock Value Variation Account is not set for the Account, use the Default Account For Stock Variation Postings as Stock Variation Account for GL line to be added.

        7. Add new custom debit GL line

          1. Set Debit Amount

          2. Set Account as Stock Variation Account from above

          3. Set Debit Memo as “Stock variation of raw materials.“

          4. Set Class, Department, Location from above

        8. Add new custom credit GL line

          1. Set Credit Amount

          2. Set Account as Default Account For WIP VARIANCE

          3. Set Memo as “WIP Stock variation.“

          4. Set Class, Department, Location from above

  6. If Transaction Type is WORK ORDER COMPLETION:

    1. Run an item search and store asset accounts of items with type assembly, inventory, kit, and item group.

    2. For each GL line:

      1. Get Debit Amount

      2. Get Account

      3. If Debit Amount > 0 and Account is an asset account

        1. Get Class, Department, Location

        2. Get Default Account For Stock Variation Postings (account) by searching for account where Default Account For Stock Variation Postings (custrecord_sta_stockvaluevariation_acct) is TRUE

        3. Get Default Account For WIP VARIANCE (account) by searching for account where Default Account For WIP Variance (custrecord_default_wip_variance_account) is TRUE

        4. f the Stock Value Variation Account is set for the Account, use this as Stock Variation Account for GL line to be added.

        5. Else if the Stock Value Variation Account is not set for the Account, use the Default Account For Stock Variation Postings as Stock Variation Account for GL line to be added.

        6. Add new custom debit GL line

          1. Set Debit Amount

          2. Set Account as Default Account For WIP VARIANCE

          3. Set Debit Memo as “Stock variation of WIP .“

          4. Set Class, Department, Location from above

        7. Add new custom credit GL line

          1. Set Credit Amount

          2. Set Account as Stock Variation Account from above

          3. Set Memo as “Stock variation of finished goods“

          4. Set Class, Department, Location from above

 

Related content