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

Shopify: Sales Order Aggregate same tax rate in Sales Order #12

Closed
SilentHunter124 opened this issue Jun 2, 2021 · 7 comments
Closed
Labels

Comments

@SilentHunter124
Copy link
Contributor

In our country we have very difficult VAT and Tax Settings and it was hard to set it up in shopify. Let's take the following example:

  • An order contains 1 item of coffee with 32,10 € which is setup as net total.
  • Onto this value a VAT of 7 % is applied.
  • Shipping costs are also added as net total by 4,99€
  • Onto shipping costs, the same tax rate as the item has to be applied. In this case 7%.

Current Behaviour:

When such a SalesOrder is synced from shopify. It will end up having these lines:
image

Idea:

Aggregate all 7% VAT at the end with a single line Type Actual with 2,60 (regarding example above).

Just a request for comments.

Regards

@SilentHunter124
Copy link
Contributor Author

Hey @ankush,

just found out, shopify seems to work differently. tax_lines array in the root of a shopify order object always display the aggregated value of all taxes. It is up to the shopify admin, to setup the account if exactly this tax_lines array value is calculated based on net total including or excluding shipping costs, even if taxes_included is set to true. The inner tax_lines of the items array is showing the non aggregated tax sum. Example order from example above:

{
  "currency": "EUR",
  "current_subtotal_price": "32.10",
  "current_total_price": "39.69",
  "current_total_tax": "2.60",
  "subtotal_price": "32.10",
  "tax_lines": [
    {
      "price": "2.60",
      "rate": 0.07,
      "title": "DE MwSt",
    }
  ],
  "taxes_included": false,
  "total_line_items_price": "32.10",
  "total_outstanding": "0.00",
  "total_price": "39.69",
  "total_tax": "2.60",
  "line_items": [
    {
      "name": "Espresso 1",
      "price": "32.10",
      "quantity": 1,
      "requires_shipping": true,
      "sku": "123",
      "taxable": true,
      "title": "Espresso 1",
      "tax_lines": [
        {
          "price": "2.25",
          "rate": 0.07,
          "title": "DE MwSt"
        }
      ],
      "duties": [],
      "discount_allocations": []
    }
  ],
  "shipping_lines": [
    {
      "discounted_price": "4.99",
      "price": "4.99",
      "tax_lines": [
        {
          "price": "0.35",
          "rate": 0.07,
          "title": "DE MwSt"
        }
      ],
      "discount_allocations": []
    }
  ]
}

Question:

Shall we just import it as shopify displays it:

image

This would mean:

  • Ignore Shipping Lines tax_items values, just import Actual Costs to taxes array
  • Change order: First import shipping lines into taxes array, then import tax_lines from root shopify order object
  • Finally Add tax_lines from root shopify object, but use type "Actual" (as it depends on calculation config in shopify)

@SilentHunter124
Copy link
Contributor Author

@ankush I can maybe create a pull request to try it out?

@ankush
Copy link
Member

ankush commented Jun 9, 2021

Sure, I haven't given much thought to this problem yet, will check it out 👍 Maybe make this behaviour configurable? Not everyone would want to merge the tax lines.

I guess it does make sense to use "Actual", but it would be good to keep the percentage in the description.

@SilentHunter124
Copy link
Contributor Author

SilentHunter124 commented Jun 10, 2021

Agree did that with following pull request: #18
Just try it out, I really like it...

@LittleB18
Copy link

Just joining the conversation, is this solved?

@ankush
Copy link
Member

ankush commented Aug 20, 2021

I've changed the tax computation to completely mirror Shopify's calculations and also item wise tax distributions.

At present, I have no plans of aggregating this, as it increases complexity because Shopify also has multiple options for configuring taxation. The only sane way to handle it is to use them at actuals, which is what we've done right now.

So if anyone else wants to take a stab at merging tax lines, feel free to do so. ref:

taxes.append(
{
"charge_type": "Actual",
"account_head": get_tax_account_head(tax),
"description": (
f"{get_tax_account_description(tax) or tax.get('title')} - {tax.get('rate') * 100.0:.2f}%"
),
"tax_amount": tax.get("price"),
"included_in_print_rate": 0,
"cost_center": setting.cost_center,
"item_wise_tax_detail": json.dumps(
{item_code: [flt(tax.get("rate")) * 100, flt(tax.get("price"))]}
),
"dont_recompute_tax": 1,
}
(This will require some understanding of the internal implementation of taxes in ERPNext. 😅 )

@ankush
Copy link
Member

ankush commented Oct 24, 2023

Refer PR above, there's option to do this now ^

@ankush ankush closed this as completed Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants