Skip to content

Commit

Permalink
Merge pull request #2856 from resilient-tech/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
sagarvora authored Dec 12, 2024
2 parents 467443c + 9e0febc commit 6bfce22
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
await frappe.require("purchase_reconciliation_tool.bundle.js");
frm.trigger("company");
frm.purchase_reconciliation_tool = new PurchaseReconciliationTool(frm);

frm.events.handle_download_failure(frm);
},

onload(frm) {
Expand Down Expand Up @@ -229,6 +231,17 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
}
});
},

handle_download_failure(frm) {
frappe.realtime.on("gstr_2a_2b_download_failed", message => {
frm.dashboard.hide();
frappe.msgprint({
title: __("2A/2B Download Failed"),
message: message.error,
indicator: "red"
});
})
},
});

class PurchaseReconciliationTool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,20 @@ def download_gstr(
if not periods:
return

if return_type == ReturnType.GSTR2A:
return download_gstr_2a(company_gstin, periods, gst_categories)
try:
if return_type == ReturnType.GSTR2A:
return download_gstr_2a(company_gstin, periods, gst_categories)

if return_type == ReturnType.GSTR2B:
return download_gstr_2b(company_gstin, periods)
if return_type == ReturnType.GSTR2B:
return download_gstr_2b(company_gstin, periods)

except Exception as e:
frappe.publish_realtime(
"gstr_2a_2b_download_failed",
{"error": str(e)},
user=frappe.session.user,
doctype="Purchase Reconciliation Tool",
)


def get_periods_to_download(company_gstin, return_type, periods):
Expand Down
2 changes: 2 additions & 0 deletions india_compliance/gst_india/overrides/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def get_advance_payment_entries_for_regional(
party_account,
order_doctype,
order_list=None,
default_advance_account=None,
include_unallocated=True,
against_all_orders=False,
limit=None,
Expand All @@ -347,6 +348,7 @@ def get_advance_payment_entries_for_regional(
party_account=party_account,
order_doctype=order_doctype,
order_list=order_list,
default_advance_account=default_advance_account,
include_unallocated=include_unallocated,
against_all_orders=against_all_orders,
limit=limit,
Expand Down
38 changes: 38 additions & 0 deletions india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,44 @@ def test_taxable_value_with_charges_after_tax(self):
doc.insert()
self.assertDocumentEqual({"taxable_value": 100}, doc.items[0])

def test_credit_note_without_quantity(self):
if self.doctype != "Sales Invoice":
return

doc = create_transaction(
**self.transaction_details, is_return=True, do_not_save=True
)
append_item(doc)

for item in doc.items:
item.qty = 0
item.rate = 0
item.price_list_rate = 0

# Adding charges
doc.append(
"taxes",
{
"charge_type": "Actual",
"account_head": "Freight and Forwarding Charges - _TIRC",
"description": "Freight",
"tax_amount": 20,
"cost_center": "Main - _TIRC",
},
)

# Adding taxes
_append_taxes(
doc, ("CGST", "SGST"), charge_type="On Previous Row Total", row_id=1
)
doc.insert()

# Ensure correct taxable_value and gst details
for item in doc.items:
self.assertDocumentEqual(
{"taxable_value": 10, "cgst_amount": 0.9, "sgst_amount": 0.9}, item
)

def test_validate_place_of_supply(self):
doc = create_transaction(**self.transaction_details, do_not_save=True)
doc.place_of_supply = "96-Others"
Expand Down
21 changes: 17 additions & 4 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def update_taxable_values(doc):
total_charges = 0
apportioned_charges = 0
tax_witholding_amount = 0
has_no_qty_value = False

if doc.taxes:
if any(
Expand Down Expand Up @@ -103,16 +104,23 @@ def update_taxable_values(doc):
# base net total may be zero if invoice has zero rated items + shipping
total_value = doc.base_net_total if doc.base_net_total else doc.total_qty

# credit note without item qty and value but with charges
if not total_value:
return
total_value = len(doc.items)
has_no_qty_value = True

for item in doc.items:
item.taxable_value = item.base_net_amount

if not total_charges:
continue

proportionate_value = item.base_net_amount if doc.base_net_total else item.qty
if has_no_qty_value:
proportionate_value = 1
elif doc.base_net_total:
proportionate_value = item.base_net_amount
else:
proportionate_value = item.qty

applicable_charges = flt(
proportionate_value * (total_charges / total_value),
Expand Down Expand Up @@ -498,7 +506,7 @@ def validate_for_charge_type(self):
)

if row.charge_type == "On Previous Row Total":
previous_row_references.add(row.row_id)
previous_row_references.add(flt(row.row_id))

# validating charge type "On Item Quantity" and non_cess_advol_account
self.validate_charge_type_for_cess_non_advol_accounts(row)
Expand Down Expand Up @@ -1031,7 +1039,12 @@ def get_gst_details(party_details, doctype, company, *, update_place_of_supply=F
== party_details.get(party_gstin_field)
) # Internal transfer
)
or (is_sales_transaction and is_export_without_payment_of_gst(party_details))
or (
is_sales_transaction
and is_export_without_payment_of_gst(
frappe._dict({**party_details, "doctype": doctype})
)
)
or (
not is_sales_transaction
and (
Expand Down
2 changes: 1 addition & 1 deletion india_compliance/patches/check_version_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"app_name": "ERPNext",
"current_version": version.parse(erpnext.__version__),
"required_versions": {"version-14": "14.70.7", "version-15": "15.27.7"},
"required_versions": {"version-14": "14.70.7", "version-15": "15.45.5"},
},
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def create_or_update_item_tax_templates(companies):
elif doc.gst_rate == 0:
doc.gst_treatment = "Nil-Rated"

doc.flags.ignore_validate = True # eg: account_type validation
doc.save()

# create new templates for nil rated, exempted, non gst
Expand Down Expand Up @@ -261,6 +262,7 @@ def remove_old_item_variant_settings():
if field.field_name in ("is_nil_exempt", "is_non_gst"):
item_variant.fields.remove(field)

item_variant.flags.ignore_validate = True
item_variant.save()


Expand Down
23 changes: 21 additions & 2 deletions india_compliance/patches/v15/migrate_boe_taxes_to_ic_taxes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import frappe
from frappe.model.document import bulk_insert
from frappe.model.naming import _generate_random_string


def execute():
Expand All @@ -8,16 +10,33 @@ def execute():
boe_taxes = frappe.qb.DocType("Bill of Entry Taxes")
boe_taxes_docs = frappe.qb.from_(boe_taxes).select("*").run(as_dict=True)

ic_taxes_names = set(
frappe.get_all("India Compliance Taxes and Charges", pluck="name")
)
ic_taxes = []

for doc in boe_taxes_docs:
ic_taxes_doc = frappe.get_doc(
{
**doc,
"doctype": "India Compliance Taxes and Charges",
"name": None,
"name": set_name(doc.name, ic_taxes_names),
"base_total": doc.total,
}
)
ic_taxes_doc.insert(ignore_if_duplicate=True)

ic_taxes.append(ic_taxes_doc)

bulk_insert("India Compliance Taxes and Charges", ic_taxes)

# Drop the old table
frappe.db.delete("Bill of Entry Taxes")


def set_name(name, names):
new_name = name
while new_name in names:
new_name = _generate_random_string(10)

names.add(new_name)
return new_name
151 changes: 151 additions & 0 deletions india_compliance/public/js/help_links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
frappe.provide("frappe.help.help_links");

const docsUrl = "https://docs.indiacompliance.app/docs/";
const blogUrl = "https://docs.indiacompliance.app/blog/";

//India Compliance Account
frappe.help.help_links["india-compliance-account"] = [
{
label: "India Compliance Account",
url: docsUrl + "getting-started/india_compliance_account",
},
];

//GST Settings
frappe.help.help_links["Form/GST Settings"] = [
{
label: "Setting Up GST accounts",
url: docsUrl + "configuration/gst_setup#gst-accounts"
},
{
label: "Setting Up API",
url: docsUrl + "ewaybill-and-einvoice/gst_settings"
},
];

//Company
frappe.help.help_links["Form/Company"] = [
{
label: "Print Settings",
url: docsUrl + "configuration/gst_setup#print-format",
}
];


//Doctypes
//Sales Invoice
if (!frappe.help.help_links["Form/Sales Invoice"]) {
frappe.help.help_links["Form/Sales Invoice"] = [];
}

frappe.help.help_links["Form/Sales Invoice"].push(
{
label: "e-Waybill",
url: docsUrl + "ewaybill-and-einvoice/generating_e_waybill",
},
{
label: "e-Invoice",
url: docsUrl + "ewaybill-and-einvoice/generating_e_invoice",
},
);

//Stock Entry
frappe.help.help_links["Form/Stock Entry"].push({
label: "Subcontracting Workflow",
url: blogUrl + "posts/post5",
})

//Subcontracting Receipt
frappe.help.help_links["Form/Subcontracting Receipt"] = [
{
label: "Subcontracting Workflow",
url: blogUrl + "posts/post5",
},
{
label: "GST Job Work Stock Movement report",
url: docsUrl + "gst-reports/miscellaneous_reports#gst-job-work-stock-movement-report",
},
]

//Journal Entry
frappe.help.help_links["Form/Journal Entry"] = [
{
label: "Reversal of Input Tax Credit",
url: docsUrl + "configuration/other_transaction#reversal-of-input-tax-credit",
}
]

// GST Reports
frappe.help.help_links["Form/GSTR-1 Beta"] = [
{
label: "GSTR-1 Beta",
url: docsUrl + "gst-reports/gstr1",
},
];

frappe.help.help_links["Form/GSTR 3B Report"] = [
{
label: "GSTR 3B Report",
url: docsUrl + "gst-reports/gstr3b",
},
];

frappe.help.help_links["List/GSTR 3B Report"] = [
{
label: "GSTR 3B Report",
url: docsUrl + "gst-reports/gstr3b",
},
];


//Query Reports
frappe.help.help_links["query-report/GST Job Work Stock Movement"] = [
{
label: "GST Job Work Stock Movement",
url: docsUrl + "gst-reports/miscellaneous_reports#gst-job-work-stock-movement-report",
},
];

frappe.help.help_links["query-report/GST Balance"] = [
{
label: "GST Balance",
url: docsUrl + "gst-reports/miscellaneous_reports#gst-balance-report",
},
];

frappe.help.help_links["query-report/GST Sales Register Beta"] = [
{
label: "GST Sales Register Beta",
url: docsUrl + "gst-reports/miscellaneous_reports#gst-sales-register-beta-report",
},
];

frappe.help.help_links["query-report/GST Purchase Register"] = [
{
label: "GST Purchase Register",
url: docsUrl + "gst-reports/miscellaneous_reports#gst-purchase-register-beta-report",
},
];

//Purchase Reconciliation
frappe.help.help_links["Form/Purchase Reconciliation Tool"] = [
{
label: "Reconciling Purchase",
url: docsUrl + "purchase-reconciliation/reconciling_purchase",
},
];

//Miscellaneous
frappe.help.help_links["query-report/Audit Trail"] = [
{
label: "Audit Trail",
url: docsUrl + "miscellaneous/audit_trail",
},
];

frappe.help.help_links["Form/Lower Deduction Certificate"] = [
{
label: "Lower Deduction Certificate",
url: docsUrl + "miscellaneous/lower_deduction_certificate",
},
];
1 change: 1 addition & 0 deletions india_compliance/public/js/india_compliance.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ import "./new_gst_category_notification";
import "./quick_info_popover";
import "./custom_number_card";
import "./taxes_controller";
import "./help_links";

0 comments on commit 6bfce22

Please sign in to comment.