 from invoice_payments ip
      left outer join bip on ip.id = bip.invoice_payment_id
 where ( coalesce(ip.RECORD_ID, 'NULL') != coalesce(bip.invoice_payment_record_id,'NULL')
-      or  coalesce(ip.ID, 'NULL') != coalesce(bip.invoice_payment_id,'NULL')
-      or  coalesce(ip.invoice_id, 'NULL') != coalesce(bip.invoice_id,'NULL')
-      or  coalesce(ip.type, 'NULL') != coalesce(bip.invoice_payment_type,'NULL')
-      or  coalesce(ip.linked_invoice_payment_id, 'NULL') != coalesce(bip.linked_invoice_payment_id,'NULL')
-      or  coalesce(ip.amount, 'NULL') != coalesce(bip.amount,'NULL')
-      or  coalesce(ip.currency, 'NULL') != coalesce(bip.currency,'NULL')
-      or  coalesce(ip.created_date, 'NULL') != coalesce(bip.created_date,'NULL')
-      or  coalesce(ip.created_by, 'NULL') != coalesce(bip.created_by,'NULL')
-      or  coalesce(ip.account_record_id, 'NULL') != coalesce(bip.account_record_id,'NULL')
-      -- or  coalesce(ip.tenant_record_id, 'NULL') != coalesce(bip.tenant_record_id,'NULL')
+      or coalesce(ip.ID, 'NULL') != coalesce(bip.invoice_payment_id,'NULL')
+      or coalesce(ip.invoice_id, 'NULL') != coalesce(bip.invoice_id,'NULL')
+      or coalesce(ip.type, 'NULL') != coalesce(bip.invoice_payment_type,'NULL')
+      or coalesce(ip.linked_invoice_payment_id, 'NULL') != coalesce(bip.linked_invoice_payment_id,'NULL')
+      or coalesce(ip.amount, 'NULL') != coalesce(bip.amount,'NULL')
+      or coalesce(ip.currency, 'NULL') != coalesce(bip.currency,'NULL')
+      or coalesce(ip.created_date, 'NULL') != coalesce(bip.created_date,'NULL')
+      or coalesce(ip.account_record_id, 'NULL') != coalesce(bip.account_record_id,'NULL')
+      -- or coalesce(ip.tenant_record_id, 'NULL') != coalesce(bip.tenant_record_id,'NULL')
      )
       and ip.type = 'ATTEMPT'
 

      or ( coalesce(ii.account_id , '')!= coalesce(b.account_id,''))
      or ( coalesce(ii.phase_name, '') != coalesce(b.slug,''))
      or ( coalesce(ii.start_date, '') != coalesce(b.start_date,''))
      -- old trials or ( coalesce(ii.end_date, '') != coalesce(b.end_date,''))
      or ( coalesce(ii.amount, '') != coalesce(b.amount,''))
      or ( coalesce(ii.currency, '') != coalesce(b.currency,''))
      or ( coalesce(ii.linked_item_id, '') != coalesce(b.linked_item_id,''))
      or ( coalesce(ii.created_by, '') != coalesce(b.created_by,''))
      or ( coalesce(ii.created_date, '') != coalesce(b.created_date,''))
      or ( coalesce(ii.account_record_id, '') != coalesce(b.account_record_id,''))
      -- RI-1966 or ( coalesce(ii.tenant_record_id, '') != coalesce(b.tenant_record_id,''))
      or ii.type not in ('CREDIT_ADJ')

-- B2
select *

      or ( coalesce(ii.account_id , '')!= coalesce(bii.account_id,''))
      or ( coalesce(ii.phase_name, '') != coalesce(bii.slug,''))
      or ( coalesce(ii.start_date, '') != coalesce(bii.start_date,''))
      -- RI-1986 or ( coalesce(ii.end_date, ii.start_date + interval 30 day) != coalesce(b.end_date,''))
      or ( coalesce(ii.amount, '') != coalesce(bii.amount,''))
      or ( coalesce(ii.currency, '') != coalesce(bii.currency,''))
      or ( coalesce(ii.linked_item_id, '') != coalesce(bii.linked_item_id,''))
      or ( coalesce(ii.created_date, '') != coalesce(bii.created_date,''))
      or ( coalesce(ii.account_record_id, '') != coalesce(bii.account_record_id,''))
      or ( coalesce(ii.tenant_record_id, '') != coalesce(bii.tenant_record_id,''))
      )

-- C1b
