How to update Credit Account balance

ZoranZoran Member Posts: 8

I am working for a customer on a procedure that needs to reset Credit Account balance. Following code ignores creditAccountID and does not update balance at CreditAccount.

What am I missing? Thank you.

url: https://api.lightspeedapp.com/API/Account/<UserAccountID>/Sale.json

Body:{

 "employeeID": "1",

 "registerID": "3",

 "shopID": "1",

 "customerID": "1",

 "completed": "true"

 "SaleLines": {

   "SaleLine": {

     "itemID": "0",

     "note": "test reset CA balance",

     "unitQuantity": "1",

     "unitPrice": "-1.13",

     "taxClassID": "0",

     "avgCost": "0",

     "fifoCost": "0"

   }

 },

 "SalePayments": {

   "SalePayment": {

     "amount": "-1.13",

     "paymentTypeID": "11",

     "creditAccountID": "1"

   }

 }

}

This ignores creditAccountID

"paymentTypeID": "11" is custom paymentType.

If I use "paymentTypeID": "4" it works fine.

Answers

  • LeahLeah Moderator, Lightspeed Staff Posts: 219 moderator

    Hi Zoran,

    You need to use the payment type 'credit account' (in this case '4') to apply a deposit to a credit account with the API. This is similar to the workflow in the UI, where after you add a misc item with a negative amount to a sale in order to credit the customer account, when you click on 'Payment,' you need to use type 'Account' to credit the amount to the account. If you use a different type, it's as if you're refunding to that type, not the account.

    This is not made explicit in the documentation, so I will update it to make it more clear.

    API Support
    Lightspeed HQ
  • ZoranZoran Member Posts: 8

    Hi Leah,

    Thank you for the answer. I will have to play with what I have.

    I will use paymentTypeID=4 to balance out the credits, but I will need to save a note to mark this 'balancing' process.

    The code above (with paymentTypeID=4) works , but the "note" is not saved. Can you help me figure out why.

    Or, if you have a suggestion on how to mark payments done by this 'Reset Credit Account Balance' procedure.

    Thank you

  • LeahLeah Moderator, Lightspeed Staff Posts: 219 moderator

    The answer to your question is likely found here: https://developers.lightspeedhq.com/retail/tutorials/salenotes/

    If that doesn't help, could you explain your workflow and end goal in a bit more detail so I can advise? Thanks!

    API Support
    Lightspeed HQ
  • ZoranZoran Member Posts: 8

    Thank you Leah,

    Let me try this and I'll get back to you.

    Zoran

  • ZoranZoran Member Posts: 8

    Hello Lea,

    I found a way to get the result I wanted.

    Thank you,

    Zoran

  • ZoranZoran Member Posts: 8

    Hi Lea,

    I was convinced I got it, but I was wrong. Back to drawing board...

    The code works, but the outcome is not what I need. Took a while to understand it. This is the story:

    The environment is a school. Students and employees have a monthly limit that needs to be reset every month. The code I put together resets the CreditAccount balance. It also creates a sale that resets Account balance and this is a problem.

    The actual payments are done through another system, not Lightspeed.

    This is the code:

    {

     "employeeID": "1",

     "registerID": "3",

     "shopID": "1",

     "customerID": "1",

     "completed": "true",

     "Customer": {

       "customerID": "1",

       "creditAccountID": "1"

     },

     "SaleLines": {

       "SaleLine": {

         "itemID": "0",

         "unitQuantity": "1",

         "unitPrice": "-38.14",

         "taxClassID": "0",

         "avgCost": "0",

         "fifoCost": "0",

         "Note": {

           "note": "MONTH END STATEMENT TRANSFER",

           "isPublic": "false"

         }

       }

     },

     "SalePayments": {

       "SalePayment": {

         "amount": "-38.14",

         "paymentTypeID": "4",

         "creditAccountID": "1"

       }

     }

    }


    I tried removing "SaleLines" section, but it didn't work.

    Do you have a suggestion?

    Thanks,

    Zoran

Sign In or Register to comment.