Wednesday, December 15, 2021

Query to list Geography's without Jurisdiction's in Oracle APPS EB-Tax

SELECT * 
  FROM(SELECT geography_type
             ,geography_element2_code state_code
,geography_element3_code county_code
,geography_element4_code city_code
         FROM hz_geographies geography
        WHERE geography.geography_type='STATE'
          AND SYSDATE BETWEEN geography.start_date AND geography.end_date
          AND geography_element1_code='US'
          AND NOT EXISTS (SELECT 1 
                            FROM zx_jurisdictions_b tax_juridiction
                           WHERE tax_juridiction.zone_geography_id=geography.geography_id
                             AND tax_juridiction.tax_regime_code = '<<TAX_REGIME_CODE>>'
                             AND SYSDATE BETWEEN tax_juridiction.effective_from AND NVL(tax_juridiction.effective_to,'31-DEC-4999')
                             AND tax_juridiction.tax=geography.geography_type
)
UNION
    SELECT geography_type
      ,geography_element2_code state_code
  ,geography_element3_code county_code
  ,geography_element4_code city_code
          FROM hz_geographies geography
         WHERE geography.geography_type='COUNTY'
           AND SYSDATE BETWEEN geography.start_date AND geography.end_date
           AND geography_element1_code='US'
           AND NOT EXISTS (SELECT 1 
                             FROM zx_jurisdictions_b tax_juridiction
                            WHERE tax_juridiction.zone_geography_id=geography.geography_id
                              AND tax_juridiction.tax_regime_code='<<TAX_REGIME_CODE>>'
                              AND SYSDATE BETWEEN tax_juridiction.effective_from AND NVL(tax_juridiction.effective_to,'31-DEC-4999')
                              AND tax_juridiction.tax=geography.geography_type
)
UNION
SELECT geography_type
      ,geography_element2_code state_code
  ,geography_element3_code county_code
  ,geography_element4_code city_code
  FROM hz_geographies geography
WHERE geography.geography_type='CITY'
    AND SYSDATE BETWEEN geography.start_date AND geography.end_date
    AND geography_element1_code='US'
    AND NOT EXISTS (SELECT 1 
                      FROM zx_jurisdictions_b tax_juridiction
                     WHERE tax_juridiction.zone_geography_id = geography.geography_id
                       AND tax_juridiction.tax_regime_code='_<<TAX_REGIME_CODE>>'
                       AND SYSDATE BETWEEN tax_juridiction.effective_from AND NVL(tax_juridiction.effective_to,'31-DEC-4999')
                                   AND tax_juridiction.tax=geography.geography_type
                                )
      )
ORDER BY geography_type
        ,state_code
,county_code
,city_code

2 comments:

SupplierAddressImportTemplate.xlsm South Africa Suburb Field mapping in POZ_SUPPLIER_ADDRESSES_INT

Suburb mpping in Supplier Address Import Template will be mapped to Address Element Attribute2 (HZ_LOCATIONS. ADDR_ELEMENT_ATTRIBUTE2)