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: make purchase invoice from irn #2630

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 80 additions & 1 deletion india_compliance/gst_india/client_scripts/purchase_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ frappe.ui.form.on(DOCTYPE, {
});
},

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

if (frm.is_new()) {
frm.add_custom_button(
__("Create Invoice from IRN"),
() => show_irn_dialog(frm),
);
}
},

gst_category(frm) {
validate_gst_hsn_code(frm);
Expand Down Expand Up @@ -103,6 +112,76 @@ frappe.ui.form.on("Purchase Invoice Item", {
gst_hsn_code: validate_gst_hsn_code,
});


function show_irn_dialog(frm) {
const dialog = new frappe.ui.Dialog({
title: __("Create Purchase Invoice"),
fields: [
{
label: "IRN",
fieldname: "irn",
fieldtype: "Data",
reqd: 1,
},
{
label: "Company GSTIN",
fieldname: "gstin",
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 = {
company_gstin: values.gstin,
irn: values.irn,
},
function (r) {
doc = r.message;
dialog.hide();
frappe.set_route("purchase-invoice", doc.name);
set_party_details(doc, frm);
Sanket322 marked this conversation as resolved.
Show resolved Hide resolved
},
);
},
});
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",
Sanket322 marked this conversation as resolved.
Show resolved Hide resolved
"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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2024, Resilient Tech and contributors
// For license information, please see license.txt

// frappe.ui.form.on("e-Invoice Mapping", {
// refresh(frm) {

// },
// });
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-09-20 15:05:52.401445",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"party_type",
"party",
"erpnext_fieldname",
"erpnext_value",
"e_invoice_value",
"item_row_name",
"rate"
],
"fields": [
{
"fieldname": "party_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Party Type",
"options": "DocType",
"read_only": 1
},
{
"fieldname": "party",
"fieldtype": "Dynamic Link",
"in_list_view": 1,
"label": "Party",
"options": "party_type",
"read_only": 1
},
{
"fieldname": "erpnext_fieldname",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Erpnext Fieldname",
"read_only": 1
},
{
"fieldname": "erpnext_value",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Erpnext Value"
},
{
"fieldname": "e_invoice_value",
"fieldtype": "Data",
"in_list_view": 1,
"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-26 00:12:00.088452",
"modified_by": "Administrator",
"module": "GST India",
"name": "e-Invoice Mapping",
"owner": "Administrator",
"permissions": [],
"sort_field": "creation",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, Resilient Tech and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class eInvoiceMapping(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, Resilient Tech and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TesteInvoiceMapping(FrappeTestCase):
pass
Loading
Loading