TuGo API Forums

General

RSS Feed

Calculating Sales Tax

    • matt
    • Topic created 8 years ago

    If I get a quote for a PL-SPCK-2 policy for an Ontario resident, the quote includes an Ontario tax priceItem in addition to the premium priceItem of $92.

    When I try to purchase this policy your system returns an error saying it expects a payment of 107.31. I don't know how your system arrives at that number.

    I know that we need to collect sales tax. Provincial tax in Ontario is 8% and HST is 13%. Neither of those tax rates gives a total price of 107.31.

    92.00 + 8% = 99.36  
    92 + 13% = 103.96
    92 + ? = 107.31
    

    What am I missing?

    Message edited by matt 8 years ago

  1. Ken Lum8 years ago

    Hi Matt,

    Did you double-check that you provided the same inputs for both quoting and purchasing?

    Also, can you post all the requests that you used to arrive at the error message expecting $107.31?

  2. matt8 years ago

    There's an example quote, purchase request and response below.

    The quote returned by your system has premium=129, tax=0, planCost=129 But it also has a priceItem {'code':'PM-TAX-1'...} indicating 8% tax will be charged. When there is a priceItem {... 'type'='TAX' ...} shouldn't tax!=0?

    I can ignore the tax=0 bit and calculate the tax anyway. But I still don't get the total your system is expecting even if I ignore the fact that tax=0 and add 8% tax as per the priceItem {'code':'PM_TAX-1'...}

    Here's a quote:

    { "planCode": "PL-SPCK-2", "planName": "Freedom - All Inclusive - Single Trip", "planType": "SINGLE", "personId": "WS-PERSON-1416938932544-1548", "premium": 92, "tax": 0, "planCost": 92, "baseRatePriceItem": { "code": "RS2032883", "name": "Freedom - All Inclusive - Single Trip, v7", "inputClass": "RATE", "amount": 92 }, "priceItems": [ { "code": "SUMP", "name": "Sum Insured Before Dept - 0 to 10000 w\\/1400", "type": "SUMP", "inputClass": "FACTOR", "value": 1000 }, { "code": "MINIMUM", "name": "Minimum", "inputClass": "MINIMUM" }, { "code": "PM-TAX-1", "name": "Tax - Ontario 8%", "type": "TAX", "inputClass": "TAX", "value": 1 }, { "code": "RS2032883", "name": "Freedom - All Inclusive - Single Trip, v7", "inputClass": "RATE", "amount": 92 }, { "code": "TRIP", "name": "Trip Length Range [1, 5, 10, 17, 24, 31, 38, 46, 53-60]", "type": "TRIP", "inputClass": "FACTOR", "value": 5 } ] }

    Here's an attempt to purchase that quote:

    { "policyInfo": {

          },
          "trip": {
            "startDate": "2014-12-01",
            "endDate": "2014-12-05",
            "departureProvince": "ON",
            "cost": 2000,
            "bookingDate": "2014-11-25"
          },
          "insuredPersons": [
            {
              "insuredType": "CANADIAN",
              "inHomeProvince": true,
              "homeProvince": "ON",
              "selectedPlans": [
                {
                  "planCode": "PL-SPCK-2",
                  "priceInputParameters": [
                    {
                      "code": "PM-TAX-1",
                      "value": 1
                    }
                  ]
                }
              ],
              "firstName": "Tester",
              "lastName": "Northman",
              "birthDate": "1990-02-06",
              "phoneNumbers": [
                {
                  "number": "6138648513"
                }
              ],
              "addresses": [
                {
                  "addressLine1": "123 Main St",
                  "city": "Ottawa",
                  "country": "CA",
                  "province": "ON",
                  "postalCode": "K2C 4G2",
                  "type": "MAIL"
                }
              ]
            }
          ],
          "payments": [
            {
              "amount": 129,
              "transactionType": "PURCHASE",
              "paymentStatus": "APPROVED",
              "paymentType": "COLLECTED",
              "paymentMethod": "SINGLE",
              "currencyCode": "CAD"
            }
          ]
        }
    

    Here's the response from your system:

    { "key": "sales.app.error.ivalid.payment.amount", "type": "ERROR", "summarykey": "sales.app.error.ivalid.payment.amount.summary", "summaryMessage": "!sales.app.error.ivalid.payment.amount.summary!", "detailMessage": "Oops, invalid payment amount. Your payment is $129.00, but the expected amount is $150.47.", "sourceType": "MSG_BUNDLE", "catalogName": "tu.venture.domain.messages.sales.i18n.SalesResources", "params": [ "129.00", "150.47" ] }

    I don't know where the $150.47 comes from. It's not $129 + 8% and it's not $129 + 13%.

  3. Clyde8 years ago

    Hi Matt,

    There seems be a couple items that need clarfication.

    1. PriceItems such as taxes and surcharges do not have to be explicitly applied. The webservice will automatically apply the appropriate taxes based on the trip's departure province or can be overwrittened with the insuredPerson's homeProvince. Taxes being applied will also depend if taxes are applicable to the plan (not all plans are taxable).

    When you were trying to purchase the policy, what was happening is the ontario tax was being applied twice. Once implicitly by the webservice and the second time explicitly through the priceItems list. Hence the 129 + 8% + 8% = 150.47.

    2.A very important thing to know when getting a quote is knowing the difference between the "plansToPrice" and "selectedPlans" list for an insuredPerson. The plansToPrice list is the playground where you can customize plans. These plans get reflected in the quoting response in the availiable plans list. If no plans are specified for the insured in the plansToPrice list than all plans will be returned in the availablePlans, you may apply filters(ex. tripType=SINGLE get all single trip plans) in the quoting request to filter plans.

    Once you want to buy a plan for an insured than you place the plan in the selectedPlans list. These plans get returned in the quoting response in selectedPlans. The selectedPlans has a totalCost attribute which is used as the payment amount to purchase the policy. Another important thing to know is that plans in the selected plans list have taxes and surcharges applied where taxes are NOT applied to the plans in the plansToPrice list.

    3.When purchasing the policy the selectedPlans list in the quoting request should look exactly the same as the selectedPlans for the policy request. Otherwise there can be a pricing difference when buying a policy.

    I'll supply a couple of samples if this helps.

  4. Clyde8 years ago

    Quoting Request

    {
    "productLineCode":"PR-FDM-1",
    "trip":{
        "startDate":"2014-12-1", 
        "endDate":"2014-12-05",
        "departureProvince" : "ON",
        "cost" : "2000",
        "bookingDate": "2014-11-25"
    }, 
    "insuredPersons":[
        { 
            "insuredType" : "CANADIAN",
            "birthDate":"1990-02-06",
            "plansToPrice" : [
                {
                    "planCode" : "PL-SPCK-2",
                    "priceInputParameters":[]
                }
            ],
            "selectedPlans" : [
                {
                    "planCode" : "PL-SPCK-2",
                    "priceInputParameters":[]
                }
            ]
        }
    ]
    

    }

  5. Clyde8 years ago

    Policy Request

    { 
    "policyInfo":{
     },
     "trip": {
       "startDate": "2014-12-01",
       "endDate": "2014-12-05",
       "departureProvince":"ON",
       "cost": 2000,
       "bookingDate": "2014-11-25"
     },
     "insuredPersons": [
       {
         "insuredType": "CANADIAN",
         "inHomeProvince": true,
         "homeProvince": "ON",
         "selectedPlans": [
           {
             "planCode": "PL-SPCK-2",
             "priceInputParameters": []
           }
         ],
         "firstName": "Tester",
         "lastName": "Northman",
         "birthDate": "1990-02-06",
         "phoneNumbers": [
           {
             "number": "6138648513"
           }
         ],
         "addresses": [
           {
             "addressLine1": "123 Main St",
             "city": "Ottawa",
             "country": "CA",
             "province": "ON",
             "postalCode": "K2C 4G2",
             "type": "MAIL"
           }
         ]
       }
     ],
     "payments": [
       {
         "amount": 139.32,
         "transactionType": "PURCHASE",
         "paymentType": "COLLECTED",
         "paymentMethod": "SINGLE",
         "currencyCode": "CAD"
       }
         ]
    

    }

  6. Clyde8 years ago

    Hi Matt,

    Perhaps a reference to one of our insurance applications would help. You may access our test environment through the following url :

    https://uat-shop.travelunderwriters.com/store/TESTFGM

    The application mainly leverages the quotes and policies endpoints and I believe will provide a good working sample.

    Clyde,

  7. matt8 years ago

    Hi Clyde,

    I see now how to use plansToPrice. That's helpful.

    I now understand your system doesn't want to receive priceInputParameters if they relate to tax. But the example in the documentation shows that I am supposed to include priceInputParameters if they relate to a deductible.

    So some priceInput's get included and some do not. How do I determine which ones to include?

    It feels like I'm missing some documentation. Where do you describe the non-intuitive stuff like "don't send tax priceItems but do send deductible priceItem's"? I've read the documentation that I have access to. I see an example request/response for each service and a list of class members with brief explanations. There is no explanation, for instance, of the significance of the different types of priceItems or how your system uses them. The same is true of the various other classes.

    Your quote has tax=0 even when taxes are charged on the policy. Why is that? Your documentation seems to say this field should be the tax charged on the policy.

    Also, I don't see how your system can charge sales tax twice. That should violate a business rule (or several).

[ Page 1 of 1 ]