Avoiding tax variance corrections in AP when PO encumberance accounting is not used (Bug16881142)
We were hitting bug 16881142 where variance corrections are posted to GL if the tax calculated on the invoice differs from the tax calculated on the PO, e.g. due to tax code or tax rate changes (which we still think is a bug and not a "desirable feature").
/* Outer loop to make sure we only re-tax every PO once */ FOR po_headers IN (SELECT DISTINCT pla.po_header_id , zldf.first_pty_org_id , zldf.internal_organization_id FROM ap_invoice_lines_interface aili JOIN ap_invoices_interface aii ON (aii.invoice_id = aili.invoice_id) JOIN po_lines_all pla ON (aili.po_line_id = pla.po_line_id) JOIN po_line_locations_all plla ON (plla.po_line_id = pla.po_line_id) JOIN zx_lines_det_factors zldf ON (zldf.trx_line_id = plla.line_location_id) WHERE aili.tax_classification_code != zldf.input_tax_classification_code AND zldf.entity_code = 'PURCHASE_ORDER' AND zldf.trx_level_type = 'SHIPMENT' AND (aii.status <> 'PROCESSED' OR aii.status IS NULL) ) LOOP BEGIN SAVEPOINT po_header; FOR po_lines IN (SELECT zldf.rowid , aili.tax_classification_code , zldf.object_version_number , pla.po_line_id , plla.line_location_id FROM ap_invoice_lines_interface aili JOIN ap_invoices_interface aii ON