Friday, 4 May 2018

Rounding of WHT in AP (ap_custom_withholding_pkg)

https://aporaclepayables.blogspot.com/2018/05/rounding-of-wht-in-ap.html

-- Begin Custom Code
BEGIN
      SELECT NVL(TR.TAX_RATE,0)
      INTO  p_tax_rate
      FROM AP_AWT_TAX_RATES_ALL TR
      WHERE ORG_ID = FND_PROFILE.VALUE('ORG_ID')
      AND TR.TAX_NAME = p_Tax_Name
      AND RATE_TYPE = 'STANDARD';
 EXCEPTION
   WHEN OTHERS THEN
   NULL;
 END;
   --INSERT INTO xxcs_wht_values
   --values(P_Invoice_exchange_rate, P_Withheld_Amount, p_tax_name,1, p_base_wt_amount,P_BaseCurrCode, p_currcode);
   --p_tax_rate := round(p_tax_rate,2);
 if p_tax_rate >= 1 then
  -- INSERT INTO xxcs_wht_values
  --values (p_tax_rate, P_Withheld_Amount, p_tax_name,2,p_base_wt_amount,P_BaseCurrCode, p_currcode);
  p_orig_inv_amount := (P_Withheld_Amount*100)/p_tax_rate;
--  p_tax_rate := round(p_tax_rate,0);
  P_Withheld_Amount := (p_orig_inv_amount*p_tax_rate)/100;
  P_Base_WT_amount  := P_Withheld_Amount;
  P_Withheld_Amount := ROUND(P_Withheld_Amount,0);
  P_Base_WT_amount  := ROUND(P_Base_WT_amount,0);

--  INSERT INTO xxcs_wht_values
  --values (p_tax_rate, P_Withheld_Amount, p_tax_name,3,p_base_wt_amount,P_BaseCurrCode, p_currcode);

elsif p_tax_rate < 1 and p_tax_rate !=0 then
  p_orig_inv_amount := (P_Withheld_Amount*100)/p_tax_rate;
  P_Withheld_Amount := (p_orig_inv_amount*p_tax_rate)/100;
  P_Base_WT_amount  := P_Withheld_Amount;
end if;

--    null;

-- End Custom Code

-----------------------------------------------------------------------------------------------------------------

For my Case

-- Begin Custom Code
     if nvl(P_Calling_parameter,'') ='HEADER' then
     if (P_Withheld_Amount >= 0 ) THEN
     P_Withheld_Amount := ROUND(P_Unrounded_WT_Amount);
     P_Base_WT_amount  := ROUND(P_Unrounded_WT_Amount);
     ELSE
     P_Withheld_Amount := ROUND(P_Unrounded_WT_Amount);
     P_Base_WT_amount  := ROUND(P_Unrounded_WT_Amount);
     END IF;
  end if;
-- End Custom Code

2 comments:

  1. -- Begin Custom Code
    if nvl(P_Calling_parameter,'') ='HEADER' then
    if (P_Withheld_Amount >= 0 ) THEN
    P_Withheld_Amount := ROUND(P_Unrounded_WT_Amount);
    P_Base_WT_amount := ROUND(P_Unrounded_WT_Amount);
    ELSE
    P_Withheld_Amount := ROUND(P_Unrounded_WT_Amount);
    P_Base_WT_amount := ROUND(P_Unrounded_WT_Amount);
    END IF;
    end if;
    -- End Custom Code

    ReplyDelete
  2. Rounding Amount on each Line level. Using the No.1 Code

    ReplyDelete