[Home] [Help]
161: /*-------------------------------------------------------------------------+
162: | PUBLIC PROCEDURE |
163: | implement_transfer_rates |
164: | |
165: | CALLED BY TRIGGER AR_LOCATION_RATES_ASIU |
166: | |
167: | REQUIRES |
168: | |
169: | PL/SQL table: LOCATION_SEGMENT_ID to be populated with the |
167: | REQUIRES |
168: | |
169: | PL/SQL table: LOCATION_SEGMENT_ID to be populated with the |
170: | location_segment_id of each row that has changed in the table |
171: | AR_LOCATION_RATES. |
172: | |
173: | The PUBLIC variable: loc_rate is a count of the number of rows in |
174: | the PL/SQL table: location_segment_id that we can expect and is |
175: | maintained by the trigger: AR_LOCATION_RATES_BRIU |
171: | AR_LOCATION_RATES. |
172: | |
173: | The PUBLIC variable: loc_rate is a count of the number of rows in |
174: | the PL/SQL table: location_segment_id that we can expect and is |
175: | maintained by the trigger: AR_LOCATION_RATES_BRIU |
176: | |
177: | DESCRIPTION |
178: | |
179: | Will take each distinct location_segment_id used during updates or |
176: | |
177: | DESCRIPTION |
178: | |
179: | Will take each distinct location_segment_id used during updates or |
180: | inserts to the table: AR_LOCATION_RATES and propogate these sales |
181: | tax rate changes into the table: AR_SALES_TAX |
182: | |
183: | This procedures fires the cursor: sel_cc to find each Location Code |
184: | Combination that uses a particular location_segment_id and then |
195: | CA.SAN MATEO.FOSTER CITY CCID: 1001, LOCATIONS: 4.6.10 |
196: | CA.FREEMONT.FREEMONT CCID: 1002, LOCATIONS: 4.12.14 |
197: | FL.MIAMI.MIAMI CCID: 1003, LOCATIONS: 16.18.20 |
198: | |
199: | And the user updates AR_LOCATION_RATES for ( CA, and SAN MATEO ) |
200: | There would be two rows set up by the TRIGGER: AR_LOCATION_RATES_BRIU |
201: | in the PL/SQL table: location_segment_id, these rows would be: |
202: | location_segment_id(0) = 4 |
203: | location_segment_id(1) = 6 |
196: | CA.FREEMONT.FREEMONT CCID: 1002, LOCATIONS: 4.12.14 |
197: | FL.MIAMI.MIAMI CCID: 1003, LOCATIONS: 16.18.20 |
198: | |
199: | And the user updates AR_LOCATION_RATES for ( CA, and SAN MATEO ) |
200: | There would be two rows set up by the TRIGGER: AR_LOCATION_RATES_BRIU |
201: | in the PL/SQL table: location_segment_id, these rows would be: |
202: | location_segment_id(0) = 4 |
203: | location_segment_id(1) = 6 |
204: | This procedure would fire the cursor: sel_cc which for location 4 |
467: /*-------------------------------------------------------------------------+
468: | PUBLIC FUNCTION |
469: | Initialise_Transfer_Rates |
470: | |
471: | CALLED BY TRIGGER AR_LOCATION_RATES_BSIU |
472: | |
473: | DESCRIPTION |
474: | |
475: | Initialise the public variable: location_rates_transfer_id with the |
472: | |
473: | DESCRIPTION |
474: | |
475: | Initialise the public variable: location_rates_transfer_id with the |
476: | value from the sequence: AR_LOCATION_RATES_TRASNFER_S |
477: | |
478: | For each set of inserted or updateed rows in the table AR_LOCATION_RATES|
479: | a distinct value is placed in the column: AR_TRANSFER_CONTROL_ID |
480: | When all records have been inserted or updated, the after statement |
474: | |
475: | Initialise the public variable: location_rates_transfer_id with the |
476: | value from the sequence: AR_LOCATION_RATES_TRASNFER_S |
477: | |
478: | For each set of inserted or updateed rows in the table AR_LOCATION_RATES|
479: | a distinct value is placed in the column: AR_TRANSFER_CONTROL_ID |
480: | When all records have been inserted or updated, the after statement |
481: | trigger: AR_LOCATION_RATES_ASIU fires, and refetchs each of these new |
482: | records across into the table: AR_SALES_TAX |
477: | |
478: | For each set of inserted or updateed rows in the table AR_LOCATION_RATES|
479: | a distinct value is placed in the column: AR_TRANSFER_CONTROL_ID |
480: | When all records have been inserted or updated, the after statement |
481: | trigger: AR_LOCATION_RATES_ASIU fires, and refetchs each of these new |
482: | records across into the table: AR_SALES_TAX |
483: | |
484: | This works around the kernel limitation of MUTATING tables. |
485: | |
530: | DESCRIPTION |
531: | |
532: | Generate records in the table: AR_SALES_TAX for the new location_CCID |
533: | These records will be derived from multiple records in the table |
534: | AR_LOCATION_RATES. |
535: | |
536: | For each enabled segment in the "Tax Location Flexfield", find |
537: | every sales tax rate, zip and date range. Note if two rates |
538: | have different, mutually exclusive date or zip code ranges |
641: and tax.enabled_flag = 'Y'
642: and not exists (
643: select
644: 'x'
645: from ar_location_rates r1,
646: ar_location_rates r2,
647: ar_location_rates r3
648: where r1.location_segment_id = p_location_id_segment_1
649: and r2.location_segment_id = p_location_id_segment_2
642: and not exists (
643: select
644: 'x'
645: from ar_location_rates r1,
646: ar_location_rates r2,
647: ar_location_rates r3
648: where r1.location_segment_id = p_location_id_segment_1
649: and r2.location_segment_id = p_location_id_segment_2
650: and r3.location_segment_id = p_location_id_segment_3
643: select
644: 'x'
645: from ar_location_rates r1,
646: ar_location_rates r2,
647: ar_location_rates r3
648: where r1.location_segment_id = p_location_id_segment_1
649: and r2.location_segment_id = p_location_id_segment_2
650: and r3.location_segment_id = p_location_id_segment_3
651: And R1.FROM_POSTAL_CODE <= TAX.FROM_POSTAL_CODE
821: least( r1.end_date ,
822: r2.end_date ,
823: r3.end_date ),
824: 'Y' /* Enabled Flag */
825: from ar_location_rates r1,
826: ar_location_rates r2,
827: ar_location_rates r3
828: where r1.location_segment_id = p_location_id_segment_1
829: and r2.location_segment_id = p_location_id_segment_2
822: r2.end_date ,
823: r3.end_date ),
824: 'Y' /* Enabled Flag */
825: from ar_location_rates r1,
826: ar_location_rates r2,
827: ar_location_rates r3
828: where r1.location_segment_id = p_location_id_segment_1
829: and r2.location_segment_id = p_location_id_segment_2
830: and r3.location_segment_id = p_location_id_segment_3
823: r3.end_date ),
824: 'Y' /* Enabled Flag */
825: from ar_location_rates r1,
826: ar_location_rates r2,
827: ar_location_rates r3
828: where r1.location_segment_id = p_location_id_segment_1
829: and r2.location_segment_id = p_location_id_segment_2
830: and r3.location_segment_id = p_location_id_segment_3
831: and greatest( r1.from_postal_code,
902: least( r1.end_date ,
903: r2.end_date ,
904: r3.end_date ),
905: 'Y' /* Enabled Flag */
906: from ar_location_rates r1,
907: ar_location_rates r2,
908: ar_location_rates r3
909: where r1.location_segment_id = p_location_id_segment_1
910: and r2.location_segment_id = p_location_id_segment_2
903: r2.end_date ,
904: r3.end_date ),
905: 'Y' /* Enabled Flag */
906: from ar_location_rates r1,
907: ar_location_rates r2,
908: ar_location_rates r3
909: where r1.location_segment_id = p_location_id_segment_1
910: and r2.location_segment_id = p_location_id_segment_2
911: and r3.location_segment_id = p_location_id_segment_3
904: r3.end_date ),
905: 'Y' /* Enabled Flag */
906: from ar_location_rates r1,
907: ar_location_rates r2,
908: ar_location_rates r3
909: where r1.location_segment_id = p_location_id_segment_1
910: and r2.location_segment_id = p_location_id_segment_2
911: and r3.location_segment_id = p_location_id_segment_3
912: and greatest( r1.from_postal_code,
1884: | CALLED BY package upgrade_sales_tax |
1885: | |
1886: | DESCRIPTION |
1887: | The tax rates will be combined and stored as the sales tax during |
1888: | the upgrade. The rates are taken from the AR_LOCATION_RATES table |
1889: | and combined as the combination is defined in AR_LOCATION_ |
1890: | COMBINATIONS |
1891: | |
1892: | |
1944: least( r1.end_date ,
1945: r2.end_date ,
1946: r3.end_date ),
1947: 'Y'
1948: from ar_location_rates r1,
1949: ar_location_rates r2,
1950: ar_location_rates r3,
1951: AR_LOCATION_COMBINATIONS ccid
1952: where ccid.LOCATION_ID_SEGMENT_1 = r1.location_segment_id and
1945: r2.end_date ,
1946: r3.end_date ),
1947: 'Y'
1948: from ar_location_rates r1,
1949: ar_location_rates r2,
1950: ar_location_rates r3,
1951: AR_LOCATION_COMBINATIONS ccid
1952: where ccid.LOCATION_ID_SEGMENT_1 = r1.location_segment_id and
1953: ccid.LOCATION_ID_SEGMENT_2 = r2.location_segment_id and
1946: r3.end_date ),
1947: 'Y'
1948: from ar_location_rates r1,
1949: ar_location_rates r2,
1950: ar_location_rates r3,
1951: AR_LOCATION_COMBINATIONS ccid
1952: where ccid.LOCATION_ID_SEGMENT_1 = r1.location_segment_id and
1953: ccid.LOCATION_ID_SEGMENT_2 = r2.location_segment_id and
1954: ccid.LOCATION_ID_SEGMENT_3 = r3.location_segment_id