Jump to content

sales_estimate post API


 Share

Recommended Posts

Hello Team, 

 
I am trying to integrate the Sage APIs but getting following error when trying to hit the sales_estimates API to create an sales estimate
 
Request - 
 
{
   "sales_estimate": {
   "expiry_date": "2022-04-04",
   "date": "2022-01-04",
   "contact_id": "182d1e41e3c14dcea94b2552beb17c1d",
   "estimate_lines": [
      {
      "unit_price": 150.00,
      "quantity": 100.00,
      "product_id": "a6726f4a4c9744e5adbe214552acce3c",
      "ledger_account_id": "c19b3f6cb00511ecb8b206dd2e485c2e",
      "discount_percentage": 10,
      "description": "Test OLI Product"
      }
   ]
   }
}
 
Response --
 
[
   {
      "$severity": "error",
      "$dataCode": "RecordInvalid",
      "$message": "translation missing: en.no key",
      "$source": "base"
   }
]
 
However, when I tried to insert the contacts and products then it worked but it was giving an error for sales_estimates only. Request you to please let me know if there is something which I am missing as part of my request.
 
I am using my trial developer business account with the email id [email protected].
 
If it is gonna be a quick fix then I request you to please consider this on priority because I have an important demo for tomorrow.
Link to comment
Share on other sites

  • Administrators

Hi Raman,

So I've reviewed the body content, and its missing both a tax rate and tax rate id:

 

{
   "sales_estimate": {
       "expiry_date": "2022-04-04",
       "date": "2022-01-04",
       "contact_id": "85b732ca9cda4c28ac580aa2c21c01e2",
       "estimate_lines": [
           {
               "unit_price": 150.00,
               "quantity": 100.00,
               "product_id": "92b7697e4a9211e797950a57719b2edb",
               "ledger_account_id": "bf15fce94a9111e797950a57719b2edb",
               "discount_percentage": 10,
               "description": "Test OLI Product",
               "tax_rate": "20",
               "tax_rate_id": "GB_STANDARD"
           }
       ]
   }
}

We are looking to make some updates to our API reference, as these are required fields and not marked as such - my apologies for this!

The error you are receiving isn't one I've seen before, but if you can first try making a call to /tax_rates to see which rates are available, and pass that in for each estimate line and see if that changes anything.

 

Ben

Link to comment
Share on other sites

Thanks @Ben Smith for the reply. After adding the tax_rate and tax_rate_id (which I get from from /tax_rates) the error is still the same. The new request looks like this now - 

{
   "sales_estimate":{
      "expiry_date":"2022-04-04",
      "estimate_lines":[
         {
            "unit_price":150.00,
            "tax_rate_id":"FR_STANDARD",
            "tax_rate":20,
            "quantity":100.00,
            "product_id":"b8c0504967ee4559a2fdf062d0d5ca89",
            "ledger_account_id":"c19b3f6cb00511ecb8b206dd2e485c2e",
            "discount_percentage":"10.00",
            "description":"Test OLI Product"
         }
      ],
      "date":"2022-01-04",
      "contact_id":"343b231bc4424d3ea72c8e81d59932e9"
   }
}

Link to comment
Share on other sites

Consider this one. but the response is still the same.

{
   "sales_estimate":{
      "expiry_date":"2022-04-04",
      "estimate_lines":[
         {
            "unit_price":150.00,
            "tax_rate_id":"FR_STANDARD",
            "tax_rate":"20",
            "quantity":100.00,
            "product_id":"b8c0504967ee4559a2fdf062d0d5ca89",
            "ledger_account_id":"c19b3f6cb00511ecb8b206dd2e485c2e",
            "discount_percentage":10.00,
            "description":"Test OLI Product"
         }
      ],
      "date":"2022-01-04",
      "contact_id":"343b231bc4424d3ea72c8e81d59932e9"
   }
}

 

Raman

Link to comment
Share on other sites

  • Administrators

Ok leave this with me Raman, I'll see if I can dig into this error more. 

Do you have a request id for this last failed call? Feel free to private message me with this info.

 

Ben

Link to comment
Share on other sites

Hi Raman, Ben is not around today, feel free to send it to myself if you wish. 

Is this a French  business creating a sales_estimate for a French customer?

Neither Ben or myself has been able to replicate this using the below body params. You'll need to change the contact and ledger ID's to those in your business.

 

{
   "sales_estimate": {
       "expiry_date": "2022-05-05",
       "date": "2022-05-04",
       "contact_id": "048baf2b8e3c4e7298a57c5ea0c0c19a",
       "estimate_lines": [
           {
               "unit_price": 150.00,
               "quantity": 100.00,
               "product_id": "271817a9c56d4367877c7a733f76a53e",
               "ledger_account_id": "4fcc6770209711e9ae720268dc652fba",
               "discount_percentage": 10,
               "description": "Test OLI Product",
               "tax_rate": "20",
               "tax_rate_id": "FR_STANDARD"
           }
       ]
   }
}

 

Link to comment
Share on other sites

Hi @Raman Raman, thanks for sending through the request_id.

Unfortunately there's nothing in the logs that provide us with a solution. Is this business a test account that you could invite me too?

Alternatively, have you tried creating the same sales_estimate in the UI and if so was there any additional errors or warnings? If it posted without issue, could you complete a GET request and post the response here please?

Thanks

Mark

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi @Steel, Mark, Thank you for your response and help.

Actually, This is a client org so I would not be able to give you the invite for this. However I asked client to create a test sales estimate using UI and there was no error and it posted without any issue. Below is the GET API Response for the same. Request you to please look into this and let me know if I need to send any additional info as part of the POST request to create the sales_estimate using API.

{
    "id": "2ac50b3ef4ad476cb94ce9d87ad60aac",
    "displayed_as": "EST-Ébauche",
    "$path": "/sales_estimates/2ac50b3ef4ad476cb94ce9d87ad60aac",
    "created_at": "2022-04-22T07:17:54Z",
    "updated_at": "2022-04-22T07:17:54Z",
    "links": [
        {
            "href": "https://accounting.eu.sageone.com/invoicing/sales_estimates/2ac50b3ef4ad476cb94ce9d87ad60aac",
            "rel": "alternate",
            "type": "text/html"
        },
        {
            "href": "https://accounting.eu.sageone.com/advanced_uk/online_payment/fr5746def8ca159751e2a12c4a687baa8776719ce899bd7cc18ab80194b0cca25a8e5de12616abf20abd0d253ba2ad89e0a1dd553741df31932fe4929ae7973b9aa4f93df1d8750cf1db725b797057434721964e684dc3cb772334d4f54176c577",
            "rel": "bookmark",
            "type": "text/html"
        }
    ],
    "editable": true,
    "tax_calculation_method": "invoice",
    "destination_consignment": false,
    "destination_vat_rates_in_use": false,
    "contact": {
        "id": "a5b1a89a02ae47fcb701b1398715b31e",
        "displayed_as": "EBSCO International INC (CGN-067)",
        "$path": "/contacts/a5b1a89a02ae47fcb701b1398715b31e"
    },
    "estimate_number_prefix": "EST-",
    "estimate_number": "EST-Ébauche",
    "contact_name": "EBSCO International INC",
    "contact_reference": "CGN-067",
    "date": "2022-04-22",
    "expiry_date": "2022-05-22",
    "reference": "DEVIS TEST",
    "main_address_free_form": "3 rue Jacques Rueff\nCS 60046\n92183 Antony Cedex",
    "main_address": {
        "id": "62d7c292d32b4624aca8c36f0a7781a4",
        "displayed_as": "3 rue Jacques Rueff\nCS 60046\n92183 Antony Cedex",
        "$path": "",
        "address_line_1": "3 rue Jacques Rueff",
        "address_line_2": "CS 60046",
        "city": "Antony Cedex",
        "postal_code": "92183",
        "country": {
            "id": "FR",
            "displayed_as": "France (FR)",
            "$path": "/countries/FR"
        },
        "address_type": {
            "id": "SALES",
            "displayed_as": "Ventes",
            "$path": "/address_types/SALES"
        },
        "region": "",
        "country_group": {
            "id": "EU",
            "displayed_as": "Europe",
            "$path": "/country_groups/EU"
        }
    },
    "delivery_address_free_form": "Université de Lorraine\n34 Cours Léopold - CS 25233\n54052 Nancy cedex",
    "delivery_address": {
        "id": "d982ec2354ce4613affbf1a86d2e338c",
        "displayed_as": "Université de Lorraine\n34 Cours Léopold - CS 25233\n54052 Nancy cedex",
        "$path": "",
        "address_line_1": "Université de Lorraine",
        "address_line_2": "34 Cours Léopold - CS 25233",
        "city": "Nancy cedex",
        "postal_code": "54052",
        "country": {
            "id": "FR",
            "displayed_as": "France (FR)",
            "$path": "/countries/FR"
        },
        "address_type": {
            "id": "DELIVERY",
            "displayed_as": "Livraison",
            "$path": "/address_types/DELIVERY"
        },
        "region": "",
        "country_group": {
            "id": "EU",
            "displayed_as": "Europe",
            "$path": "/country_groups/EU"
        }
    },
    "notes": "",
    "terms_and_conditions": "",
    "shipping_net_amount": "0.0",
    "shipping_tax_rate": {
        "id": "FR_STANDARD",
        "displayed_as": "TVA 20,00%",
        "$path": "/tax_rates/FR_STANDARD"
    },
    "shipping_tax_amount": "0.0",
    "shipping_tax_breakdown": [],
    "shipping_total_amount": "0.0",
    "net_amount": "2838.33",
    "tax_amount": "329.54",
    "total_amount": "3167.87",
    "currency": {
        "id": "EUR",
        "displayed_as": "Euro (EUR)",
        "$path": "/currencies/EUR"
    },
    "exchange_rate": "1.0",
    "inverse_exchange_rate": "1.0",
    "base_currency_shipping_net_amount": "0.0",
    "base_currency_shipping_tax_amount": "0.0",
    "base_currency_shipping_tax_breakdown": [],
    "base_currency_shipping_total_amount": "0.0",
    "total_quantity": "9.0",
    "total_discount_amount": "83.67",
    "base_currency_total_discount_amount": "83.67",
    "base_currency_net_amount": "2838.33",
    "base_currency_tax_amount": "329.54",
    "base_currency_total_amount": "3167.87",
    "payments_allocations_total_amount": "0.0",
    "payments_allocations_total_discount": "0.0",
    "total_paid": "0.0",
    "status": {
        "id": "DRAFT",
        "displayed_as": "Ébauche"
    },
    "sent": false,
    "sent_by_email": false,
    "estimate_lines": [
        {
            "id": "4948d62c18a54e7aa13290c852075b05",
            "displayed_as": "Bouquet Littérature - Comparée (2022)",
            "description": "Bouquet Littérature - Comparée (2022)",
            "product": {
                "id": "9c74766d7b1d43a6b4670c30c7e69962",
                "displayed_as": "Bouquet Littérature - Comparée (2022)",
                "$path": "/products/9c74766d7b1d43a6b4670c30c7e69962"
            },
            "service": null,
            "ledger_account": {
                "id": "9bf7f23788e44824b81907d73824e82f",
                "displayed_as": "vente en France avec TVA à 5,5% (70410000)",
                "$path": "/ledger_accounts/9bf7f23788e44824b81907d73824e82f"
            },
            "trade_of_asset": false,
            "quantity": "1.0",
            "unit_price": "1195.0",
            "net_amount": "1159.15",
            "tax_rate": {
                "id": "FR_LOWER_2",
                "displayed_as": "TVA 5,50%",
                "$path": "/tax_rates/FR_LOWER_2"
            },
            "tax_amount": "63.75",
            "tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_LOWER_2",
                        "displayed_as": "TVA 5,50%",
                        "$path": "/tax_rates/FR_LOWER_2"
                    },
                    "percentage": "5.5",
                    "amount": "63.75"
                }
            ],
            "total_amount": "1222.9",
            "base_currency_unit_price": "1195.0",
            "unit_price_includes_tax": false,
            "base_currency_net_amount": "1159.15",
            "base_currency_tax_amount": "63.75",
            "base_currency_tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_LOWER_2",
                        "displayed_as": "TVA 5,50%",
                        "$path": "/tax_rates/FR_LOWER_2"
                    },
                    "percentage": "5.5",
                    "amount": "63.75"
                }
            ],
            "base_currency_total_amount": "1222.9",
            "eu_goods_services_type": null,
            "discount_amount": "35.85",
            "base_currency_discount_amount": "35.85",
            "discount_percentage": "3.0",
            "eu_sales_description": null
        },
        {
            "id": "73fc0dffc8fa416a873f51395e6c2a07",
            "displayed_as": "Ædificare\r\nParutions 2022",
            "description": "Ædificare\r\nParutions 2022",
            "product": {
                "id": "b52a4a30718b4024991914efd547d807",
                "displayed_as": "Ædificare",
                "$path": "/products/b52a4a30718b4024991914efd547d807"
            },
            "service": null,
            "ledger_account": {
                "id": "9bf7f23788e44824b81907d73824e82f",
                "displayed_as": "vente en France avec TVA à 5,5% (70410000)",
                "$path": "/ledger_accounts/9bf7f23788e44824b81907d73824e82f"
            },
            "trade_of_asset": false,
            "quantity": "2.0",
            "unit_price": "83.0",
            "net_amount": "161.02",
            "tax_rate": {
                "id": "FR_LOWER_2",
                "displayed_as": "TVA 5,50%",
                "$path": "/tax_rates/FR_LOWER_2"
            },
            "tax_amount": "8.86",
            "tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_LOWER_2",
                        "displayed_as": "TVA 5,50%",
                        "$path": "/tax_rates/FR_LOWER_2"
                    },
                    "percentage": "5.5",
                    "amount": "8.86"
                }
            ],
            "total_amount": "169.88",
            "base_currency_unit_price": "83.0",
            "unit_price_includes_tax": false,
            "base_currency_net_amount": "161.02",
            "base_currency_tax_amount": "8.86",
            "base_currency_tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_LOWER_2",
                        "displayed_as": "TVA 5,50%",
                        "$path": "/tax_rates/FR_LOWER_2"
                    },
                    "percentage": "5.5",
                    "amount": "8.86"
                }
            ],
            "base_currency_total_amount": "169.88",
            "eu_goods_services_type": null,
            "discount_amount": "4.98",
            "base_currency_discount_amount": "4.98",
            "discount_percentage": "3.0",
            "eu_sales_description": null
        },
        {
            "id": "dfa15209f8a2494dbac2651526afd030",
            "displayed_as": "Revue d'Histoire littéraire de la France\r\nParutions 2022",
            "description": "Revue d'Histoire littéraire de la France\r\nParutions 2022",
            "product": {
                "id": "70d79031377c4be188355fb5d0eb34d0",
                "displayed_as": "Revue d'Histoire littéraire de la France",
                "$path": "/products/70d79031377c4be188355fb5d0eb34d0"
            },
            "service": null,
            "ledger_account": {
                "id": "9bf7f23788e44824b81907d73824e82f",
                "displayed_as": "vente en France avec TVA à 5,5% (70410000)",
                "$path": "/ledger_accounts/9bf7f23788e44824b81907d73824e82f"
            },
            "trade_of_asset": false,
            "quantity": "4.0",
            "unit_price": "83.0",
            "net_amount": "322.04",
            "tax_rate": {
                "id": "FR_LOWER_2",
                "displayed_as": "TVA 5,50%",
                "$path": "/tax_rates/FR_LOWER_2"
            },
            "tax_amount": "17.71",
            "tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_LOWER_2",
                        "displayed_as": "TVA 5,50%",
                        "$path": "/tax_rates/FR_LOWER_2"
                    },
                    "percentage": "5.5",
                    "amount": "17.71"
                }
            ],
            "total_amount": "339.75",
            "base_currency_unit_price": "83.0",
            "unit_price_includes_tax": false,
            "base_currency_net_amount": "322.04",
            "base_currency_tax_amount": "17.71",
            "base_currency_tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_LOWER_2",
                        "displayed_as": "TVA 5,50%",
                        "$path": "/tax_rates/FR_LOWER_2"
                    },
                    "percentage": "5.5",
                    "amount": "17.71"
                }
            ],
            "base_currency_total_amount": "339.75",
            "eu_goods_services_type": null,
            "discount_amount": "9.96",
            "base_currency_discount_amount": "9.96",
            "discount_percentage": "3.0",
            "eu_sales_description": null
        },
        {
            "id": "fe3d5ebe2e8d4c2c980774ae9d7694e6",
            "displayed_as": "Bibliographie de la littérature française (BLF)\r\nAbonnement du 01/01/2022 au 31/12/2022",
            "description": "Bibliographie de la littérature française (BLF)\r\nAbonnement du 01/01/2022 au 31/12/2022",
            "product": {
                "id": "8f103a4daf404d829e5029fc013e3a2c",
                "displayed_as": "Bibliographie de la littérature française (BLF)",
                "$path": "/products/8f103a4daf404d829e5029fc013e3a2c"
            },
            "service": null,
            "ledger_account": {
                "id": "9bf7f23788e44824b81907d73824e82f",
                "displayed_as": "vente en France avec TVA à 5,5% (70410000)",
                "$path": "/ledger_accounts/9bf7f23788e44824b81907d73824e82f"
            },
            "trade_of_asset": false,
            "quantity": "1.0",
            "unit_price": "830.0",
            "net_amount": "805.1",
            "tax_rate": {
                "id": "FR_STANDARD",
                "displayed_as": "TVA 20,00%",
                "$path": "/tax_rates/FR_STANDARD"
            },
            "tax_amount": "161.02",
            "tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_STANDARD",
                        "displayed_as": "TVA 20,00%",
                        "$path": "/tax_rates/FR_STANDARD"
                    },
                    "percentage": "20.0",
                    "amount": "161.02"
                }
            ],
            "total_amount": "966.12",
            "base_currency_unit_price": "830.0",
            "unit_price_includes_tax": false,
            "base_currency_net_amount": "805.1",
            "base_currency_tax_amount": "161.02",
            "base_currency_tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_STANDARD",
                        "displayed_as": "TVA 20,00%",
                        "$path": "/tax_rates/FR_STANDARD"
                    },
                    "percentage": "20.0",
                    "amount": "161.02"
                }
            ],
            "base_currency_total_amount": "966.12",
            "eu_goods_services_type": null,
            "discount_amount": "24.9",
            "base_currency_discount_amount": "24.9",
            "discount_percentage": "3.0",
            "eu_sales_description": null
        },
        {
            "id": "8bd0111fe2394116845cbeba3656c214",
            "displayed_as": "Frais de maintenance annuels\r\n2 bases\r\nService du 01/01/2022 au 31/12/2022",
            "description": "Frais de maintenance annuels\r\n2 bases\r\nService du 01/01/2022 au 31/12/2022",
            "product": null,
            "service": {
                "id": "96fb6826b9da415d8e841a42a4e2f2cb",
                "displayed_as": "Frais de maintenance annuels",
                "$path": "/services/96fb6826b9da415d8e841a42a4e2f2cb"
            },
            "ledger_account": {
                "id": "55d32ada9a20475a97734aa3b10ab155",
                "displayed_as": "vente de service taux de TVA à 20% (70882000)",
                "$path": "/ledger_accounts/55d32ada9a20475a97734aa3b10ab155"
            },
            "trade_of_asset": false,
            "quantity": "1.0",
            "unit_price": "399.0",
            "net_amount": "391.02",
            "tax_rate": {
                "id": "FR_STANDARD",
                "displayed_as": "TVA 20,00%",
                "$path": "/tax_rates/FR_STANDARD"
            },
            "tax_amount": "78.2",
            "tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_STANDARD",
                        "displayed_as": "TVA 20,00%",
                        "$path": "/tax_rates/FR_STANDARD"
                    },
                    "percentage": "20.0",
                    "amount": "78.2"
                }
            ],
            "total_amount": "469.22",
            "base_currency_unit_price": "399.0",
            "unit_price_includes_tax": false,
            "base_currency_net_amount": "391.02",
            "base_currency_tax_amount": "78.2",
            "base_currency_tax_breakdown": [
                {
                    "tax_rate": {
                        "id": "FR_STANDARD",
                        "displayed_as": "TVA 20,00%",
                        "$path": "/tax_rates/FR_STANDARD"
                    },
                    "percentage": "20.0",
                    "amount": "78.2"
                }
            ],
            "base_currency_total_amount": "469.22",
            "eu_goods_services_type": null,
            "discount_amount": "7.98",
            "base_currency_discount_amount": "7.98",
            "discount_percentage": "2.0",
            "eu_sales_description": null
        }
    ],
    "tax_analysis": [
        {
            "tax_rate": {
                "id": "FR_STANDARD",
                "displayed_as": "TVA 20,00%",
                "$path": "/tax_rates/FR_STANDARD"
            },
            "net_amount": "1196.12",
            "tax_amount": "239.22",
            "total_amount": "1435.34",
            "goods_amount": "805.1",
            "service_amount": "391.02"
        },
        {
            "tax_rate": {
                "id": "FR_LOWER_2",
                "displayed_as": "TVA 5,50%",
                "$path": "/tax_rates/FR_LOWER_2"
            },
            "net_amount": "1642.21",
            "tax_amount": "90.32",
            "total_amount": "1732.53",
            "goods_amount": "1642.21",
            "service_amount": "0.0"
        }
    ],
    "tax_address_region": null,
    "withholding_tax_rate": null,
    "withholding_tax_amount": null,
    "base_currency_withholding_tax_amount": null,
    "profit_analysis": {
        "total": {
            "description": "",
            "total_cost": "0.0",
            "total_sale": "0.0",
            "profit": "0.0",
            "profit_percentage": "0.0"
        },
        "line_breakdown": []
    },
    "tax_reconciled": false,
    "invoice": null
}

 

Link to comment
Share on other sites

Thanks @Raman Raman

Looking at the sales_estimate, non of the id's reflect what you are using in your POST request's. 

What happens if you use the id's from the UI created estimate?

contact_id = a5b1a89a02ae47fcb701b1398715b31e
product_id = 9c74766d7b1d43a6b4670c30c7e69962
ledger_id = 9bf7f23788e44824b81907d73824e82f

Thanks

Mark

Link to comment
Share on other sites

Hi @Steel, Mark, Thank You for response.

I tried posting a sales estimate through API using these ids and it worked. However would like to know that why it didn't work with the previous ids and just to confirm those ids are present in sage org. The only difference is that the earlier contact and product were created through API and these were created using GUI.

Thanks,

Raman

Link to comment
Share on other sites

Thanks for the update @Raman Raman.

When you say they are present in the Sage Org do you mean the business of the user?

Are you able to make GET requests for the id's you are trying to use? If so, can you provide the responses please.

https://api.accounting.sage.com/v3.1/contacts/182d1e41e3c14dcea94b2552beb17c1d

https://api.accounting.sage.com/v3.1/products/a6726f4a4c9744e5adbe214552acce3c

https://api.accounting.sage.com/v3.1/ledger_accounts/c19b3f6cb00511ecb8b206dd2e485c2e

"The only difference is that the earlier contact and product were created through API and these were created using GUI." Are the Contact, product and ledger account selectable in the UI and can a Sales Estimate be created if they are selected in the UI?

Thanks
Mark

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...