select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Sales Invoice' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`salesInvoiceDate` AS `transDate`,`a`.`customerID` AS `customerID`,`d`.`customerName` AS `customerName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_sales_invoice` `a` join `iaccountdb`.`comp_sales_invoice_detail` `b`) join `iaccountdb`.`customer` `d`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`invoiceID`) and (`a`.`customerID` = `d`.`ID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Sales Invoice' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`salesInvoiceDate` AS `transDate`,`a`.`customerID` AS `customerID`,`d`.`customerName` AS `customerName`,`b`.`chargeDescription` AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_sales_invoice` `a` join `iaccountdb`.`comp_sales_invoice_charges` `b`) join `iaccountdb`.`customer` `d`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`invoiceID`) and (`a`.`customerID` = `d`.`ID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Sales Credit Note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`creditNoteDate` AS `transDate`,`a`.`customerID` AS `customerID`,`d`.`customerName` AS `customerName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,(`b`.`amountExcludedTax` * -(1)) AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,(`b`.`taxAmount` * -(1)) AS `taxAmount`,(`b`.`amountIncludedTax` * -(1)) AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_sales_creditnote` `a` join `iaccountdb`.`comp_sales_creditnote_detail` `b`) join `iaccountdb`.`customer` `d`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`creditnoteID`) and (`a`.`customerID` = `d`.`ID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Sales Credit Note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`creditNoteDate` AS `transDate`,`a`.`customerID` AS `customerID`,`d`.`customerName` AS `customerName`,`b`.`chargeDescription` AS `itemName`,(`b`.`amountExcludedTax` * -(1)) AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,(`b`.`taxAmount` * -(1)) AS `taxAmount`,(`b`.`amountIncludedTax` * -(1)) AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_sales_creditnote` `a` join `iaccountdb`.`comp_sales_creditnote_charges` `b`) join `iaccountdb`.`customer` `d`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`creditNoteID`) and (`a`.`customerID` = `d`.`ID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`d`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Sales Debit note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`debitNoteDate` AS `transDate`,`a`.`customerID` AS `customerID`,`d`.`customerName` AS `customerName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_sales_debitnote` `a` join `iaccountdb`.`comp_sales_debitnote_detail` `b`) join `iaccountdb`.`customer` `d`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`debitnoteID`) and (`a`.`customerID` = `d`.`ID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Sales Debit Note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`debitNoteDate` AS `transDate`,`a`.`customerID` AS `customerID`,`d`.`customerName` AS `customerName`,`b`.`chargeDescription` AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_sales_debitnote` `a` join `iaccountdb`.`comp_sales_debitnote_charges` `b`) join `iaccountdb`.`customer` `d`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`debitNoteID`) and (`a`.`customerID` = `d`.`ID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`d`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Purchase Invoice' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`invoiceDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`d`.`supplierName` AS `supplierName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_supplier_invoice` `a` join `iaccountdb`.`comp_supplier_invoice_detail` `b`) join `iaccountdb`.`supplier` `d`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`invoiceID`) and (`a`.`supplierID` = `d`.`ID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Purchase Invoice' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`invoiceDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`d`.`supplierName` AS `supplierName`,`b`.`chargeDescription` AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_supplier_invoice` `a` join `iaccountdb`.`comp_supplier_invoice_charges` `b`) join `iaccountdb`.`supplier` `d`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`invoiceID`) and (`a`.`supplierID` = `d`.`ID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`d`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Purchase Credit Note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`creditNoteDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`d`.`supplierName` AS `supplierName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_supplier_creditnote` `a` join `iaccountdb`.`comp_supplier_creditnote_detail` `b`) join `iaccountdb`.`supplier` `d`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`creditnoteID`) and (`a`.`supplierID` = `d`.`ID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Purchase Credit Note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`creditNoteDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`d`.`supplierName` AS `supplierName`,`b`.`itemdescription` AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_supplier_creditnote` `a` join `iaccountdb`.`comp_supplier_creditnote_charges` `b`) join `iaccountdb`.`supplier` `d`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`creditNoteID`) and (`a`.`supplierID` = `d`.`ID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`d`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Purchase Debit note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`debitNoteDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`d`.`supplierName` AS `supplierName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,(`b`.`amountExcludedTax` * -(1)) AS `b.amountExcludedTax * -1`,`b`.`taxRate` AS `taxRate`,(`b`.`taxAmount` * -(1)) AS `b.taxAmount * -1`,(`b`.`amountIncludedTax` * -(1)) AS `b.amountIncludedTax * -1`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_supplier_debitnote` `a` join `iaccountdb`.`comp_supplier_debitnote_detail` `b`) join `iaccountdb`.`supplier` `d`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`debitnoteID`) and (`a`.`supplierID` = `d`.`ID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Purchase Debit Note' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`debitNoteDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`d`.`supplierName` AS `supplierName`,`b`.`itemdescription` AS `itemName`,(`b`.`amountExcludedTax` * -(1)) AS `b.amountExcludedTax * -1`,`b`.`taxRate` AS `taxRate`,(`b`.`taxAmount` * -(1)) AS `b.taxAmount * -1`,(`b`.`amountIncludedTax` * -(1)) AS `b.amountIncludedTax * -1`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_supplier_debitnote` `a` join `iaccountdb`.`comp_supplier_debitnote_charges` `b`) join `iaccountdb`.`supplier` `d`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`debitNoteID`) and (`a`.`supplierID` = `d`.`ID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`d`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Other Payment' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`paymentDate` AS `transDate`,NULL AS `NULL`,`a`.`payTo` AS `supplierName`,`b`.`itemdescription` AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((`iaccountdb`.`comp_payment_others` `a` join `iaccountdb`.`comp_payment_others_without_item` `b`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`otherPaymentID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Cash Sales' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`salesInvoiceDate` AS `transDate`,NULL AS `customerID`,`a`.`paymentFrom` AS `customerName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_cash_sales` `a` join `iaccountdb`.`comp_cash_sales_detail` `b`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`invoiceID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Other Receive' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`receivePaymentDate` AS `transDate`,NULL AS `customerID`,`a`.`receiveFrom` AS `customerName`,`b`.`description` AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((`iaccountdb`.`comp_receive_payment_others` `a` join `iaccountdb`.`comp_receive_payment_others_detail` `b`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`receivePaymentOthersID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `b`.`ID` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,`a`.`type` AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`date` AS `transDate`,NULL AS `supplierID`,`a`.`vendor_cust_name` AS `supplierName`,`b`.`description` AS `itemName`,if((`a`.`reverse` > 0),(`a`.`based_amount` * -(1)),`a`.`based_amount`) AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,if((`a`.`reverse` > 0),(if((`b`.`taxAmountDr` > 0),`b`.`taxAmountDr`,`b`.`taxAmountCr`) * -(1)),if((`b`.`taxAmountDr` > 0),`b`.`taxAmountDr`,`b`.`taxAmountCr`)) AS `taxAmount`,if((`a`.`reverse` > 0),((if((`b`.`taxAmountDr` > 0),`b`.`taxAmountDr`,`b`.`taxAmountCr`) + `a`.`based_amount`) * -(1)),(if((`b`.`taxAmountDr` > 0),`b`.`taxAmountDr`,`b`.`taxAmountCr`) + `a`.`based_amount`)) AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((`iaccountdb`.`comp_gst_transaction` `a` join `iaccountdb`.`comp_gst_transaction_detail` `b`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`gstTransID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`isDelete` = 0)) union select `b`.`lineNo` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Cash Purchase' AS `transType`,concat(`a`.`formNo`,'[',convert(lpad(`a`.`serialNo`,8,'0') using latin1),']') AS `ref`,`a`.`paymentDate` AS `transDate`,NULL AS `supplierID`,`a`.`payTo` AS `supplierName`,concat(`e`.`name`,' / ',`e`.`itemCode`) AS `itemName`,`b`.`amountExcludedTax` AS `amountExcludedTax`,`b`.`taxRate` AS `taxRate`,`b`.`taxAmount` AS `taxAmount`,`b`.`amountIncludedTax` AS `amountIncludedTax`,`b`.`taxID` AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_payment_others` `a` join `iaccountdb`.`comp_payment_others_with_item` `b`) join `iaccountdb`.`item` `e`) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`a`.`ID` = `b`.`otherPaymentID`) and (`e`.`ID` = `b`.`itemID`) and (`f`.`ID` = `b`.`taxID`) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`f`.`taxClass` = 1) and (`b`.`taxID` > 0) and (`a`.`updateAble` = 0) and (`e`.`companyID` = `a`.`companyID`) and (`f`.`companyID` = `a`.`companyID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8)) and (`j`.`status` = 1) and (`a`.`is_delete` = 0)) union select `a`.`ID` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Bad debt relief' AS `transType`,`a`.`journalNo` AS `ref`,`a`.`transDate` AS `transDate`,NULL AS `supplierID`,`c`.`customerName` AS `supplierName`,concat(`b`.`formNo`,'[',convert(lpad(`b`.`serialNo`,8,'0') using latin1),']') AS `itemName`,round((((((round(`b`.`totalReceivable`,2) / round(`b`.`totalamount`,2)) * round(`b`.`totalTaxAmount`,2)) * 106) / 6) - ((round(`b`.`totalReceivable`,2) / round(`b`.`totalamount`,2)) * round(`b`.`totalTaxAmount`,2))),2) AS `amountExcludedTax`,`f`.`taxPercentage` AS `taxRate`,round(((`b`.`totalReceivable` / `b`.`totalamount`) * `b`.`totalTaxAmount`),2) AS `taxAmount`,round((round((((((`b`.`totalReceivable` / `b`.`totalamount`) * `b`.`totalTaxAmount`) * 106) / 6) - ((`b`.`totalReceivable` / `b`.`totalamount`) * `b`.`totalTaxAmount`)),2) + ((`b`.`totalReceivable` / `b`.`totalamount`) * `b`.`totalTaxAmount`)),2) AS `amountIncludedTax`,NULL AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((`iaccountdb`.`comp_sales_bad_debt` `a` join `iaccountdb`.`comp_sales_invoice` `b` on((`b`.`badDebtID` = `a`.`ID`))) join `iaccountdb`.`customer` `c` on((`c`.`ID` = `a`.`customerID`))) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`f`.`companyID` = `a`.`companyID`) and (`f`.`code` = 'AJP') and (`a`.`updateAble` = 0) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`a`.`updateAble` = 0) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8))) union select `a`.`ID` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Bad debt Recover' AS `transType`,`a`.`journalNo` AS `ref`,`a`.`transDate` AS `transDate`,NULL AS `supplierID`,`c`.`customerName` AS `supplierName`,concat(`y`.`formNo`,'[',convert(lpad(`y`.`serialNo`,8,'0') using latin1),']') AS `itemName`,round((((((round(`b`.`amountApplied`,2) / round(`y`.`totalamount`,2)) * round(`y`.`totalTaxAmount`,2)) * 106) / 6) - ((round(`b`.`amountApplied`,2) / round(`y`.`totalamount`,2)) * round(`y`.`totalTaxAmount`,2))),2) AS `amountExcludedTax`,`f`.`taxPercentage` AS `taxRate`,round(((`b`.`amountApplied` / `y`.`totalamount`) * `y`.`totalTaxAmount`),2) AS `taxAmount`,round((round((((((`b`.`amountApplied` / `y`.`totalamount`) * `y`.`totalTaxAmount`) * 106) / 6) - ((`b`.`amountApplied` / `y`.`totalamount`) * `y`.`totalTaxAmount`)),2) + ((`b`.`amountApplied` / `y`.`totalamount`) * `y`.`totalTaxAmount`)),2) AS `amountIncludedTax`,NULL AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_sales_debt_recover` `a` join `iaccountdb`.`comp_receive_payment_detail` `b` on((`b`.`debtRecoverID` = `a`.`ID`))) left join `iaccountdb`.`comp_sales_invoice` `y` on((`y`.`ID` = `b`.`invoiceID`))) join `iaccountdb`.`customer` `c` on((`c`.`ID` = `a`.`customerID`))) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`f`.`companyID` = `a`.`companyID`) and (`f`.`code` = 'AJS') and (`a`.`updateAble` = 0) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8))) union select `a`.`ID` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Supplier Bad debt relief' AS `transType`,`a`.`journalNo` AS `ref`,`a`.`transDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`c`.`supplierName` AS `supplierName`,concat(`b`.`formNo`,'[',convert(lpad(`b`.`serialNo`,8,'0') using latin1),']') AS `itemName`,round((((((round((`b`.`totalPayable` + ifnull(sum(`p`.`amountApplied`),0)),2) / round(`b`.`totalAmount`,2)) * round(`b`.`totalTaxAmount`,2)) * 106) / 6) - ((round((`b`.`totalPayable` + ifnull(sum(`p`.`amountApplied`),0)),2) / round(`b`.`totalAmount`,2)) * round(`b`.`totalTaxAmount`,2))),2) AS `amountExcludedTax`,`f`.`taxPercentage` AS `taxRate`,round((((`b`.`totalPayable` + ifnull(sum(`p`.`amountApplied`),0)) / `b`.`totalAmount`) * `b`.`totalTaxAmount`),2) AS `taxAmount`,(round((((((round((`b`.`totalPayable` + ifnull(sum(`p`.`amountApplied`),0)),2) / round(`b`.`totalAmount`,2)) * round(`b`.`totalTaxAmount`,2)) * 106) / 6) - ((round((`b`.`totalPayable` + ifnull(sum(`p`.`amountApplied`),0)),2) / round(`b`.`totalAmount`,2)) * round(`b`.`totalTaxAmount`,2))),2) + round((((`b`.`totalPayable` + ifnull(sum(`p`.`amountApplied`),0)) / `b`.`totalAmount`) * `b`.`totalTaxAmount`),2)) AS `amountIncludedTax`,NULL AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from (((((((((`iaccountdb`.`comp_purchase_bad_debt` `a` join `iaccountdb`.`comp_supplier_invoice` `b` on((`b`.`badDebtID` = `a`.`ID`))) join `iaccountdb`.`comp_payment_detail` `p` on((`p`.`purchaseInvoiceID` = `b`.`ID`))) join `iaccountdb`.`comp_payment` `pay` on(((`pay`.`ID` = `p`.`paymentID`) and (`pay`.`paymentDate` > `a`.`transDate`)))) join `iaccountdb`.`supplier` `c` on((`c`.`ID` = `a`.`supplierID`))) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`f`.`companyID` = `a`.`companyID`) and (`f`.`code` = 'AJS') and (`a`.`updateAble` = 0) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8))) group by `p`.`purchaseInvoiceID` union select `a`.`ID` AS `lineNo`,`a`.`companyID` AS `companyID`,`f`.`taxClass` AS `taxClass`,`h`.`description` AS `taxClassName`,`f`.`taxGroup` AS `taxGroup`,`i`.`description` AS `taxGroupName`,`f`.`taxType` AS `taxType`,`g`.`description` AS `taxTypeName`,'Supplier Bad debt Recover' AS `transType`,`a`.`journalNo` AS `ref`,`a`.`transDate` AS `transDate`,`a`.`supplierID` AS `supplierID`,`c`.`supplierName` AS `supplierName`,concat(`y`.`formNo`,'[',convert(lpad(`y`.`serialNo`,8,'0') using latin1),']') AS `itemName`,round((((((round(`b`.`amountApplied`,2) / round(`y`.`totalAmount`,2)) * round(`y`.`totalTaxAmount`,2)) * 106) / 6) - ((round(`b`.`amountApplied`,2) / round(`y`.`totalAmount`,2)) * round(`y`.`totalTaxAmount`,2))),2) AS `amountExcludedTax`,`f`.`taxPercentage` AS `taxRate`,round(((`b`.`amountApplied` / `y`.`totalAmount`) * `y`.`totalTaxAmount`),2) AS `taxAmount`,round((round((((((`b`.`amountApplied` / `y`.`totalAmount`) * `y`.`totalTaxAmount`) * 106) / 6) - ((`b`.`amountApplied` / `y`.`totalAmount`) * `y`.`totalTaxAmount`)),2) + ((`b`.`amountApplied` / `y`.`totalAmount`) * `y`.`totalTaxAmount`)),2) AS `amountIncludedTax`,NULL AS `taxID`,`f`.`code` AS `gst`,`j`.`journalID` AS `journalID`,`j`.`formNo` AS `formNo` from ((((((((`iaccountdb`.`comp_purchase_debt_recover` `a` join `iaccountdb`.`comp_payment_detail` `b` on((`b`.`debtRecoverID` = `a`.`ID`))) left join `iaccountdb`.`comp_supplier_invoice` `y` on((`y`.`ID` = `b`.`purchaseInvoiceID`))) join `iaccountdb`.`supplier` `c` on((`c`.`ID` = `a`.`supplierID`))) join `iaccountdb`.`tax_master` `f`) join `iaccountdb`.`tax_type` `g`) join `iaccountdb`.`tax_class` `h`) join `iaccountdb`.`tax_group` `i`) join `iaccountdb`.`comp_journal` `j`) where ((`f`.`companyID` = `a`.`companyID`) and (`f`.`code` = 'AJP') and (`a`.`updateAble` = 0) and (`f`.`taxType` = `g`.`ID`) and (`f`.`taxClass` = `h`.`ID`) and (`f`.`taxGroup` = `i`.`ID`) and (`j`.`companyID` = `a`.`companyID`) and (`j`.`journalID` = convert(`a`.`journalNo` using utf8))) 