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 all 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
59 changes: 58 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,54 @@ 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) {
dialog.hide();
if(!r.message) return;

frappe.set_route("purchase-invoice", r.message);
},
);
},
});
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 toggle_reverse_charge(frm) {
let is_read_only = 0;
if (frm.doc.gst_category !== "Overseas") is_read_only = 0;
Expand Down
10 changes: 10 additions & 0 deletions india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,16 @@
"read_only": 1,
"print_hide": 1,
},
{
"fieldname": "is_generated_from_irn",
"label": "Is Generated From IRN",
"fieldtype": "Check",
"default": 0,
"read_only": 1,
"print_hide": 1,
"no_copy": 1,
"hidden": 1,
},
],
"Purchase Receipt": [
{
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,92 @@
{
"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,
"links": [],
"modified": "2024-10-14 23:13:02.604854",
"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
}
],
"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