Class CashVATUtil


  • public class CashVATUtil
    extends Object
    • Constructor Detail

      • CashVATUtil

        public CashVATUtil()
    • Method Detail

      • getOrganizationIsCashVAT

        public static String getOrganizationIsCashVAT​(String strOrgId)
        Returns the associated legal entity Cash VAT configuration. Useful for sales flows
        Parameters:
        strOrgId - organization id
        Returns:
        "Y", "N" or null if not found
      • getOrganizationIsDoubleCash

        public static String getOrganizationIsDoubleCash​(String strOrgId)
        Returns the associated legal entity Double Cash Criteria configuration. Useful for purchase flows
        Parameters:
        strOrgId - organization id
        Returns:
        "Y", "N" or null if not found
      • getBusinessPartnerIsCashVAT

        public static String getBusinessPartnerIsCashVAT​(String strBPId)
        Returns the Cash VAT configuration for the given Vendor (Business Partner)
        Parameters:
        strBPId - Vendor (c_bpartner_id)
        Returns:
        "Y", "N" or null if not found
      • isForcedNonCashVAT

        public static boolean isForcedNonCashVAT​(String strOrgId,
                                                 String strBPartnerLocationId)
        It returns true if Organization's and Business Partner's countries are different, which implies a non Cash VAT document. If Organization has no address, it tries to get its legal entity address instead.
        Parameters:
        strOrgId - Organization Id
        strBPartnerLocationId - Business Partner Location Id from the document (invoice, order, etc.)
        Returns:
        It returns true if Organization's and Business Partner's countries are different
      • isCashVAT

        public static String isCashVAT​(String strIsSOTrx,
                                       String strOrgId,
                                       String strBPartnerId,
                                       String strBPartnerLocationId)
        Returns "Y" if the combination of these parameters represents a Cash VAT transaction. It first checks whether the organization's and business partner's location country is different. In this case it returns "N", because Cash VAT transactions are only valid within the same country.
        For sales flow, it checks whether the organization is declared as Cash VAT. In this case it returns "Y".
        For purchase flow, it first checks if the organization is declared as Cash VAT and Double cash criteria. In this case it returns "Y"; otherwise it returns the business partner Cash VAT configuration
        Parameters:
        strIsSOTrx - is Sales transaction ("Y" or "N")
        strOrgId - organization ID
        strBPartnerId - business partner ID
        strBPartnerLocationId - business partner location ID (from the document: order, invoice, etc.)
        Returns:
        "Y" for Cash VAT transactions, otherwise returns "N"
      • createInvoiceTaxCashVAT

        public static void createInvoiceTaxCashVAT​(FIN_PaymentDetail paymentDetail,
                                                   FIN_PaymentSchedule paymentSchedule,
                                                   BigDecimal amount)
        Creates the records into the Cash VAT management table (InvoiceTaxCashVAT), calculating the percentage paid/collected tax amount and taxable amount. Only for cash vat tax rates. If the invoice has been already settled in a Manual Cash VAT Settlement, we don't create a new Cash VAT management record
      • hasManualCashVATSettlement

        public static boolean hasManualCashVATSettlement​(Invoice invoice)
        Returns true if the invoice has a manual cash vat settlement associated
      • getTotalOutstandingCashVATAmount

        public static Map<String,​BigDecimal> getTotalOutstandingCashVATAmount​(String cInvoiceTaxID)
        Returns the outstanding percentage, tax amount and taxable amount by subtracting the total percentage (100%), total tax amount and total taxable amount with the amounts registered into the InvoiceTaxCashVAT. Use this method when the invoice is fully paid to avoid rounding issues with on the fly calculations based on the percentage of the invoice that has been paid/collected
      • calculatePrepaidPercentageForCashVATTax

        public static BigDecimal calculatePrepaidPercentageForCashVATTax​(String cTaxID,
                                                                         String cInvoiceId)
        Returns the total percentage that should be applied to the cash vat regime that comes from a prepayment, i.e. from an (partially or totally) paid/collected order and from a payment created at invoicing time (see FIN_PaymentDetail.PROPERTY_ISPAIDATINVOICING). This percentage must be directly registered into the final tax account instead of the transitory tax account as usual, because this part of the invoice has been paid from the order
      • calculatePercentageAmount

        public static BigDecimal calculatePercentageAmount​(BigDecimal percentage,
                                                           BigDecimal totalAmt,
                                                           String cCurrencyId)
        Generic method to calculate the percentage of an amount (totalAmt) with the currency's standard precision
        Parameters:
        percentage - percentage to apply for the totalAmt
        totalAmt - total amount (represents 100%)
        cCurrencyId - currency ID
        Returns:
        percentage * totalAmt / 100, rounded to the currency's standard precision
      • calculatePercentageAmount

        public static BigDecimal calculatePercentageAmount​(BigDecimal percentage,
                                                           BigDecimal totalAmt,
                                                           Currency currency)
        Generic method to calculate the percentage of an amount (totalAmt) with the currency's standard precision
        Parameters:
        percentage - percentage to apply for the totalAmt
        totalAmt - total amount (represents 100%)
        currency - currency
        Returns:
        percentage * totalAmt / 100, rounded to the currency's standard precision