Skip to content

Commit

Permalink
fix: add item mapping to e-invoice log
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Sep 26, 2024
1 parent a7da87f commit 9b29195
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 152 deletions.
53 changes: 44 additions & 9 deletions india_compliance/gst_india/client_scripts/purchase_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ frappe.ui.form.on(DOCTYPE, {
});
},

onload: function(frm) {
onload: function (frm) {
toggle_reverse_charge(frm);

if (frm.is_new()) {
frm.add_custom_button(
__("Create Purchase Invoice"),
() => get_irn_dialog(frm),
__("Create Invoice from IRN"),
() => show_irn_dialog(frm),
);
}
},
Expand Down Expand Up @@ -113,7 +113,7 @@ frappe.ui.form.on("Purchase Invoice Item", {
});


function get_irn_dialog(frm) {
function show_irn_dialog(frm) {
const dialog = new frappe.ui.Dialog({
title: __("Create Purchase Invoice"),
fields: [
Expand All @@ -126,27 +126,62 @@ function get_irn_dialog(frm) {
{
label: "Company GSTIN",
fieldname: "gstin",
fieldtype: "Data",
fieldtype: "Autocomplete",
get_query: function () {
return {
query: "india_compliance.gst_india.overrides.purchase_invoice.get_gstin_with_company_name",
};
},
reqd: 1,
}
],
primary_action_label: 'Create',
primary_action(values) {
taxpayer_api.call(
method ="india_compliance.gst_india.overrides.purchase_invoice.create_purchase_invoice_from_irn",
args= {
method = "india_compliance.gst_india.overrides.purchase_invoice.create_purchase_invoice_from_irn",
args = {
company_gstin: values.gstin,
irn: values.irn,
},
function (r){
function (r) {
doc = r.message;
dialog.hide();
frappe.set_route("purchase-invoice", r.message);
frappe.set_route("purchase-invoice", doc.name);
set_party_details(doc, frm);
},
);
},
});
dialog.show();

frappe.db.get_value("Company", frappe.defaults.get_default("company"), "gstin").then(r => {
dialog.fields_dict.gstin.set_input(r.message.gstin);
})
}

function set_party_details(doc, frm) {
erpnext.utils.get_party_details(
frm,
"erpnext.accounts.party.get_party_details",
{
posting_date: doc.posting_date,
bill_date: doc.bill_date,
party: doc.supplier,
party_type: "Supplier",
account: doc.credit_to,
price_list: doc.buying_price_list,
fetch_payment_terms_template: cint(!doc.ignore_default_payment_terms_template),
},
function () {
frm.set_value("apply_tds", frm.supplier_tds ? 1 : 0);
frm.set_value("tax_withholding_category", frm.supplier_tds);
frm.set_df_property("apply_tds", "read_only", frm.supplier_tds ? 0 : 1);
frm.set_df_property("tax_withholding_category", "hidden", frm.supplier_tds ? 0 : 1);
}
);
}


function toggle_reverse_charge(frm) {
let is_read_only = 0;
if (frm.doc.gst_category !== "Overseas") is_read_only = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"cancelled_on",
"column_break_3",
"cancel_reason_code",
"cancel_remark"
"cancel_remark",
"section_break_clwh",
"item_mapping"
],
"fields": [
{
Expand Down Expand Up @@ -131,6 +133,16 @@
"label": "Reference Document Name",
"options": "reference_doctype",
"read_only": 1
},
{
"fieldname": "section_break_clwh",
"fieldtype": "Section Break"
},
{
"fieldname": "item_mapping",
"fieldtype": "Table",
"label": "Item Mapping",
"options": "e-Invoice Mapping"
}
],
"in_create": 1,
Expand All @@ -140,7 +152,7 @@
"link_fieldname": "irn"
}
],
"modified": "2024-09-19 18:59:01.195753",
"modified": "2024-09-24 17:51:10.730928",
"modified_by": "Administrator",
"module": "GST India",
"name": "e-Invoice Log",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,33 @@
"party",
"erpnext_fieldname",
"erpnext_value",
"log_value"
"e_invoice_value",
"item_row_name",
"rate"
],
"fields": [
{
"fieldname": "party_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Party Type",
"options": "DocType"
"options": "DocType",
"read_only": 1
},
{
"fieldname": "party",
"fieldtype": "Dynamic Link",
"in_list_view": 1,
"label": "Party",
"options": "party_type"
"options": "party_type",
"read_only": 1
},
{
"fieldname": "erpnext_fieldname",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Erpnext Fieldname"
"label": "Erpnext Fieldname",
"read_only": 1
},
{
"fieldname": "erpnext_value",
Expand All @@ -39,33 +44,36 @@
"label": "Erpnext Value"
},
{
"fieldname": "log_value",
"fieldname": "e_invoice_value",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Log Value"
"label": "e-Invoice Value",
"read_only": 1
},
{
"fieldname": "item_row_name",
"fieldtype": "Data",
"label": "Item Row Name",
"read_only": 1
},
{
"fieldname": "rate",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Rate",
"precision": "2",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-09-20 15:09:27.296167",
"modified": "2024-09-26 00:12:00.088452",
"modified_by": "Administrator",
"module": "GST India",
"name": "e-Invoice Mapping",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"permissions": [],
"sort_field": "creation",
"sort_order": "DESC",
"states": []
Expand Down
Loading

0 comments on commit 9b29195

Please sign in to comment.