× FreshBooks App Logo
FreshBooks
Official App
Free - Google Play
Get it
You're currently on our US site. Select your regional site here:

Accounting API For Reporting Other Income

Modern businesses have endless ways of selling their products and services. They can generate sales on e-commerce platforms like Shopify and Etsy, through events and fairs, or through renting out space. Layer in the fact that people use multiple external payment hubs (like Stripe or Square), and you can quickly see how many different income sources a business will need to keep track of! Reporting other income allows businesses to provide accurate information for their accountants, and provides a complete picture of the health of their business. This data can be sent to FreshBooks using the Other Income API by posting the payments information.

Use-Case For Developers: Reporting Other Income

Imagine we have a seller who uses Square as his/her payment solution and FreshBooks for accounting. To have a complete picture in FreshBooks, reporting other income is the business owners priority!

Things you would need for this are:

  1. A Square Developer account: to mock transactions and play with Square APIs
  2. A FreshBooks account: to create a FreshBooks application and  to interact with the FreshBooks Other Income API

Playing With The Square API

First, we need to create an application in Square’s sandbox so that we can interact with the Square sandbox APIs.

Now we’ll perform a transaction in the Square sandbox environment. For this, we’ll use Square’s virtual terminal  to create a single transaction in Square; we’ll use cash as the payment method.

We are all here for the APIā€™s, so let’s get to it.

First, letā€™s get the Location in Square using the Location API.


Response:

{
  "locations": [
    {
      "id": "LJTC8CXDWK7KB",
      "name": "Default Test Account",
      "address": {
        "address_line_1": "1600 Pennsylvania Ave NW",
        "locality": "Washington",
        "administrative_district_level_1": "DC",
        "postal_code": "20500",
        "country": "US"
      },
      "timezone": "UTC",
      "capabilities": [
        "CREDIT_CARD_PROCESSING"
      ],
      "status": "ACTIVE",
      "created_at": "2021-02-08T13:15:58Z",
      "merchant_id": "<merchant_Id>",
      "country": "US",
      "language_code": "en-US",
      "currency": "USD",
      "business_name": "Default Test Account",
      "type": "PHYSICAL",
      "business_hours": {},
      "mcc": "7299"
    }
  ]
}


Next, we’ll will use the Order API and provide the location_id retrieved above to list the transaction.

Response

{
   "orders":[
      {
         "id":"DiaFNDn9v8jGL5xe7sm1qaIwna4F",
         "location_id":"LJTC8CXDWK7KB",
         "line_items":[
            {
               "uid":"18a16546-ce36-9c67-0921-1efdc7308639",
               "catalog_object_id":"XSF26EWURHOUW33TOYFPII6R",
               "quantity":"1",
               "name":"Solar Panel",
               "variation_name":"Regular",
               "base_price_money":{
                  "amount":100000,
                  "currency":"USD"
               },
               "gross_sales_money":{
                  "amount":100000,
                  "currency":"USD"
               },
               "total_tax_money":{
                  "amount":19643,
                  "currency":"USD"
               },
               "total_discount_money":{
                  "amount":0,
                  "currency":"USD"
               },
               "total_money":{
                  "amount":108929,
                  "currency":"USD"
               },
               "variation_total_price_money":{
                  "amount":100000,
                  "currency":"USD"
               },
               "applied_taxes":[
                  {
                     "uid":"36a475cc-aeec-a769-6822-941cd9459343",
                     "tax_uid":"b6543b98-8325-7961-ecc5-9ad60fd28eef",
                     "applied_money":{
                        "amount":8929,
                        "currency":"USD"
                     }
                  },
                  {
                     "uid":"35e4f83d-2a3f-2806-015b-3d6a6e26e972",
                     "tax_uid":"09d17b21-b00d-67b1-4917-230345163503",
                     "applied_money":{
                        "amount":10714,
                        "currency":"USD"
                     }
                  }
               ]
            }
         ],
         "taxes":[
            {
               "uid":"b6543b98-8325-7961-ecc5-9ad60fd28eef",
               "catalog_object_id":"QPOVJECN3X4TX6BUR4NLCWOF",
               "name":"GST",
               "percentage":"10.0",
               "type":"ADDITIVE",
               "applied_money":{
                  "amount":8929,
                  "currency":"USD"
               },
               "scope":"LINE_ITEM"
            },
            {
               "uid":"09d17b21-b00d-67b1-4917-230345163503",
               "catalog_object_id":"MJDI6VCHNWFARQ2TJWRNYECB",
               "name":"Product inclusive",
               "percentage":"12.0",
               "type":"INCLUSIVE",
               "applied_money":{
                  "amount":10714,
                  "currency":"USD"
               },
               "scope":"LINE_ITEM"
            }
         ],
         "created_at":"2021-04-22T11:42:05.181Z",
         "updated_at":"2021-04-22T11:42:07.000Z",
         "state":"COMPLETED",
         "version":4,
         "total_tax_money":{
            "amount":19643,
            "currency":"USD"
         },
         "total_discount_money":{
            "amount":0,
            "currency":"USD"
         },
         "total_tip_money":{
            "amount":0,
            "currency":"USD"
         },
         "total_money":{
            "amount":108929,
            "currency":"USD"
         },
         "closed_at":"2021-04-22T11:42:05.754Z",
         "tenders":[
            {
               "id":"DDL1cYyTXgPIJhdZYzDQXEwRrvKZY",
               "location_id":"LJTC8CXDWK7KB",
               "transaction_id":"DiaFNDn9v8jGL5xe7sm1qaIwna4F",
               "created_at":"2021-04-22T11:42:05Z",
               "amount_money":{
                  "amount":108929,
                  "currency":"USD"
               },
               "type":"CASH",
               "cash_details":{
                  "buyer_tendered_money":{
                     "amount":108929,
                     "currency":"USD"
                  },
                  "change_back_money":{
                     "amount":0,
                     "currency":"USD"
                  }
               },
               "payment_id":"DDL1cYyTXgPIJhdZYzDQXEwRrvKZY"
            }
         ],
         "total_service_charge_money":{
            "amount":0,
            "currency":"USD"
         },
         "net_amounts":{
            "total_money":{
               "amount":108929,
               "currency":"USD"
            },
            "tax_money":{
               "amount":19643,
               "currency":"USD"
            },
            "discount_money":{
               "amount":0,
               "currency":"USD"
            },
            "tip_money":{
               "amount":0,
               "currency":"USD"
            },
            "service_charge_money":{
               "amount":0,
               "currency":"USD"
            }
         },
         "source":{
            "name":"Sandbox for sq0idp-4Uw2-7Sy15Umdnct7FTeuQ"
         }
      }
   ],
   "cursor":"tttttttttt"
}

Reporting Other Income With The FreshBooks Other Income API

To quickly get started with FreshBooks, you will need to log in or signup for a FreshBooks Developer account and then create an app on the developer page. You will then need to authenticate yourself on the FreshBooks API. If you donā€™t know-how, we got you covered, go check out our OAuth authentication tutorial.

Now, we need to create the request body of the message. For this, we need to answer 3 main questions.

  1. What date did the transaction take place?

  2. What was the total amount of the transaction (including taxes)?

  3. What was each tax category and the amount applicable?

In our case letā€™s answer these questions by looking first at the response message from Square.

  1. $.orders.created_at is 2021-04-22T11:42:05.181Z

  2. $.orders.total_money is 108929,USD (Note it is $1089.29)

  3. $.orders.taxes is GST(10%) and PIC(12%) 

Itā€™s time to use the FreshBooks Other Income API to post this information into FreshBooks.

Letā€™s take a look at our curl request

curl -L -X POST 'https://api.freshbooks.com/accounting/account//other_incomes/other_incomes' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ' \
--data-raw '{
  "other_income":{
    "amount":{
      "amount":"1089.29",
      "code":"USD"
    },
    "category_name":"online_sales",
    "date":"2021-04-24",
    "note":null,
    "payment_type":"cash",
    "source":"Square",
    "userid":null,
    "taxes":[
      {
        "name":"PIT",
        "amount":"107.14"
      },
      {
        "name":"GST",
        "amount":"89.29"
      }
    ]
  }
}'


You can now find these entries under the other income section of your FreshBooks account.

Need Inspiration For Your Next App?

We can’t stress how important it is for businesses to report other sources of income, That’s why at FreshBooks, we have created an app called Income Importer which connects to popular other income channels like Square, Stripe and Etsy.Ā 

We have customers who would like to sync their FreshBooks accounts with platforms like PayPal, IntegraPay, Ecwid, LawPay, Amazon, BigCommerce, eBay, and PinPayments. Are you a developer who can help solve this? Get in touch with us, or develop your own integration and get it listed on our app store.

Still, have questions? Something isn’t working? Don’t hesitate to reach out to newapi@freshbooks.com.

We’ll respond to your request as quickly as we can!