declare

     ln_trx_number                    VARCHAR2 (50);

      v_api_version                    NUMBER                          := 1.0;

      —      V_init_msg_list      VARCHAR2(1) := FND_API.G_FALSE;

      v_init_msg_list                  VARCHAR2 (1)         := fnd_api.g_true;

      v_commit                         VARCHAR2 (1)        := fnd_api.g_false;

      v_validation_level               NUMBER   := fnd_api.g_valid_level_full;

      v_return_status                  VARCHAR2 (1);

      v_msg_count                      NUMBER;

      v_msg_data                       VARCHAR2 (3000);     

      v_application_ref_type           ar_receivable_applications.application_ref_type%TYPE

                                                                 DEFAULT NULL;

      v_application_ref_id             ar_receivable_applications.application_ref_id%TYPE

                                                                 DEFAULT NULL;

      v_application_ref_num            ar_receivable_applications.application_ref_num%TYPE

                                                                 DEFAULT NULL;

      v_secondary_application_ref_id   ar_receivable_applications.secondary_application_ref_id%TYPE

                                                                 DEFAULT NULL;

      v_application_ref_reason         ar_receivable_applications.application_ref_reason%TYPE

                                                                 DEFAULT NULL;

      v_customer_reference             ar_receivable_applications.customer_reference%TYPE

                                                                 DEFAULT NULL;

      v_customer_reason                ar_receivable_applications.customer_reason%TYPE

                                                                 DEFAULT NULL;

      l_msg_index_out                  NUMBER;

      v_receipt_remaining_amount       NUMBER;

      v_receivable_application_id      NUMBER;

      x_clm_num                        VARCHAR2 (100);

      x_application_ref_id             VARCHAR2 (100);

      x_secondary_application_ref_id   VARCHAR2 (100);

   BEGIN

      fnd_global.apps_initialize (0, 20678, 222);

      DEBUG (‘For Receipt ID: ‘ || :p_receipt_id);

      DEBUG (‘Creating application for the deduction of amount ‘ || :p_amount);

      –v_customer_reference := SUBSTR (p_description, 1, 100);

      v_customer_reason := ‘Payments::Refund ‘ || p_order_number;

      v_application_ref_type := ‘CLAIM’;

      v_cash_receipt_id := :p_receipt_id;

      v_call_payment_processor := fnd_api.g_false;

      ln_trx_number := 0;

 

      BEGIN

         SELECT trx_number

           INTO ln_trx_number

           FROM apps.ra_customer_trx_all

          WHERE purchase_order = :p_order_number;

      EXCEPTION

         WHEN OTHERS

         THEN

            ln_trx_number := NULL;

      END;

 

      ar_receipt_api_pub.apply_other_account

            (p_api_version                       => 1.0,

             p_init_msg_list                     => v_init_msg_list,

             p_commit                            => v_commit,

             p_validation_level                  => v_validation_level,

             x_return_status                     => v_return_status,

             x_msg_count                         => v_msg_count,

             x_msg_data                          => v_msg_data,

             p_receivable_application_id         => v_receivable_application_id,

             p_cash_receipt_id                   => v_cash_receipt_id,

             p_receivables_trx_id                => p_activity_id,

               p_applied_payment_schedule_id       => -4,

             — apply to the account

             p_amount_applied                    => p_amount,

             p_application_ref_type              => v_application_ref_type,

             p_application_ref_id                => x_application_ref_id,

             p_application_ref_num               => x_clm_num,

             p_secondary_application_ref_id      => x_secondary_application_ref_id,

             p_customer_reference                => v_customer_reference,

             p_customer_reason                   => v_customer_reason,

             p_called_from                       => NULL

            );

 

      IF v_return_status != ‘S’

      THEN

         FOR j IN 1 .. v_msg_count                    –fnd_msg_pub.count_msg

         LOOP

            fnd_msg_pub.get (p_msg_index          => j,

                             p_encoded            => ‘F’,

                             p_data               => v_msg_data,

                             p_msg_index_out      => l_msg_index_out

                            );

         END LOOP;

 

         DEBUG (‘Errors in applying deduction to the receipt:  ‘ || v_msg_data);

         p_claim_status := ‘CLAIM_CREATION_FAILURE’;

         p_claim_number := x_clm_num;

 

       

      ELSE

         DEBUG (‘Applied deduction successfuly’);

         DEBUG (‘Claim ‘ || x_clm_num || ‘ created’);

         p_claim_status := ‘CLAIM_CREATION_SUCCESS’;

         p_claim_number := x_clm_num;

 

        

      END IF;

   EXCEPTION

      WHEN OTHERS

      THEN

         DEBUG (   ‘ Issue in procedure CREATE_DEDUCTION_CLAIMS ‘

                || SQLERRM

                || ‘ ‘

                || SQLCODE

               );

         p_claim_status := ‘CLAIM_CREATION_FAILURE’;

         p_claim_number := x_clm_num;

   END;

Recent Posts

Start typing and press Enter to search