Integrate an inventory system
The Xero API provides a couple of options for developers to integrate an inventory/stock system with Xero. The "Accounting for Inventory" method is for apps that want to manage inventory items completely on their side and only send transactions into Xero to track accounting movements.
Choose this option if your app already provides inventory functionality which is not compatible with the inventory business rules in Xero.
- A current asset (CURRENT) account to record stock on hand is necessary. Do NOT choose an account type of 'INVENTORY' - this is a special system account type for Xero inventory functionality. To add this account use the Accounts endpoint. Consider having more than one stock asset account if you want to distinguish between different stock lines on your balance sheet.
- We also need a Cost of Goods Sold account so we can show this expense on our profit and loss. We can add this the same way as above as an EXPENSE account type.
- If we are selling products then typically we want to show our Sales less Cost of Goods sold on our Profit and Loss report. Xero provides great flexibility with reporting layouts so we can easily adjust the default layout of our Profit and Loss report to move the cost of goods sold expense up to be included in the Gross Profit calculation.
To do this, go to Reports > All Reports > Profit and Loss. Scroll to the bottom of the report and choose "Layout Options" and then "Create new Layout".
Tick the selection box to the left of your "Cost of Goods Sold" account and choose "Move selected accounts" at the top of the screen. Choose "Less Cost of Sales" in the drop down list shown in the popup window and choose "OK". Type a name in the "Layout Name" such as "My Profit and Loss". Choose "Save" at the bottom of the page. Your Profit and Loss report will now show the Cost of Goods Sold in the correct place.
When we make stock purchases we can code the purchases to the Stock on hand account or alternate asset account we have setup for this.
Cost of Goods Sold (COGS)
Every time we make a sale we can reduce the asset value of stock on hand and increase our cost of goods sold. You may choose to do this for every sale or in batch once a day, week or month. Since Xero receives daily information from your bank we recommend to update your COGS every day so that your reports are as accurate as possible whenever viewed.
We can enter a zero total accounts payable invoice (similar to posting a journal) to show the reduction of stock on hand and recording the cost of goods sold. Create an invoice through the API using the Invoices endpoint.
In the example below I sold a widget for $1000 which only cost me $600 so I need to reduce my stock on hand by $600 and increase my cost of goods sold by $600.
Below is an example of a Profit and Loss that has a customised layout to show our cost of goods sold as part of our Gross Profit figure.
After our stock adjustment our Balance sheet is updated to reflect the change to our stock on hand.