Skip to content

Commit 6860f87

Browse files
authored
Merge pull request #4465 from ljain112/refgression-pr
fix: revert purchase receipt hook and improve test cases
2 parents c7f3f6c + 613a70c commit 6860f87

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

india_compliance/gst_india/overrides/test_transaction.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -372,18 +372,17 @@ def test_block_tax_changing_address_after_submit(self):
372372
purchase = supplier (re-synced here, so the supplier change alone flips it)."""
373373
doc = create_transaction(**self.transaction_details, is_in_state=True)
374374
doc.reload()
375-
doc.load_doc_before_save()
376375

377376
if self.is_sales_doctype:
378377
doc.customer_address = "_Test Registered Customer-Billing-3" # Karnataka (29)
379378
doc.place_of_supply = "29-Karnataka"
380379
else:
381380
doc.supplier_address = "_Test Registered Supplier-Billing-3" # Karnataka (29)
382381

383-
self.assertRaises(
382+
self.assertRaisesRegex(
384383
frappe.exceptions.ValidationError,
385-
sync_address_dependent_fields_on_submit,
386-
doc,
384+
"Cannot charge CGST/SGST for inter-state supplies",
385+
doc.save,
387386
)
388387

389388
def test_block_pos_change_to_different_state_after_submit(self):
@@ -395,13 +394,12 @@ def test_block_pos_change_to_different_state_after_submit(self):
395394
if doc.place_of_supply == "27-Maharashtra":
396395
return
397396

398-
doc.load_doc_before_save()
399397
doc.place_of_supply = "27-Maharashtra"
400398

401-
self.assertRaises(
399+
self.assertRaisesRegex(
402400
frappe.exceptions.ValidationError,
403-
sync_address_dependent_fields_on_submit,
404-
doc,
401+
"Cannot charge CGST/SGST for inter-state supplies",
402+
doc.save,
405403
)
406404

407405
def test_allow_tax_neutral_pos_change_after_submit(self):
@@ -442,13 +440,12 @@ def test_block_gst_category_change_after_submit(self):
442440
address_field = "supplier_address"
443441
new_address = "_Test Registered Supplier-Billing-2"
444442

445-
doc.load_doc_before_save()
446443
doc.set(address_field, new_address)
447444

448-
self.assertRaises(
445+
self.assertRaisesRegex(
449446
frappe.exceptions.ValidationError,
450-
sync_address_dependent_fields_on_submit,
451-
doc,
447+
"GST Category cannot be set to",
448+
doc.save,
452449
)
453450

454451
def test_block_address_or_pos_change_when_ewaybill_or_irn_exists(self):
@@ -460,16 +457,15 @@ def test_block_address_or_pos_change_when_ewaybill_or_irn_exists(self):
460457

461458
doc = create_transaction(**self.transaction_details)
462459
doc.reload()
463-
doc.load_doc_before_save()
464460

465461
# fake an e-Waybill / IRN, then a tax-neutral POS edit
466462
doc.set(ewb_field, "123456789012" if ewb_field == "ewaybill" else "a" * 64)
467463
doc.place_of_supply = "27-Maharashtra" if doc.place_of_supply != "27-Maharashtra" else "29-Karnataka"
468464

469-
self.assertRaises(
465+
self.assertRaisesRegex(
470466
frappe.exceptions.ValidationError,
471-
sync_address_dependent_fields_on_submit,
472-
doc,
467+
"Cannot change the Place of Supply or address after the e-Waybill",
468+
doc.save,
473469
)
474470

475471
def test_validate_mandatory_gst_category(self):

india_compliance/hooks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
"validate": "india_compliance.gst_india.overrides.purchase_receipt.validate",
210210
"before_save": "india_compliance.gst_india.overrides.transaction.update_valuation_rate",
211211
"before_submit": "india_compliance.gst_india.overrides.transaction.update_valuation_rate",
212+
"before_update_after_submit": "india_compliance.gst_india.overrides.transaction.sync_address_dependent_fields_on_submit",
212213
"before_cancel": "india_compliance.gst_india.utils.e_waybill.before_cancel",
213214
"after_mapping": "india_compliance.gst_india.overrides.transaction.after_mapping",
214215
},

0 commit comments

Comments
 (0)