Skip to content

Commit

Permalink
feat: good in trasit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishBarvaliya committed Aug 1, 2024
1 parent 289ce90 commit 7be9f2e
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 46 deletions.
18 changes: 0 additions & 18 deletions d2h/api.py

This file was deleted.

55 changes: 55 additions & 0 deletions d2h/fixtures/custom_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,61 @@
"unique": 0,
"width": null
},
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"doctype": "Custom Field",
"dt": "Purchase Order Item",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "custom_good_in_transit_qty",
"fieldtype": "Float",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "stock_uom",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Good In Transit Qty",
"length": 0,
"link_filters": null,
"mandatory_depends_on": null,
"modified": "2024-08-01 08:21:51.582129",
"module": null,
"name": "Purchase Order Item-custom_good_in_transit_qty",
"no_copy": 0,
"non_negative": 0,
"options": null,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
},
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
Expand Down
62 changes: 34 additions & 28 deletions d2h/public/js/purchase_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,61 @@ function show_items_dialog(frm) {
label: "Items",
cannot_add_rows: true,
in_place_edit: true,
get_data: () => {
data = [];
frm.doc.items.forEach((item) => {
data.push({
new_item_code: item.item_code,
new_uom: item.uom,
new_qty: item.qty,
});
});
return data;
},
data: frm.doc.items.map((item) => {
return {
new_item_code: item.item_code,
new_qty: item.qty - item.good_in_transit_qty,
new_good_in_transit_qty: 0,
};
}),
fields: [
{
fieldtype: "Data",
fieldname: "new_item_code",
label: "Item Code",
in_list_view: 1,
columns: 4,
read_only: 1,
},
{
fieldtype: "Data",
fieldname: "new_uom",
label: "UOM",
fieldtype: "Float",
fieldname: "new_qty",
label: "Pending Qty",
in_list_view: 1,
columns: 3,
read_only: 1,
},
{
fieldtype: "Float",
fieldname: "new_qty",
label: "Quantity",
fieldname: "new_good_in_transit_qty",
label: "Good In Transit Qty",
columns: 3,
in_list_view: 1,
},
],
},
],
primary_action_label: __("Create"),
primary_action_label: __("Save"),
primary_action: function () {
frappe.call({
method: "d2h.api.create_stock_entry",
args: {
items: JSON.stringify(d.get_values().new_items),
},
callback: function (r) {
if (!r.exc) {
frappe.msgprint(__("Stock Entry Created"));
d.hide();
if (d.get_value("new_items").length) {
d.get_value("new_items").map((item) => {
if (item.new_good_in_transit_qty > item.new_qty) {
frappe.throw(
__("Good In Transit Qty cannot be greater than Pending Qty")
);
} else {
frm.doc.items.map((i) => {
if (i.item_code == item.new_item_code) {
i.good_in_transit_qty += item.new_good_in_transit_qty;
frm.dirty();
}
});
frm.refresh_field("items");
}
},
});
});
}
d.hide();
frm.save();
},
secondary_action_label: __("Close"),
secondary_action: function () {
Expand Down
Empty file added d2h/www/__init__.py
Empty file.

0 comments on commit 7be9f2e

Please sign in to comment.