Skip to content

Commit

Permalink
Merge pull request #1329 from resilient-tech/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
mergify[bot] authored Nov 29, 2023
2 parents 62872a2 + 6d5556d commit 41670cb
Show file tree
Hide file tree
Showing 35 changed files with 791 additions and 95 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache
Expand All @@ -97,6 +97,36 @@ jobs:
BRANCH_TO_CLONE: ${{ env.IC_BRANCH }}

- name: Run Tests
run: cd ~/frappe-bench/ && bench --site test_site run-tests --app india_compliance
run: cd ~/frappe-bench/ && bench --site test_site run-tests --app india_compliance --coverage
env:
TYPE: server

- name: Show bench output
if: ${{ always() }}
run: cat ~/frappe-bench/bench_start.log || true

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage
path: /home/runner/frappe-bench/sites/coverage.xml

coverage:
name: Coverage Wrap Up
needs: tests
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v3

- name: Upload coverage data
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
name: MariaDB
fail_ci_if_error: true
verbose: true
2 changes: 1 addition & 1 deletion .releaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"branches": ["version-14", "version-15"],
"branches": ["version-15"],
"plugins": [
"@semantic-release/commit-analyzer", {
"preset": "angular",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const E_WAYBILL_CLASS = {
"Sales Invoice": SalesInvoiceEwaybill,
"Purchase Invoice": PurchaseInvoiceEwaybill,
"Delivery Note": DeliveryNoteEwaybill,
"Purchase Receipt": PurchaseReceiptEwaybill,
};

function setup_e_waybill_actions(doctype) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ class PurchaseInvoiceEwaybill extends EwaybillApplicability {
}
}


class PurchaseReceiptEwaybill extends EwaybillApplicability {
is_e_waybill_applicable() {
return super.is_e_waybill_applicable() && gst_settings.enable_e_waybill_from_pr;
}

is_e_waybill_generatable() {
return (
this.is_e_waybill_applicable() &&
this.frm.doc.supplier_address &&
this.frm.doc.company_gstin !== this.frm.doc.supplier_gstin
);
}
}

class DeliveryNoteEwaybill extends EwaybillApplicability {
is_e_waybill_applicable() {
return super.is_e_waybill_applicable() && gst_settings.enable_e_waybill_from_dn;
Expand Down
12 changes: 9 additions & 3 deletions india_compliance/gst_india/client_scripts/party.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const TCS_REGEX = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[C]{1}[0-9A-Z]{1}$/;
const PAN_REGEX = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/;

function update_gstin_in_other_documents(doctype) {
Expand Down Expand Up @@ -48,7 +49,7 @@ function update_gstin_in_other_documents(doctype) {
function validate_gstin(doctype) {
frappe.ui.form.on(doctype, {
gstin(frm) {
const { gstin } = frm.doc;
let { gstin } = frm.doc;

// TODO: remove below condition once event is fixed in frappe
if (!gstin || gstin.length < 15) return;
Expand All @@ -57,7 +58,13 @@ function validate_gstin(doctype) {
frappe.throw(__("GSTIN/UIN should be 15 characters long"));
}

frm.doc.gstin = gstin.trim().toUpperCase();
gstin = india_compliance.validate_gstin(gstin);

if (TCS_REGEX.test(gstin)) {
frappe.throw(__("e-Commerce Operator (TCS) GSTIN is not allowed to be set in Party/Address"));
}

frm.doc.gstin = gstin;
frm.refresh_field("gstin");

if (!frm.fields_dict.pan) return;
Expand Down Expand Up @@ -135,7 +142,6 @@ async function set_gstin_options(frm) {
field.set_data(await india_compliance.get_gstin_options(frm.doc.name, frm.doctype));
}


function set_gst_category(doctype) {
frappe.ui.form.on(doctype, {
gstin(frm) {
Expand Down
27 changes: 27 additions & 0 deletions india_compliance/gst_india/client_scripts/purchase_receipt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const DOCTYPE = "Purchase Receipt";
setup_e_waybill_actions(DOCTYPE);

frappe.ui.form.on(DOCTYPE, {
refresh(frm) {
if (gst_settings.enable_e_waybill && gst_settings.enable_e_waybill_from_pr)
show_sandbox_mode_indicator();
},

after_save(frm) {
if (
frm.doc.supplier_address ||
!(frm.doc.gst_category == "Unregistered" || frm.doc.is_return) ||
!is_e_waybill_applicable(frm) ||
!has_e_waybill_threshold_met(frm)
)
return;

frappe.show_alert(
{
message: __("Supplier Address is required to create e-Waybill"),
indicator: "yellow",
},
10
);
},
});
42 changes: 42 additions & 0 deletions india_compliance/gst_india/client_scripts/sales_invoice_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ frappe.listview_settings[DOCTYPE].onload = function (list_view) {
);
}

if (frappe.model.can_print("e-Waybill Log")) {
add_bulk_action_for_invoices(
list_view,
__("Print e-Waybill"),
bulk_e_waybill_print
);
}

if (india_compliance.is_e_invoice_enabled())
add_bulk_action_for_invoices(
list_view,
Expand Down Expand Up @@ -76,6 +84,40 @@ function show_bulk_update_transporter_dialog(docnames) {
d.show();
}

async function bulk_e_waybill_print(docnames) {
frappe.call({
method: "india_compliance.gst_india.utils.e_waybill.get_valid_and_invalid_e_waybill_log",
args: {
doctype: DOCTYPE,
docs: JSON.stringify(docnames),
},
callback: function (r) {
if (r.message) {
if (r.message.invalid_log.length > 1) {
const invalid_docs = r.message.invalid_log.map(
doc => `${doc.link} - ${doc.reason}`
);
frappe.msgprint(
__(
"Cannot print e-Waybill for following documents:<br><br>{0}",
[invalid_docs.join("<br>")]
)
);
}

window.open_url_post(
"/api/method/frappe.utils.print_format.download_multi_pdf",
{
doctype: "e-Waybill Log",
name: JSON.stringify(r.message.valid_log),
},
true
);
}
},
});
}

async function enqueue_bulk_e_waybill_generation(docnames) {
enqueue_bulk_generation(
"india_compliance.gst_india.utils.e_waybill.enqueue_bulk_e_waybill_generation",
Expand Down
75 changes: 74 additions & 1 deletion india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
],
("Customer", "Supplier"): party_fields,
# Purchase Fields
("Purchase Order", "Purchase Receipt", "Purchase Invoice"): [
("Purchase Order", "Purchase Receipt", "Purchase Invoice", "Supplier Quotation"): [
{
"fieldname": "supplier_gstin",
"label": "Supplier GSTIN",
Expand Down Expand Up @@ -889,6 +889,78 @@
*E_WAYBILL_DN_FIELDS,
]

E_WAYBILL_PURCHASE_RECEIPT_FIELDS = [
{
"fieldname": "transporter",
"label": "Transporter",
"fieldtype": "Link",
"insert_after": "transporter_info",
"options": "Supplier",
"print_hide": 1,
"no_copy": 1,
},
{
"fieldname": "transporter_name",
"label": "Transporter Name",
"fieldtype": "Small Text",
"insert_after": "lr_no",
"fetch_from": "transporter.supplier_name",
"read_only": 1,
"print_hide": 1,
"no_copy": 1,
"translatable": 0,
},
{
"fieldname": "lr_no",
"label": "Transport Receipt No",
"fieldtype": "Data",
"insert_after": "column_break5",
"print_hide": 1,
"no_copy": 1,
"translatable": 0,
"length": 30,
},
{
"fieldname": "lr_date",
"label": "Transport Receipt Date",
"fieldtype": "Date",
"insert_after": "lr_no",
"default": "Today",
"print_hide": 1,
"no_copy": 1,
},
{
"fieldname": "driver",
"label": "Driver",
"fieldtype": "Link",
"insert_after": "lr_date",
"options": "Driver",
"print_hide": 1,
"no_copy": 1,
},
{
"fieldname": "vehicle_no",
"label": "Vehicle No",
"fieldtype": "Data",
"insert_after": "transporter_name",
"print_hide": 1,
"no_copy": 1,
"translatable": 0,
"length": 15,
},
{
"fieldname": "driver_name",
"label": "Driver Name",
"fieldtype": "Small Text",
"insert_after": "driver",
"fetch_from": "driver.full_name",
"print_hide": 1,
"no_copy": 1,
"translatable": 0,
},
*E_WAYBILL_DN_FIELDS,
]

sales_e_waybill_field = {
"fieldname": "ewaybill",
"label": "e-Waybill No.",
Expand Down Expand Up @@ -922,4 +994,5 @@
+ [sales_e_waybill_field, e_waybill_status_field],
"Delivery Note": E_WAYBILL_DN_FIELDS + [sales_e_waybill_field],
"Purchase Invoice": E_WAYBILL_INV_FIELDS + [purchase_e_waybill_field],
"Purchase Receipt": E_WAYBILL_PURCHASE_RECEIPT_FIELDS + [purchase_e_waybill_field],
}
1 change: 1 addition & 0 deletions india_compliance/gst_india/constants/e_waybill.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"Sales Invoice": selling_address,
"Purchase Invoice": buying_address,
"Delivery Note": selling_address,
"Purchase Receipt": buying_address,
}
PERMITTED_DOCTYPES = list(ADDRESS_FIELDS.keys())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"enable_e_waybill",
"enable_e_waybill_from_dn",
"enable_e_waybill_from_pi",
"enable_e_waybill_from_pr",
"fetch_e_waybill_data",
"attach_e_waybill_print",
"column_break_10",
Expand Down Expand Up @@ -371,12 +372,18 @@
"fieldtype": "Code",
"hidden": 1,
"label": "GSTN Public Certificate"
},
{
"default": "0",
"fieldname": "enable_e_waybill_from_pr",
"fieldtype": "Check",
"label": "Enable e-Waybill Generation from Purchase Receipt"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-10-05 20:27:28.909862",
"modified": "2023-11-07 17:56:07.859891",
"modified_by": "Administrator",
"module": "GST India",
"name": "GST Settings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ class ImportDialog {
this.frm.events.show_progress(this.frm, "download");
const { message } = await this.frm.call(method, args);
if (message && ["otp_requested", "invalid_otp"].includes(message.error_type)) {
const otp = await india_compliance.get_gstin_otp(message.error_type);
const otp = await india_compliance.get_gstin_otp(message.error_type, this.frm.doc.company_gstin);
if (otp) this.download_gstr(only_missing, otp);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from india_compliance.gst_india.utils.gstr import (
IMPORT_CATEGORY,
GSTRCategory,
ReturnsAPI,
ReturnType,
download_gstr_2a,
download_gstr_2b,
Expand Down Expand Up @@ -513,6 +514,13 @@ def wrapper(*args, **kwargs):
return wrapper


@frappe.whitelist()
def resend_otp(company_gstin):
frappe.has_permission("Purchase Reconciliation Tool", "write", throw=True)

return ReturnsAPI(company_gstin).request_otp()


class BuildExcel:
COLOR_PALLATE = frappe._dict(
{
Expand Down
12 changes: 12 additions & 0 deletions india_compliance/gst_india/overrides/purchase_receipt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from india_compliance.gst_india.overrides.sales_invoice import (
update_dashboard_with_gst_logs,
)


def get_dashboard_data(data):
return update_dashboard_with_gst_logs(
"Purchase Receipt",
data,
"e-Waybill Log",
"Integration Request",
)
Loading

0 comments on commit 41670cb

Please sign in to comment.