45: | PUBLIC FUNCTION |
46: | ins_sales_tax |
47: | |
48: | DESCRIPTION |
49: | This function generates a new record in the table: AR_SALES_TAX |
50: | and returns the SALES_TAX_ID of this new record |
51: | |
52: | REQUIRES |
53: | location_id CCID of this Location |
98: to_postal_code in varchar2,
99: start_date in date,
100: end_date in date) return number IS
101:
102: CURSOR ar_sales_tax_s_c is
103: select ar_sales_tax_s.nextval + arp_standard.sequence_offset
104: from dual;
105:
106: sales_tax_id NUMBER;
99: start_date in date,
100: end_date in date) return number IS
101:
102: CURSOR ar_sales_tax_s_c is
103: select ar_sales_tax_s.nextval + arp_standard.sequence_offset
104: from dual;
105:
106: sales_tax_id NUMBER;
107:
112: IF PG_DEBUG = 'Y' THEN
113: arp_util_tax.debug( '>> INS_SALES_TAX' );
114: END IF;
115:
116: OPEN ar_sales_tax_s_c;
117: FETCH ar_sales_tax_s_c into sales_tax_id;
118: CLOSE ar_sales_tax_s_c;
119:
120: insert into ar_sales_tax(
113: arp_util_tax.debug( '>> INS_SALES_TAX' );
114: END IF;
115:
116: OPEN ar_sales_tax_s_c;
117: FETCH ar_sales_tax_s_c into sales_tax_id;
118: CLOSE ar_sales_tax_s_c;
119:
120: insert into ar_sales_tax(
121: SALES_TAX_ID,
114: END IF;
115:
116: OPEN ar_sales_tax_s_c;
117: FETCH ar_sales_tax_s_c into sales_tax_id;
118: CLOSE ar_sales_tax_s_c;
119:
120: insert into ar_sales_tax(
121: SALES_TAX_ID,
122: LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN,
116: OPEN ar_sales_tax_s_c;
117: FETCH ar_sales_tax_s_c into sales_tax_id;
118: CLOSE ar_sales_tax_s_c;
119:
120: insert into ar_sales_tax(
121: SALES_TAX_ID,
122: LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN,
123: CREATED_BY, CREATION_DATE,
124: LOCATION_ID,
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 |
185: | updates each of the rows in ar_sales_tax for that specific location. |
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 |
185: | updates each of the rows in ar_sales_tax for that specific location. |
186: | |
187: | To optimise performance of the code a note of every code combination |
188: | is made so that the same set of records in ar_sales_tax is only ever |
189: | visited once. |
184: | Combination that uses a particular location_segment_id and then |
185: | updates each of the rows in ar_sales_tax for that specific location. |
186: | |
187: | To optimise performance of the code a note of every code combination |
188: | is made so that the same set of records in ar_sales_tax is only ever |
189: | visited once. |
190: | |
191: | EXAMPLE |
192: | |
266:
267: /*------------------------------------------------------------------------+
268: | For each distinct location_segment_id that had a rate insert or update |
269: | assocaited with it, find each distinct location_ccid and update |
270: | the table: AR_SALES_TAX for this location_ccid, updating rate |
271: | assignments |
272: +------------------------------------------------------------------------*/
273:
274: FOR i in 1 .. loc_rate
391: | |
392: | Find the location CCID for the address used by this site use, and all |
393: | of the segment id's in use by this locaiton code combination. |
394: | |
395: | Re-Populates AR_SALES_TAX with rate information. |
396: | |
397: | MODIFIES |
398: | |
399: | EXCEPTIONS RAISED |
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: | |
486: | MODIFIES |
528: | CALLED BY TRIGGER RA_LOCATION_COMBINATIONS_BRIU |
529: | |
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 |
635: p_location_id_segment_9 in number,
636: p_location_id_segment_10 in number ) is
637:
638: select rowid, sales_tax_id
639: from ar_sales_tax tax
640: where tax.location_id = p_location_id
641: and tax.enabled_flag = 'Y'
642: and not exists (
643: select
735: -- So we can delete it.
736: --
737: IF RateUsed%NOTFOUND THEN
738: --
739: DELETE FROM ar_sales_tax
740: WHERE rowid = tax_rate_rec.rowid;
741: --
742: ELSE
743: --
746: -- So we do not want to delete it,intead, set enabled to 'N'
747: -- (This part is added because the AR foreign key constraint
748: -- is not shipped to customers )
749: --
750: UPDATE ar_sales_tax SET enabled_flag = 'N',
751: last_update_date = sysdate,
752: last_updated_by = arp_standard.profile.user_id
753: WHERE rowid = tax_rate_rec.rowid;
754: END IF;
760:
761: /*-----------------------------------------------------------------------+
762: | Generate new sales tax records, by combining location rates from each |
763: | of the segment values of the location flexfield. |
764: | Only location rates that do not already exist in the ar_sales_tax |
765: | table are inserted. |
766: +-----------------------------------------------------------------------*/
767:
768: IF PG_DEBUG = 'Y' THEN
778:
779: if statement_type = 'Update'
780: THEN
781:
782: insert into ar_sales_tax(
783: SALES_TAX_ID,
784: LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN,
785: CREATED_BY, CREATION_DATE,
786: LOCATION_ID,
794: start_date,
795: end_date,
796: enabled_flag)
797: select
798: AR_SALES_TAX_S.NEXTVAL+arp_standard.sequence_offset,
799: sysdate,
800: arp_standard.profile.user_id,
801: null,
802: arp_standard.profile.user_id,
838: r3.start_date ) <= least( r1.end_date ,
839: r2.end_date ,
840: r3.end_date )
841: and not exists (
842: select 'x' from ar_sales_tax tax
843: where tax.location_id = location_ccid
844: and tax.location1_rate = decode( r3.override_rate1, null, nvl(r1.tax_rate,0), r3.override_rate1)
845: and tax.location2_rate = decode( r3.override_rate2, null, nvl(r2.tax_rate,0), r3.override_rate2)
846: and tax.location3_rate = decode( r3.override_rate3, null, nvl(r3.tax_rate,0), r3.override_rate3)
859: and tax.enabled_flag = 'Y' );
860:
861: ELSE /* Statement type is INSERT, dont us: not exists clause */
862:
863: insert into ar_sales_tax(
864: SALES_TAX_ID,
865: LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN,
866: CREATED_BY, CREATION_DATE,
867: LOCATION_ID,
875: start_date,
876: end_date,
877: enabled_flag)
878: select
879: AR_SALES_TAX_S.NEXTVAL+arp_standard.sequence_offset,
880: sysdate,
881: arp_standard.profile.user_id,
882: null,
883: arp_standard.profile.user_id,
969:
970: PROCEDURE Purge_Sales_Tax IS
971:
972: CURSOR sel_rates_c IS
973: SELECT rowid, sales_tax_id from ar_sales_tax;
974:
975: CURSOR PurgeRateUsed( p_sales_tax_id IN NUMBER ) IS
976: SELECT 'x' from dual
977: WHERE exists (
999: -- So we can delete it.
1000: --
1001: IF PurgeRateUsed%NOTFOUND THEN
1002: --
1003: DELETE FROM ar_sales_tax
1004: WHERE rowid = tax.rowid;
1005: --
1006: ELSE
1007: --
1010: -- So we do not want to delete it,intead, set enabled to 'N'
1011: -- (This part is added because the AR foreign key constraint
1012: -- is not shipped to customers )
1013: --
1014: UPDATE ar_sales_tax SET enabled_flag = 'N',
1015: last_update_date = sysdate,
1016: last_updated_by = arp_standard.profile.user_id
1017: WHERE rowid = tax.rowid;
1018: END IF;
1892: | |
1893: | |
1894: | REQUIRES: no arguments |
1895: | |
1896: | MODIFIES: inserts combined rates into AR_SALES_TAX |
1897: | |
1898: +------------------------------------------------------------------------*/
1899:
1900: PROCEDURE combine_tax_rates IS
1898: +------------------------------------------------------------------------*/
1899:
1900: PROCEDURE combine_tax_rates IS
1901: BEGIN
1902: insert into ar_sales_tax(
1903: SALES_TAX_ID,
1904: LAST_UPDATE_DATE,
1905: LAST_UPDATED_BY,
1906: LAST_UPDATE_LOGIN,
1917: start_date,
1918: end_date,
1919: enabled_flag)
1920: select
1921: AR_SALES_TAX_S.NEXTVAL+arp_standard.sequence_offset,
1922: sysdate,
1923: arp_standard.profile.user_id,
1924: null,
1925: arp_standard.profile.user_id,
1963: r2.end_date ,
1964: r3.end_date )
1965: and not exists (
1966: select 'x'
1967: from ar_sales_tax tax
1968: where tax.location_id = ccid.location_id
1969: and tax.location1_rate = decode( r3.override_rate1, null, nvl(r1.tax_rate,0), r3.override_rate1)
1970: and tax.location2_rate = decode( r3.override_rate2, null, nvl(r2.tax_rate,0), r3.override_rate2)
1971: and tax.location3_rate = decode( r3.override_rate3, null, nvl(r3.tax_rate,0), r3.override_rate3)