Skip to content

Commit

Permalink
Merge pull request #2857 from resilient-tech/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
vorasmit authored Dec 12, 2024
2 parents b3e2d4f + d33c041 commit a1a0845
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 8 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 @@ -227,6 +229,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 @@ -484,11 +484,20 @@ def download_pending_gstr_2(
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
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 @@ -71,6 +71,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 @@ -105,16 +106,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 @@ -499,7 +507,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 @@ -956,7 +964,12 @@ def get_gst_details(party_details, doctype, company, *, update_place_of_supply=F
# Taxes Not Applicable
if (
(destination_gstin and destination_gstin == source_gstin) # 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
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
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 @@ -5,3 +5,4 @@ import "./audit_trail_notification";
import "./item_tax_template_notification";
import "./quick_info_popover";
import "./custom_number_card";
import "./help_links";

0 comments on commit a1a0845

Please sign in to comment.