File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,10 +25,24 @@ def set_bootinfo(bootinfo):
2525 bootinfo ["india_state_options" ] = list (INDIAN_STATES )
2626 bootinfo ["ic_api_enabled_from_conf" ] = bool (frappe .conf .ic_api_secret )
2727
28+ set_indian_registered_companies (bootinfo )
2829 set_trigger_for_audit_trail_notification (bootinfo )
2930 set_trigger_for_item_tax_template_notification (bootinfo )
3031
3132
33+ def set_indian_registered_companies (bootinfo ):
34+ companies = frappe .get_all (
35+ "Company" ,
36+ filters = {
37+ "country" : "India" ,
38+ "gst_category" : ("!=" , "Unregistered" ),
39+ },
40+ pluck = "name" ,
41+ )
42+
43+ bootinfo ["indian_registered_companies" ] = companies
44+
45+
3246def set_trigger_for_audit_trail_notification (bootinfo ):
3347 if not bootinfo .sysdefaults or not cint (
3448 bootinfo .sysdefaults .get ("needs_audit_trail_notification" , 0 )
Original file line number Diff line number Diff line change @@ -84,3 +84,44 @@ frappe.ui.form.on(DOCTYPE, {
8484 } , 2000 ) ;
8585 } ,
8686} ) ;
87+ < << << << HEAD
88+ = === ===
89+
90+ frappe . ui . form . on ( "Purchase Invoice Item" , {
91+ item_code ( frm ) {
92+ validate_gst_hsn_code ( frm ) ;
93+ toggle_reverse_charge ( frm ) ;
94+ } ,
95+
96+ items_remove : toggle_reverse_charge ,
97+
98+ gst_hsn_code : validate_gst_hsn_code ,
99+ } ) ;
100+
101+ function toggle_reverse_charge ( frm ) {
102+ let is_read_only = 0 ;
103+ if ( frm . doc . gst_category !== "Overseas" ) is_read_only = 0 ;
104+ // has_goods_item
105+ else if (
106+ frm . doc . items . length > 0 &&
107+ frm . doc . items . some (
108+ item => item . gst_hsn_code && ! item . gst_hsn_code . startsWith ( "99" )
109+ )
110+ )
111+ is_read_only = 1 ;
112+
113+ frm . set_df_property ( "is_reverse_charge" , "read_only" , is_read_only ) ;
114+ }
115+
116+ function validate_gst_hsn_code ( frm ) {
117+ if (
118+ frm . doc . gst_category !== "Overseas" ||
119+ ! india_compliance . is_indian_registered_company ( frm . doc . company )
120+ )
121+ return ;
122+
123+ if ( frm . doc . items . some ( item => item . item_name && ! item . gst_hsn_code ) ) {
124+ frappe . throw ( __ ( "GST HSN Code is mandatory for Overseas Purchase Invoice." ) ) ;
125+ }
126+ }
127+ >>> > >>> d40f56ac ( fix : add support for identifying Indian registered companies in GST validation in JS ; ( #3546 ) )
Original file line number Diff line number Diff line change @@ -137,7 +137,12 @@ function validate_overseas_gst_category(doctype) {
137137 frappe . ui . form . on ( doctype , {
138138 gst_category ( frm ) {
139139 const { enable_overseas_transactions } = gst_settings ;
140- if ( ! is_overseas_transaction ( frm ) || enable_overseas_transactions ) return ;
140+ if (
141+ ! is_overseas_transaction ( frm ) ||
142+ enable_overseas_transactions ||
143+ ! india_compliance . is_indian_registered_company ( frm . doc . company )
144+ )
145+ return ;
141146
142147 frappe . throw (
143148 __ ( "Please enable SEZ / Overseas transactions in GST Settings first" )
@@ -234,7 +239,11 @@ async function _set_gstin_status(frm, gstin_field_name) {
234239}
235240
236241function validate_gstin_status ( gstin_doc , frm , gstin_field_name ) {
237- if ( ! gst_settings . validate_gstin_status ) return ;
242+ if (
243+ ! gst_settings . validate_gstin_status ||
244+ ! india_compliance . is_indian_registered_company ( frm . doc . company )
245+ )
246+ return ;
238247
239248 const date_field =
240249 frm . get_field ( "posting_date" ) || frm . get_field ( "transaction_date" ) ;
Original file line number Diff line number Diff line change @@ -448,6 +448,39 @@ Object.assign(india_compliance, {
448448
449449 return alert ;
450450 } ,
451+ << < << << HEAD
452+ === = ===
453+
454+ is_e_waybill_applicable_for_subcontracting ( doc ) {
455+ if (
456+ ! (
457+ gst_settings . enable_api &&
458+ gst_settings . enable_e_waybill &&
459+ gst_settings . enable_e_waybill_for_sc
460+ )
461+ ) {
462+ return false ;
463+ }
464+
465+ if ( doc . doctype != "Stock Entry" ) return true ;
466+
467+ if (
468+ ! [ "Material Transfer" , "Material Issue" , "Send to Subcontractor" ] . includes (
469+ doc . purpose
470+ )
471+ ) {
472+ return false ;
473+ }
474+
475+ return true ;
476+ } ,
477+
478+ is_indian_registered_company ( company ) {
479+ if ( ! company ) return false ;
480+
481+ return frappe . boot . indian_registered_companies ?. includes ( company ) ;
482+ } ,
483+ >>> >>> > d40f56ac ( fix : add support for identifying Indian registered companies in GST validation in JS ; ( #3546 ) )
451484} ) ;
452485
453486function is_gstin_check_digit_valid ( gstin ) {
You can’t perform that action at this time.
0 commit comments