Wednesday, January 22, 2014

Script to Calculate the Tax details of the Product Line in the Service Contract(apps.oks_tax_util_pvt.get_tax)


DECLARE
   p_chr_id                                          NUMBER;
   p_cle_id                                          NUMBER;
   x_rail_rec                                        apps.oks_tax_util_pvt.ra_rec_type;
   l_return_status                                   VARCHAR2(20);
   l_msg_count                                       NUMBER;
   l_msg_data                                        VARCHAR2(2000);
   l_msg_index_out                                   NUMBER;
   l_error_message                                   VARCHAR2(2000);
   l_num                                             NUMBER;
BEGIN
   p_chr_id                                       := 1549063;
   p_cle_id                                       := 364326736554364142775004706891329465584;
   apps.oks_tax_util_pvt.get_tax(p_api_version                 => 1.0
                               , p_init_msg_list               => fnd_api.g_false
                               , p_chr_id                      => p_chr_id
                               , p_cle_id                      => p_cle_id
                               , px_rail_rec                   => x_rail_rec
                               , x_msg_count                   => l_msg_count
                               , x_msg_data                    => l_msg_data
                               , x_return_status               => l_return_status
                                );

   IF l_return_status <> fnd_api.g_ret_sts_success
   THEN
      l_num                                          := 40;

      IF l_msg_count > 0
      THEN
         FOR i IN 1 .. l_msg_count
         LOOP
            l_num                                          := 50;
            apps.fnd_msg_pub.get(p_msg_index                   => i, p_encoded => fnd_api.g_false, p_data => l_msg_data
                               , p_msg_index_out               => l_msg_index_out);

            IF l_error_message IS NULL
            THEN
               l_error_message                                := SUBSTR(l_msg_data, 1, 250);
            ELSE
               l_error_message                                := l_error_message || ' /' || SUBSTR(l_msg_data, 1, 250);
            END IF;
         END LOOP;

         DBMS_OUTPUT.put_line('*****************************************');
         DBMS_OUTPUT.put_line('API Error : ' || l_error_message);
         DBMS_OUTPUT.put_line('*****************************************');
      ELSE
         apps.fnd_msg_pub.get(p_msg_index                   => 1, p_encoded => fnd_api.g_false, p_data => l_msg_data
                            , p_msg_index_out               => l_msg_index_out);
         DBMS_OUTPUT.put_line('*****************************************');
         DBMS_OUTPUT.put_line('API Error : ' || l_msg_data);
         DBMS_OUTPUT.put_line('*****************************************');
      END IF;
   ELSE
      l_num                                          := 60;
      DBMS_OUTPUT.put_line('*******************************************************************************************************');
      DBMS_OUTPUT.put_line('API Success');
      DBMS_OUTPUT.put_line('Header Id : ' || x_rail_rec.header_id);
      DBMS_OUTPUT.put_line('Line Id : ' || x_rail_rec.line_id);
      DBMS_OUTPUT.put_line('Tax Exempt Flag : ' || x_rail_rec.tax_exempt_flag);
      DBMS_OUTPUT.put_line('Tax exempt reason : ' || x_rail_rec.tax_exempt_reason);
      DBMS_OUTPUT.put_line('Tax exempt number : ' || x_rail_rec.tax_exempt_number);
      DBMS_OUTPUT.put_line('Sales Tax ID : ' || x_rail_rec.sales_tax_id);
      DBMS_OUTPUT.put_line('Org Id : ' || x_rail_rec.org_id);
      DBMS_OUTPUT.put_line('Orig_system_ship_address_id : ' || x_rail_rec.orig_system_ship_address_id);
      DBMS_OUTPUT.put_line('Orig_system_ship_contact_id : ' || x_rail_rec.orig_system_ship_contact_id);
      DBMS_OUTPUT.put_line('ORIG_SYSTEM_SHIP_CUSTOMER_I : ' || x_rail_rec.orig_system_ship_customer_id);
      DBMS_OUTPUT.put_line('SHIP_TO_SITE_USE_ID         : ' || x_rail_rec.ship_to_site_use_id);
      DBMS_OUTPUT.put_line('SHIP_TO_POSTAL_CODE         : ' || x_rail_rec.ship_to_postal_code);
      DBMS_OUTPUT.put_line('SHIP_TO_LOCATION_ID         : ' || x_rail_rec.ship_to_location_id);
      DBMS_OUTPUT.put_line('SHIP_TO_CUSTOMER_NUMBER     : ' || x_rail_rec.ship_to_customer_number);
      DBMS_OUTPUT.put_line('SHIP_TO_CUSTOMER_NAME       : ' || x_rail_rec.ship_to_customer_name);
      DBMS_OUTPUT.put_line('SHIP_TO_ORG_ID              : ' || x_rail_rec.ship_to_org_id);
      DBMS_OUTPUT.put_line('WAREHOUSE_ID                : ' || x_rail_rec.warehouse_id);
      DBMS_OUTPUT.put_line('ORIG_SYSTEM_SOLD_CUSTOMER_I : ' || x_rail_rec.orig_system_sold_customer_id);
      DBMS_OUTPUT.put_line('ORIG_SYSTEM_BILL_CUSTOMER_I : ' || x_rail_rec.orig_system_bill_customer_id);
      DBMS_OUTPUT.put_line('ORIG_SYSTEM_BILL_ADDRESS_ID : ' || x_rail_rec.orig_system_bill_address_id);
      DBMS_OUTPUT.put_line('ORIG_SYSTEM_BILL_CONTACT_ID : ' || x_rail_rec.orig_system_bill_contact_id);
      DBMS_OUTPUT.put_line('BILL_TO_SITE_USE_ID         : ' || x_rail_rec.bill_to_site_use_id);
      DBMS_OUTPUT.put_line('BILL_TO_POSTAL_CODE         : ' || x_rail_rec.bill_to_postal_code);
      DBMS_OUTPUT.put_line('BILL_TO_LOCATION_ID         : ' || x_rail_rec.bill_to_location_id);
      DBMS_OUTPUT.put_line('BILL_TO_CUSTOMER_NUMBER     : ' || x_rail_rec.bill_to_customer_number);
      DBMS_OUTPUT.put_line('BILL_TO_CUSTOMER_NAME       : ' || x_rail_rec.bill_to_customer_name);
      DBMS_OUTPUT.put_line('BILL_TO_ORG_ID              : ' || x_rail_rec.bill_to_org_id);
      DBMS_OUTPUT.put_line('RECEIPT_METHOD_NAME         : ' || x_rail_rec.receipt_method_name);
      DBMS_OUTPUT.put_line('RECEIPT_METHOD_ID           : ' || x_rail_rec.receipt_method_id);
      DBMS_OUTPUT.put_line('CONVERSION_TYPE             : ' || x_rail_rec.conversion_type);
      DBMS_OUTPUT.put_line('CONVERSION_DATE             : ' || x_rail_rec.conversion_date);
      DBMS_OUTPUT.put_line('CONVERSION_RATE             : ' || x_rail_rec.conversion_rate);
      DBMS_OUTPUT.put_line('CUSTOMER_TRX_ID             : ' || x_rail_rec.customer_trx_id);
      DBMS_OUTPUT.put_line('TRX_DATE                    : ' || x_rail_rec.trx_date);
      DBMS_OUTPUT.put_line('GL_DATE                     : ' || x_rail_rec.gl_date);
      DBMS_OUTPUT.put_line('DOCUMENT_NUMBER             : ' || x_rail_rec.document_number);
      DBMS_OUTPUT.put_line('TRX_NUMBER                  : ' || x_rail_rec.trx_number);
      DBMS_OUTPUT.put_line('LINE_NUMBER                 : ' || x_rail_rec.line_number);
      DBMS_OUTPUT.put_line('QUANTITY                    : ' || x_rail_rec.quantity);
      DBMS_OUTPUT.put_line('QUANTITY_ORDERED            : ' || x_rail_rec.quantity_ordered);
      DBMS_OUTPUT.put_line('UNIT_SELLING_PRICE          : ' || x_rail_rec.unit_selling_price);
      DBMS_OUTPUT.put_line('UNIT_STANDARD_PRICE         : ' || x_rail_rec.unit_standard_price);
      DBMS_OUTPUT.put_line('PRINTING_OPTION             : ' || x_rail_rec.printing_option);
      DBMS_OUTPUT.put_line('INVENTORY_ITEM_ID           : ' || x_rail_rec.inventory_item_id);
      DBMS_OUTPUT.put_line('INVENTORY_ORG_ID            : ' || x_rail_rec.inventory_org_id);
      DBMS_OUTPUT.put_line('UOM_CODE                    : ' || x_rail_rec.uom_code);
      DBMS_OUTPUT.put_line('UOM_NAME                    : ' || x_rail_rec.uom_name);
      DBMS_OUTPUT.put_line('RELATED_TRX_NUMBER          : ' || x_rail_rec.related_trx_number);
      DBMS_OUTPUT.put_line('RELATED_CUSTOMER_TRX_ID     : ' || x_rail_rec.related_customer_trx_id);
      DBMS_OUTPUT.put_line('PREVIOUS_CUSTOMER_TRX_ID    : ' || x_rail_rec.previous_customer_trx_id);
      DBMS_OUTPUT.put_line('REASON_CODE                 : ' || x_rail_rec.reason_code);
      DBMS_OUTPUT.put_line('TAX_RATE                    : ' || x_rail_rec.tax_rate);
      DBMS_OUTPUT.put_line('TAX_CODE                    : ' || x_rail_rec.tax_code);
      DBMS_OUTPUT.put_line('TAX_PRECEDENCE              : ' || x_rail_rec.tax_precedence);
      DBMS_OUTPUT.put_line('INVOICING_RULE_NAME         : ' || x_rail_rec.invoicing_rule_name);
      DBMS_OUTPUT.put_line('INVOICING_RULE_ID           : ' || x_rail_rec.invoicing_rule_id);
      DBMS_OUTPUT.put_line('PURCHASE_ORDER              : ' || x_rail_rec.purchase_order);
      DBMS_OUTPUT.put_line('SET_OF_BOOKS_ID             : ' || x_rail_rec.set_of_books_id);
      DBMS_OUTPUT.put_line('LINE_TYPE                   : ' || x_rail_rec.line_type);
      DBMS_OUTPUT.put_line('DESCRIPTION                 : ' || x_rail_rec.description);
      DBMS_OUTPUT.put_line('CURRENCY_CODE               : ' || x_rail_rec.currency_code);
      DBMS_OUTPUT.put_line('AMOUNT                      : ' || x_rail_rec.amount);
      DBMS_OUTPUT.put_line('CUST_TRX_TYPE_NAME          : ' || x_rail_rec.cust_trx_type_name);
      DBMS_OUTPUT.put_line('CUST_TRX_TYPE_ID            : ' || x_rail_rec.cust_trx_type_id);
      DBMS_OUTPUT.put_line('PAYMENT_TERM_ID             : ' || x_rail_rec.payment_term_id);
      DBMS_OUTPUT.put_line('AMOUNT_INCLUDES_TAX_FLAG    : ' || x_rail_rec.amount_includes_tax_flag);
      DBMS_OUTPUT.put_line('TAX_CAL_PLSQL_BLOCK         : ' || x_rail_rec.tax_cal_plsql_block);
      DBMS_OUTPUT.put_line('MINIMUM_ACCOUNTABLE_UNIT    : ' || x_rail_rec.minimum_accountable_unit);
      DBMS_OUTPUT.put_line('PRECISION                   : ' || x_rail_rec.PRECISION);
      DBMS_OUTPUT.put_line('FOB_POINT                   : ' || x_rail_rec.fob_point);
      DBMS_OUTPUT.put_line('TAXABLE_BASIS               : ' || x_rail_rec.taxable_basis);
      DBMS_OUTPUT.put_line('VAT_TAX_ID                  : ' || x_rail_rec.vat_tax_id);
      DBMS_OUTPUT.put_line('TAX_VALUE                   : ' || x_rail_rec.tax_value);
      DBMS_OUTPUT.put_line('TOTAL_PLUS_TAX              : ' || x_rail_rec.total_plus_tax);
      DBMS_OUTPUT.put_line('*******************************************************************************************************');
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line(l_num || ' Unexpected Error : ' || SUBSTR(SQLERRM, 1, 250));
END;

Output for the above Script.

=====================================

*******************************************************************************************************
API Success
Header Id : 1549063
Line Id : 364326736554364142775004706891329465584
Tax Exempt Flag : S
Tax exempt reason :
Tax exempt number :
Sales Tax ID :
Org Id : 102
Orig_system_ship_address_id : 326265
Orig_system_ship_contact_id :
ORIG_SYSTEM_SHIP_CUSTOMER_I : 2043938
SHIP_TO_SITE_USE_ID         : 401915
SHIP_TO_POSTAL_CODE         : 98031
SHIP_TO_LOCATION_ID         : 2143
SHIP_TO_CUSTOMER_NUMBER     :
SHIP_TO_CUSTOMER_NAME       :
SHIP_TO_ORG_ID              : 102
WAREHOUSE_ID                :
ORIG_SYSTEM_SOLD_CUSTOMER_I : 491186
ORIG_SYSTEM_BILL_CUSTOMER_I : 491186
ORIG_SYSTEM_BILL_ADDRESS_ID : 72442
ORIG_SYSTEM_BILL_CONTACT_ID :
BILL_TO_SITE_USE_ID         : 101790
BILL_TO_POSTAL_CODE         : 80112
BILL_TO_LOCATION_ID         : 2870
BILL_TO_CUSTOMER_NUMBER     :
BILL_TO_CUSTOMER_NAME       :
BILL_TO_ORG_ID              : 102
RECEIPT_METHOD_NAME         :
RECEIPT_METHOD_ID           :
CONVERSION_TYPE             :
CONVERSION_DATE             : 22-JAN-14
CONVERSION_RATE             :
CUSTOMER_TRX_ID             :
TRX_DATE                    :
GL_DATE                     :
DOCUMENT_NUMBER             :
TRX_NUMBER                  :
LINE_NUMBER                 :
QUANTITY                    : 1
QUANTITY_ORDERED            :
UNIT_SELLING_PRICE          : 5500.53
UNIT_STANDARD_PRICE         :
PRINTING_OPTION             :
INVENTORY_ITEM_ID           : 109135
INVENTORY_ORG_ID            : 103
UOM_CODE                    : Ea
UOM_NAME                    :
RELATED_TRX_NUMBER          :
RELATED_CUSTOMER_TRX_ID     :
PREVIOUS_CUSTOMER_TRX_ID   
REASON_CODE                 :
TAX_RATE                    : 0
TAX_CODE                    : Sales Tax
TAX_PRECEDENCE              :
INVOICING_RULE_NAME         :
INVOICING_RULE_ID           :
PURCHASE_ORDER              :
SET_OF_BOOKS_ID             : 1002
LINE_TYPE                   :
DESCRIPTION                 :
CURRENCY_CODE               : USD
AMOUNT                      : 2712.590136812997
CUST_TRX_TYPE_NAME          :
CUST_TRX_TYPE_ID            : 1005
PAYMENT_TERM_ID             :
AMOUNT_INCLUDES_TAX_FLAG    : N
TAX_CAL_PLSQL_BLOCK         :
MINIMUM_ACCOUNTABLE_UNIT    :
PRECISION                   : 2
FOB_POINT                   :
TAXABLE_BASIS               :
VAT_TAX_ID                  : 10094
TAX_VALUE                   : 0
TOTAL_PLUS_TAX              : 2712.590136812997
*******************************************************************************************************

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.