omfgppc - 2009-03-10

ction will require a new '''taxassign''' composite type used t=
o return the indented list of tax assignments
+ =

  {{{
+ CREATE TYPE taxassign AS
+ (
+   taxassign_taxzone_id integer,
+   taxassign_taxtype_id integer,
+   taxassign_level integer,
+   taxassign_zone_code text,
+   taxassign_type_descrip text,
+   taxassign_taxclass_code text,
+   taxassign_taxclass_sequence integer
+ );
+ }}}
+ Then we can build our function
+ {{{
- CREATE OR REPLACE FUNCTION taxAssignments(INTEGER, INTEGER) RETURNS SETOF=
taxassign AS '
+ CREATE OR REPLACE FUNCTION taxAssignments(INTEGER, INTEGER) RETURNS SETOF=
taxassign AS $$
  DECLARE
    pTaxZoneId ALIAS FOR $1;
    pTaxTypeId ALIAS FOR $2;
@@ -312, +350 @@

      END IF;
    END IF;
  =

-   FOR _x IN EXECUTE _qry =

+   FOR _x IN EXECUTE _qry
    LOOP
      Map values to _row here and RETURN NEXT so we get a level tax zone/ty=
pe 0 record.
-     FOR _y IN SELECT all the records with matching _x.taxzone_id and _x.t=
axtype_id from taxass =

+     FOR _y IN SELECT all the records with matching _x.taxzone_id and _x.t=
axtype_id from taxass
      LOOP
        Map results to _row
        RETURN NEXT to get code detail record;
-       =

+ =

        SELECT results FROM taxcodesub(_y.taxassign_taxcode_id, 1) a new re=
cursive function described above
        LOOP
-         Map results for sub codes =

+         Map results for sub codes
          RETURN NEXT return to _row
-       END LOOP;
-     END LOOP;
-   END LOOP;
- }}}
  =

+ ... end loops and function
+ }}}
  A new table function will be created that takes the an input of tax zone,=
tax type,date,currency id, and amount to produce a set of output records de=
scribing tax detail.  This function will be multilevel similar to the inden=
tedBOM(int,int,int,int) function. It will return records using the taxdetai=
l composite type listed below.
  =

  {{{
@@ -508, +544 @@

  ALTER TABLE tax ADD COLUMN tax_basis_tax_id integer REFERENCES tax (tax_i=
d) ON DELETE CASCADE;
  }}}
  =3D=3D=3D New Type =3D=3D=3D
-  . '''taxassign''' - A composite type used to return an indented list of =
tax assignments
  =

- {{{
- CREATE TYPE taxassign AS
- (
-   taxassign_taxzone_id integer,
-   taxassign_taxtype_id integer,
-   taxassign_level integer,
-   taxassign_zone_code text,
-   taxassign_type_descrip text,
-   taxassign_taxclass_code text,
-   taxassign_taxclass_sequence integer
- );
- }}}
   . '''taxdetail''' - A composite type used to return a calculated tax det=
ail record set used by the taxdetail function which is in turn used by the =
Tax Detail window.
  =

  {{{