@@ -350,35 +350,28 @@ def set_reclaim_of_itc_reversal(self):
350350 self .report_dict ["itc_elg" ]["itc_inelg" ][0 ][tax_amount_key ] += entry .amount
351351
352352 def get_inward_nil_exempt (self , state ):
353- PurchaseInvoice = frappe .qb .DocType ("Purchase Invoice" )
354- PurchaseInvoiceItem = frappe .qb .DocType ("Purchase Invoice Item" )
355-
356- query = (
357- frappe .qb .from_ (PurchaseInvoice )
358- .join (PurchaseInvoiceItem )
359- .on (PurchaseInvoice .name == PurchaseInvoiceItem .parent )
360- .select (
361- PurchaseInvoice .place_of_supply ,
362- PurchaseInvoice .supplier_address ,
363- PurchaseInvoiceItem .taxable_value ,
364- PurchaseInvoiceItem .gst_treatment ,
365- )
366- .where (
367- (PurchaseInvoice .docstatus == 1 )
368- & (PurchaseInvoice .is_opening == "No" )
369- & (PurchaseInvoice .company_gstin != IfNull (PurchaseInvoice .supplier_gstin , "" ))
370- & (
371- (PurchaseInvoiceItem .gst_treatment != "Taxable" )
372- | (PurchaseInvoice .gst_category == "Registered Composition" )
373- )
374- & (PurchaseInvoice .posting_date .between (self .from_date , self .to_date ))
375- & (PurchaseInvoice .company == self .company )
376- & (PurchaseInvoice .company_gstin == self .gst_details .get ("gstin" ))
377- )
353+ inward_nil_exempt = frappe .db .sql (
354+ """
355+ SELECT p.place_of_supply, p.supplier_address,
356+ i.taxable_value, i.gst_treatment
357+ FROM `tabPurchase Invoice` p , `tabPurchase Invoice Item` i
358+ WHERE p.docstatus = 1 and p.name = i.parent
359+ and p.is_opening = 'No'
360+ and p.company_gstin != IFNULL(p.supplier_gstin, "")
361+ and (i.gst_treatment != 'Taxable' or p.gst_category = 'Registered Composition') and
362+ p.posting_date between %s and %s
363+ and p.company = %s and p.company_gstin = %s
364+ and p.gst_category != "Overseas"
365+ """ ,
366+ (
367+ self .from_date ,
368+ self .to_date ,
369+ self .company ,
370+ self .gst_details .get ("gstin" ),
371+ ),
372+ as_dict = 1 ,
378373 )
379374
380- inward_nil_exempt = query .run (as_dict = True )
381-
382375 inward_nil_exempt_details = {
383376 "gst" : {"intra" : 0.0 , "inter" : 0.0 },
384377 "non_gst" : {"intra" : 0.0 , "inter" : 0.0 },
@@ -391,7 +384,9 @@ def get_inward_nil_exempt(self, state):
391384 d .place_of_supply = "00-" + cstr (state )
392385
393386 supplier_state = address_state_map .get (d .supplier_address ) or state
394- is_intra_state = cstr (supplier_state ) == cstr (d .place_of_supply .split ("-" )[1 ])
387+ is_intra_state = cstr (supplier_state ) == cstr (
388+ d .place_of_supply .split ("-" )[1 ]
389+ )
395390 amount = flt (d .taxable_value , 2 )
396391
397392 if d .gst_treatment != "Non-GST" :
0 commit comments