Skip to content

Commit

Permalink
feat(unicommerce): Sales Invoice creation through picklist (#240)
Browse files Browse the repository at this point in the history
* feat:added shelf wise inventory sync and funtionality to generate invoice through pick list

* feat:added shelf wise inventory sync and funtionality to generate invoicethrough picklist

* fix:whitespace

* fix:error log in inventory sync

* fix:error log in inventory sync

* fix:error log in inventory sync

* feat:remove whitelist and clean the code

* feat:add custom fields in unicommerce settings

* fix:inventory sync

* fix:fieldtype

* fix:set workflow state on submit the sales invoice

* fix:error in query

* fix:whitespace

* fix:format of msg

* fix:pre-commit

* fix:validations on pick_list and sales_invoice

---------

Co-authored-by: sonali8848 <[email protected]>
  • Loading branch information
sonali8848 and sonali8848 authored May 15, 2023
1 parent 3cf612b commit 8410c59
Show file tree
Hide file tree
Showing 13 changed files with 359 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"actions": [],
"creation": "2023-04-19 11:57:15.149202",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"sales_order",
"sales_invoice",
"posting_date",
"pick_status",
"invoice_url",
"invoice_pdf"
],
"fields": [
{
"fieldname": "sales_order",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Sales Order",
"options": "Sales Order"
},
{
"fieldname": "sales_invoice",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Sales Invoice",
"options": "Sales Invoice"
},
{
"fetch_from": "sales_invoice.posting_date",
"fieldname": "posting_date",
"fieldtype": "Date",
"label": "Posting Date"
},
{
"fieldname": "pick_status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Pick Status",
"options": "\nPartially Picked\nFully Picked"
},
{
"fieldname": "invoice_url",
"fieldtype": "Data",
"hidden": 1,
"label": "Invoice URL"
},
{
"fieldname": "invoice_pdf",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Invoice Pdf"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-04-20 10:58:07.144994",
"modified_by": "Administrator",
"module": "Ecommerce Integrations",
"name": "Pick List Sales Order Details",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class PickListSalesOrderDetails(Document):
pass
6 changes: 6 additions & 0 deletions ecommerce_integrations/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"Sales Invoice": "public/js/unicommerce/sales_invoice.js",
"Item": "public/js/unicommerce/item.js",
"Stock Entry": "public/js/unicommerce/stock_entry.js",
"Pick List": "public/js/unicommerce/pick_list.js",
}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
Expand Down Expand Up @@ -114,6 +115,11 @@
"on_cancel": "ecommerce_integrations.unicommerce.grn.prevent_grn_cancel",
},
"Item Price": {"on_change": "ecommerce_integrations.utils.price_list.discard_item_prices"},
"Pick List": {"validate": "ecommerce_integrations.unicommerce.pick_list.validate"},
"Sales Invoice": {
"on_submit": "ecommerce_integrations.unicommerce.invoice.on_submit",
"on_cancel": "ecommerce_integrations.unicommerce.invoice.on_cancel",
},
}

# Scheduled Tasks
Expand Down
47 changes: 47 additions & 0 deletions ecommerce_integrations/public/js/unicommerce/pick_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
frappe.ui.form.on('Pick List', {
refresh(frm){
if (frm.doc.order_details){
frm.add_custom_button(__('Generate Invoice'), () => frm.trigger('generate_invoice'))
}
},
generate_invoice(frm){
let selected_so = []
var tbl = frm.doc.order_details || [];
for(var i = 0; i < tbl.length; i++) {
selected_so.push(tbl[i].sales_order)
}
let sales_orders = [];
let so_item_list = [];
const warehouse_allocation = {};
selected_so.forEach(function(so) {
const item_details = frm.doc.locations.map((item) => {
if (item.sales_order == so && item.picked_qty > 0){
so_item_list.push({so_item:item.sales_order_item,
qty:item.qty
});
return {
sales_order_row: item.sales_order_item,
item_code: item.item_code,
warehouse: item.warehouse,
shelf:item.shelf
}
}
else{
return {}
}
});
sales_orders.push(so);
warehouse_allocation[so] = item_details.filter(value => Object.keys(value).length !== 0);
});
frappe.call({
method: 'ecommerce_integrations.unicommerce.invoice.generate_unicommerce_invoices',
args: {
'sales_orders': sales_orders,
'warehouse_allocation': warehouse_allocation
},
freeze: true,
freeze_message: "Requesting Invoice generation. Once synced, invoice will appear in linked documents.",
});

},
})
2 changes: 1 addition & 1 deletion ecommerce_integrations/unicommerce/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
SHIPPING_PACKAGE_STATUS_FIELD = "unicommerce_shipping_package_status"
IS_COD_CHECKBOX = "unicommerce_is_cod"
SHIPPING_METHOD_FIELD = "unicommerce_shipping_method"

PICKLIST_ORDER_DETAILS_FIELD = "order_details"

GRN_STOCK_ENTRY_TYPE = "GRN on Unicommerce"

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"actions": [],
"creation": "2023-04-19 11:57:15.149202",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"sales_order",
"sales_invoice",
"posting_date",
"pick_status",
"invoice_url",
"invoice_pdf"
],
"fields": [
{
"fieldname": "sales_order",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Sales Order",
"options": "Sales Order"
},
{
"fieldname": "sales_invoice",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Sales Invoice",
"options": "Sales Invoice"
},
{
"fetch_from": "sales_invoice.posting_date",
"fieldname": "posting_date",
"fieldtype": "Date",
"label": "Posting Date"
},
{
"fieldname": "pick_status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Pick Status",
"options": "\nPartially Picked\nFully Picked"
},
{
"fieldname": "invoice_url",
"fieldtype": "Data",
"hidden": 1,
"label": "Invoice URL"
},
{
"fieldname": "invoice_pdf",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Invoice Pdf"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-05-02 19:52:50.157639",
"modified_by": "Administrator",
"module": "unicommerce",
"name": "Pick List Sales Order Details",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class PickListSalesOrderDetails(Document):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
ORDER_ITEM_CODE_FIELD,
ORDER_STATUS_FIELD,
PACKAGE_TYPE_FIELD,
PICKLIST_ORDER_DETAILS_FIELD,
PRODUCT_CATEGORY_FIELD,
RETURN_CODE_FIELD,
SHIPPING_METHOD_FIELD,
Expand Down Expand Up @@ -427,6 +428,14 @@ def setup_custom_fields(update=True):
read_only=1,
),
],
"Pick List": [
dict(
fieldname=PICKLIST_ORDER_DETAILS_FIELD,
label="Order Details",
fieldtype="Table",
options="Pick List Sales Order Details",
),
],
}

# create sections first for proper ordering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2021-11-19 16:39:01.415522",
"modified": "2023-05-12 14:06:13.182121",
"modified_by": "Administrator",
"module": "unicommerce",
"name": "Unicommerce Warehouses",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
Loading

0 comments on commit 8410c59

Please sign in to comment.