Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderTaxLine is missing rate_percent. No such property inside docs. #687

Open
lukasan opened this issue Mar 25, 2022 · 5 comments
Open

OrderTaxLine is missing rate_percent. No such property inside docs. #687

lukasan opened this issue Mar 25, 2022 · 5 comments

Comments

@lukasan
Copy link

lukasan commented Mar 25, 2022

Hello.

I'm using

  • Wordpress 5.9.2 (many separate sites with different languages)
  • WooCommerce 6.3.1
  • WooCommerce.NET 0.8.4

The docs have no such rate_percent property in Order - Tax lines properties https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties

When I query a single order with Postman, which includes a tax_lines array, its object has everything, including rate_percent. OrderTaxLine has no such property.

[DataContract]
public class OrderTaxLine
{
/// <summary>
/// Item ID.
/// read-only
/// </summary>
[DataMember(EmitDefaultValue = false)]
public string id { get; set; }
/// <summary>
/// Tax rate code.
/// read-only
/// </summary>
[DataMember(EmitDefaultValue = false)]
public string rate_code { get; set; }
/// <summary>
/// Tax rate ID.
/// read-only
/// </summary>
[DataMember(EmitDefaultValue = false)]
public string rate_id { get; set; }
/// <summary>
/// Tax rate label.
/// read-only
/// </summary>
[DataMember(EmitDefaultValue = false)]
public string label { get; set; }
/// <summary>
/// Show if is a compound tax rate.
/// read-only
/// </summary>
[DataMember(EmitDefaultValue = false)]
public bool? compound { get; set; }
/// <summary>
/// Tax total (not including shipping taxes).
/// read-only
/// </summary>
[DataMember(EmitDefaultValue = false)]
public decimal? tax_total { get; set; }
/// <summary>
/// Shipping tax total.
/// read-only
/// </summary>
[DataMember(EmitDefaultValue = false)]
public decimal? shipping_tax_total { get; set; }
/// <summary>
/// Meta data. See Order - Meta data properties
/// </summary>
[DataMember(EmitDefaultValue = false)]
public List<OrderMeta> meta_data { get; set; }
}

    "tax_lines": [
        {
            "id": 11036,
            "rate_code": "MWST 19%-1",
            "rate_id": 1,
            "label": "MwSt 19%",
            "compound": false,
            "tax_total": "528",
            "shipping_tax_total": "0",
            "rate_percent": 19,
            "meta_data": []
        }
    ],

I doubt some plugin adds it, although I didn't test that. Another plugin alongside WooCommerce usually adds everything to meta_data.

Thanks.

@zeug-it
Copy link

zeug-it commented Feb 22, 2024

@lukasan - did you solve this problem. I stumbled across the same exactly.
Greetings,
Martin

@lukasan
Copy link
Author

lukasan commented Feb 26, 2024

hey @zeug-it
sadly, after two years nothing has changed. I had managed to calculate the percent on my own from the total amount and discounted amount with various functions in models.

maybe a solution for you is to query it yourself?
https://github.com/XiaoFaye/WooCommerce.NET/wiki/How-to-use-JSON.NET-in-WooCommerce.NET

I had to do that with objects in meta_data. Specifically, for addons plugin.

@lukasan lukasan closed this as completed Feb 26, 2024
@lukasan lukasan reopened this Feb 26, 2024
@zeug-it
Copy link

zeug-it commented Feb 26, 2024

Hi, I found the solution - I think - in the metadata, there is the taxId, with this one you can query the tax from the taxes.
Many Thanks,
Martin

@lukasan
Copy link
Author

lukasan commented Feb 26, 2024

oh yeah maybe, in my solution I got it like this:

var taxlist = await wc.TaxRate.GetAll();
double tax = 0;
if (taxlist.Count == 1)
{
    tax = double.Parse(taxlist.SingleOrDefault().rate, System.Globalization.CultureInfo.InvariantCulture);
}

with config:

AddonRestAPI rest = new(store.Uri + "/wp-json/wc/v3/", store.ApiKey, store.ApiSecret);
WCObject.MetaValueProcessor = ProcessMetaValue;
WCObject wc = new(rest);

...

 public class AddonRestAPI : RestAPI
 {
     public AddonRestAPI(string url, string key, string secret, bool authorizedHeader = true,
         Func<string, string> jsonSerializeFilter = null,
         Func<string, string> jsonDeserializeFilter = null,
         Action<HttpWebRequest> requestFilter = null) : base(url, key, secret, authorizedHeader, jsonSerializeFilter, jsonDeserializeFilter, requestFilter)
     {
     }
...

that was enough for my purposes.

@zeug-it
Copy link

zeug-it commented Feb 26, 2024

Same I did after analyzing the result Json and reading documentation :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants