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

feat(shopify): consolidate tax accounts in order #229

Merged
merged 4 commits into from
Feb 13, 2023

Conversation

rtdany10
Copy link
Contributor

@rtdany10 rtdany10 commented Feb 4, 2023

Currently, the tax table have individual lines of tax for each item in the order.
This PR consolidates the tax table and also gives the user ability to move shipping charges to the item table, if required.

Settings page:
image

When Shipping Charge is added as an item:
image

Otherwise:
image

Related: resilient-tech/india-compliance#469
@ankush @vorasmit

@rtdany10 rtdany10 requested a review from ankush as a code owner February 4, 2023 06:33
@rtdany10
Copy link
Contributor Author

rtdany10 commented Feb 9, 2023

Closes #12

row = {"account_head": account, **tax_row}
row["item_wise_tax_detail"] = json.dumps(row.get("item_wise_tax_detail", {}))
taxes.append(row)

return taxes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing code is much more readable and we are adding a layer of complexity. It's better to break this and make it more readable.

Given a chance, I wouldn't touch existing functionality, but instead process the list of taxes just before returning it in a separate function (if applicable). Appending to items in update_taxes_with_shipping_lines would still be required though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, have made consolidation an optional feature and also split it into a different function.


shipping_charge_amount = flt(shipping_charge["price"]) - flt(total_discount)
if bool(taxes_inclusive):
shipping_charge_amount -= total_tax

taxes.append(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserting at 0 would make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipping item at the top? 🤔

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f"{get_tax_account_description(tax) or tax.get('title')}"
),
"tax_amount": tax["price"],
"cost_center": setting.cost_center,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not updating item_wise_tax_detail here?
Also its just equal to using set_default instead of if / else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have added item_wise_tax_detail

@vorasmit
Copy link

@ankush LGTM from a Logical standpoint.

@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Merging #229 (dbd97ca) into develop (568253b) will decrease coverage by 0.14%.
The diff coverage is 14.28%.

❗ Current head dbd97ca differs from pull request most recent head 90ddff1. Consider uploading reports for the commit 90ddff1 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #229      +/-   ##
===========================================
- Coverage    40.96%   40.83%   -0.14%     
===========================================
  Files           62       62              
  Lines         4245     4261      +16     
===========================================
+ Hits          1739     1740       +1     
- Misses        2506     2521      +15     
Impacted Files Coverage Δ
ecommerce_integrations/shopify/order.py 14.94% <14.28%> (-0.79%) ⬇️

@ankush ankush merged commit f466088 into frappe:develop Feb 13, 2023
@github-actions
Copy link

🎉 This PR is included in version 1.15.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

ankush added a commit to ankush/ecommerce_integrations that referenced this pull request Feb 16, 2023
caused by frappe#229

```
Traceback (most recent call last):
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 49, in sync_sales_order
    create_order(order, setting)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 61, in create_order
    so = create_sales_order(order, setting, company)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 96, in create_sales_order
    taxes = get_order_taxes(shopify_order, setting, items)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 223, in get_order_taxes
    row["item_wise_tax_detail"] = json.dumps(row["item_wise_tax_detail"])
KeyError: 'item_wise_tax_detail'
```
ankush added a commit to ankush/ecommerce_integrations that referenced this pull request Feb 16, 2023
caused by frappe#229

```
Traceback (most recent call last):
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 49, in sync_sales_order
    create_order(order, setting)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 61, in create_order
    so = create_sales_order(order, setting, company)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 96, in create_sales_order
    taxes = get_order_taxes(shopify_order, setting, items)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 223, in get_order_taxes
    row["item_wise_tax_detail"] = json.dumps(row["item_wise_tax_detail"])
KeyError: 'item_wise_tax_detail'
```
ankush added a commit that referenced this pull request Feb 16, 2023
caused by #229

```
Traceback (most recent call last):
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 49, in sync_sales_order
    create_order(order, setting)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 61, in create_order
    so = create_sales_order(order, setting, company)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 96, in create_sales_order
    taxes = get_order_taxes(shopify_order, setting, items)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 223, in get_order_taxes
    row["item_wise_tax_detail"] = json.dumps(row["item_wise_tax_detail"])
KeyError: 'item_wise_tax_detail'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants