dvdl16 / woocommerce_fusion

WooCommerce connector for ERPNext v15
https://finfoot.tech
Other
17 stars 14 forks source link

<title> Manual sync of woocommerce orders with sales order seems strange and too humanly and manual #109

Closed MartinFulgueiras closed 1 week ago

MartinFulgueiras commented 3 weeks ago

Is your feature request related to a problem? Please describe.

Maybe I'm missing something, but here is the problem / request:

As I am trying and understanding the connector in our sandbox, woocommerce orders are automatically sync'd to a virtual doctype woocommerce order inside erpnext. Apparently someone has to manually go to that woocommerce order list, select the woocommerce order (virtual doctype) and manually 'sync this order to erpnext'. If this understanding is correct an ecommerce website with tens/hundreds of orders per minute needs to have quite a big team to manually process the incoming woocommerce orders inside erpnext, sync them to sales order and continue with the process in erpnext.

In the meantime, stock values get de-synchronized and there is no certainty that the figures showing in the ecommerce are correct, thus opening the possibility of problems plus a hefty team of manual synchronizers. Am I getting this wrong?

Describe the solution you'd like

My idea is that as soon as a woocommerce order is created, there appears a sales order inside erpnext without the users doing anything else manually. This because woocommerce handles the commercial side and orders, maybe 99% of the times, come already confirmed into the erp system and paid for. And if not the erpnext platform shouldn't do anything as the commercial side is handled by woocommerce (alas, waiting, pending payment, pending confirmation by customer, draft, etc, etc)

Then, the automatically created erpnext order (from woocommerce) 'separates' the stock in the warehouse until delivery (erpnext already handles this separation smoothly with it's own sales orders) Woocommerce updates the available stock with the available quantity (actual stock (maybe + virtual stock) - separated stock = available stock in woocommerce and gets sync'd fast!) Delivery is processed within erpnext and as soon as it is submitted, stock is update within erpnext (already done in erpnext smoothly) Erpnext could sync woocommerce order (in woocommerce) as pending delivery or being delivered Woocommerce doesn't update stock because it's already showing the available stock, not real stock Order gets delivered, user updates order status in erpnext, this status is sync'd to woocommerce order for user to see. commerce continues smoothly

Describe alternatives you've considered

Can't think of any as this is quite standard in erpnext

Additional context

Am I understanding this incorrectly? can´t imagine that we are synchronizing 2 platforms for someone in the middle to manually be clicking on every order that is incomming. I must be understanding something wrong or not being able to find the functionality in the fusion connector or configuring it correctly. Am I? thanks.

MartinFulgueiras commented 3 weeks ago

Isn't this what I am talking about? The option is ticked, but erpnext isn't creating the internal sales orders

image

dvdl16 commented 3 weeks ago

@MartinFulgueiras the options for manually synchronising orders one by one is just there for convenience/as an alternative way to force sync. Your expectation is correct, the orders should synchronise automatically.

Have you seen this help page, specifically the troubleshooting steps below? Can you send any error logs, or check your Scheduled Job Log list for failed jobs. You can also use the System Health page to check for failed logs. What dates are currently set on WooCommerce Integration Settings

MartinFulgueiras commented 3 weeks ago

Hi Dirk, we've been doing test, scrapping everything and starting from zero so as to have fresh error logs. The problem persists plus a new message:

image

And here is the error:

App Versions

{
    "crm": "1.19.0",
    "erpnext": "15.33.2",
    "frappe": "15.39.0",
    "hrms": "15.26.0",
    "lms": "2.1.0",
    "payments": "0.0.1",
    "woocommerce_fusion": "1.7.2"
}

Route

Form/WooCommerce Order/cc-wp.test.puentedigital.net~33

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 114, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1768, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 64, in run_sales_order_sync
    sync.run()
  File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 144, in run
    raise err
  File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 140, in run
    self.sync_wc_order_with_erpnext_order()
  File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 198, in sync_wc_order_with_erpnext_order
    self.create_sales_order(self.woocommerce_order)
  File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 445, in create_sales_order
    self.create_and_link_payment_entry(wc_order, new_sales_order)
  File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 273, in create_and_link_payment_entry
    raise KeyError(
KeyError: 'WooCommerce payment method cheque not found in WooCommerce Server'

Request Data

{
    "type": "POST",
    "args": {
        "woocommerce_order_name": "cc-wp.test.puentedigital.net~33"
    },
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/woocommerce_fusion.tasks.sync_sales_orders.run_sales_order_sync",
    "request_id": null
}

Response Data

{
    "exception": "KeyError: 'WooCommerce payment method cheque not found in WooCommerce Server'",
    "exc_type": "KeyError",
    "_exc_source": "woocommerce_fusion (app)",
    "_server_messages": "[\"{\\\"message\\\": \\\"Item Price added for 17 in Price List Standard Selling\\\", \\\"title\\\": \\\"Message\\\", \\\"alert\\\": 1}\", \"{\\\"message\\\": \\\"Item Price added for 19 in Price List Standard Selling\\\", \\\"title\\\": \\\"Message\\\", \\\"alert\\\": 1}\"]"
}

We've tried creating the mode of payment and the payment term, but nothing seems to be working now. Before we could manage to manually sync the orders. Now not even that.

BTW, the sync item does work in woocommerce product list but again we need to manually sync item by item for them to appear in erpnext item list.

On the new ones there is no Scheduled Job log, and the error log has the same one as before: Traceback (most recent call last): File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 140, in run self.sync_wc_order_with_erpnext_order() File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 198, in sync_wc_order_with_erpnext_order self.create_sales_order(self.woocommerce_order) File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 445, in create_sales_order self.create_and_link_payment_entry(wc_order, new_sales_order) File "apps/woocommerce_fusion/woocommerce_fusion/tasks/sync_sales_orders.py", line 273, in create_and_link_payment_entry raise KeyError( KeyError: 'WooCommerce payment method cheque not found in WooCommerce Server'

Sales Order Data:

WC Product Data {'name': 'cc-wp.test.puentedigital.net~33', 'owner': None, 'creation': None, 'modified': '2024-08-21T04:50:47', 'modified_by': None, 'docstatus': 0, 'idx': 0, 'woocommerce_server': 'cc-wp.test.puentedigital.net', 'id': 33, 'parent_id': 0, 'number': '33', 'order_key': 'wc_order_3RVZcdeqWepli', 'created_via': 'store-api', 'version': '9.1.4', 'status': 'completed', 'currency': 'MXN', 'date_created': '2024-08-21T04:39:06', 'date_created_gmt': '2024-08-21T04:39:06', 'date_modified': '2024-08-21T04:50:47', 'date_modified_gmt': '2024-08-21T04:50:47', 'discount_total': '0.00', 'discount_tax': '0.00', 'shipping_total': '0.00', 'shipping_tax': '0.00', 'cart_tax': '0.00', 'total': '240.00', 'total_tax': '0.00', 'prices_include_tax': 0, 'customer_id': 1, 'customer_ip_address': '189.130.78.94', 'customer_user_agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36', 'customer_note': '', 'billing': '{"first_name": "Juan", "last_name": "Perez", "company": "", "address_1": "Test Street", "address_2": "", "city": "City", "state": "DF", "postcode": "00000", "country": "MX", "email": "administrator@puentedigital.net", "phone": ""}', 'shipping': '{"first_name": "Juan", "last_name": "Perez", "company": "", "address_1": "Test Street", "address_2": "", "city": "City", "state": "DF", "postcode": "00000", "country": "MX", "phone": ""}', 'payment_method': 'cheque', 'payment_method_title': 'Check payments', 'transaction_id': '', 'date_paid': '2024-08-21T04:40:53', 'date_paid_gmt': '2024-08-21T04:40:53', 'date_completed': '2024-08-21T04:50:47', 'date_completed_gmt': '2024-08-21T04:50:47', 'cart_hash': 'f27189da6b365647c3adc2f091ce4f52', 'meta_data': '[{"id": 1, "key": "_shipping_hash", "value": "9d4568c009d203ab10e33ea9953a0264"}, {"id": 2, "key": "_coupons_hash", "value": "d751713988987e9331980363e24189ce"}, {"id": 3, "key": "_fees_hash", "value": "d751713988987e9331980363e24189ce"}, {"id": 4, "key": "_taxes_hash", "value": "fce788ca3b16abebf49baaf53a9a3afa"}, {"id": 5, "key": "is_vat_exempt", "value": "no"}, {"id": 8, "key": "_wc_order_attribution_source_type", "value": "typein"}, {"id": 9, "key": "_wc_order_attribution_referrer", "value": "https://cc-wp.test.puentedigital.net/wp-admin/admin.php?page=wc-admin"}, {"id": 10, "key": "_wc_order_attribution_utm_source", "value": "(direct)"}, {"id": 11, "key": "_wc_order_attribution_session_entry", "value": "https://cc-wp.test.puentedigital.net/"}, {"id": 12, "key": "_wc_order_attribution_session_start_time", "value": "2024-08-21 04:11:45"}, {"id": 13, "key": "_wc_order_attribution_session_pages", "value": "16"}, {"id": 14, "key": "_wc_order_attribution_session_count", "value": "1"}, {"id": 15, "key": "_wc_order_attribution_user_agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"}, {"id": 16, "key": "_wc_order_attribution_device_type", "value": "Desktop"}]', 'line_items': '[{"id": 5, "name": "Hi-Fi Headphones", "product_id": 17, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "125.00", "subtotal_tax": "0.00", "total": "125.00", "total_tax": "0.00", "taxes": [{"id": 1, "total": "0", "subtotal": "0"}], "meta_data": [], "sku": "", "price": 125, "image": {"id": "16", "src": "https://cc-wp.test.puentedigital.net/wp-content/uploads/2024/08/man-person-music-black-and-white-white-photography-scaled.jpg"}, "parent_name": null}, {"id": 6, "name": "3-Speed Bike", "product_id": 19, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "115.00", "subtotal_tax": "0.00", "total": "115.00", "total_tax": "0.00", "taxes": [{"id": 1, "total": "0", "subtotal": "0"}], "meta_data": [], "sku": "", "price": 115, "image": {"id": "18", "src": "https://cc-wp.test.puentedigital.net/wp-content/uploads/2024/08/road-sport-vintage-wheel-retro-old-scaled.jpg"}, "parent_name": null}]', 'tax_lines': '[{"id": 20, "rate_code": "TAX-1", "rate_id": 1, "label": "Tax", "compound": false, "tax_total": "0.00", "shipping_tax_total": "0.00", "rate_percent": 0, "meta_data": []}]', 'shipping_lines': '[{"id": 21, "method_title": "Free shipping", "method_id": "free_shipping", "instance_id": "1", "total": "0.00", "total_tax": "0.00", "taxes": [{"id": 1, "total": "0", "subtotal": ""}], "meta_data": [{"id": 135, "key": "Items", "value": "Hi-Fi Headphones × 1, 3-Speed Bike × 1", "display_key": "Items", "display_value": "Hi-Fi Headphones × 1, 3-Speed Bike × 1"}]}]', 'fee_lines': '[]', 'coupon_lines': '[]', 'refunds': '[]', 'set_paid': 0, 'shipment_trackings': None, 'doctype': 'WooCommerce Order'})