Package org.openbravo.erpCommon.utility
Class CashVATUtil
- java.lang.Object
-
- org.openbravo.erpCommon.utility.CashVATUtil
-
public class CashVATUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static BigDecimal
_100
-
Constructor Summary
Constructors Constructor Description CashVATUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static BigDecimal
calculatePercentageAmount(BigDecimal percentage, BigDecimal totalAmt, String cCurrencyId)
Generic method to calculate the percentage of an amount (totalAmt) with the currency's standard precisionstatic BigDecimal
calculatePercentageAmount(BigDecimal percentage, BigDecimal totalAmt, Currency currency)
Generic method to calculate the percentage of an amount (totalAmt) with the currency's standard precisionstatic 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.static String
createFactCashVAT(AcctSchema as, ConnectionProvider conn, Fact fact, String fact_Acct_Group_ID, DocLineCashVATReady_PaymentTransactionReconciliation line, Invoice invoice, String documentType, String SeqNo)
Create the accounting fact lines related to Cash VAT for payments, transactions and reconciliations that come from a cash VAT invoicestatic String
createFactCashVAT(AcctSchema as, ConnectionProvider conn, Fact fact, String fact_Acct_Group_ID, DocLineCashVATReady_PaymentTransactionReconciliation line, Invoice invoice, String documentType, String cCurrencyID, String SeqNo)
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.static String
getBusinessPartnerIsCashVAT(String strBPId)
Returns the Cash VAT configuration for the given Vendor (Business Partner)static List<InvoiceTaxCashVAT>
getInvoiceTaxCashVAT(FIN_PaymentDetail paymentDetail)
Gets the InvoiceTaxCashVAT records linked to the payment detailstatic String
getOrganizationIsCashVAT(String strOrgId)
Returns the associated legal entity Cash VAT configuration.static String
getOrganizationIsDoubleCash(String strOrgId)
Returns the associated legal entity Double Cash Criteria configuration.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.static boolean
hasManualCashVATSettlement(Invoice invoice)
Returns true if the invoice has a manual cash vat settlement associatedstatic String
isCashVAT(String strIsSOTrx, String strOrgId, String strBPartnerId, String strBPartnerLocationId)
Returns "Y" if the combination of these parameters represents a Cash VAT transaction.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.
-
-
-
Field Detail
-
_100
public static final BigDecimal _100
-
-
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 IdstrBPartnerLocationId
- 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 IDstrBPartnerId
- business partner IDstrBPartnerLocationId
- 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
-
getInvoiceTaxCashVAT
public static List<InvoiceTaxCashVAT> getInvoiceTaxCashVAT(FIN_PaymentDetail paymentDetail)
Gets the InvoiceTaxCashVAT records linked to the payment detail
-
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 (seeFIN_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 totalAmttotalAmt
- 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 totalAmttotalAmt
- total amount (represents 100%)currency
- currency- Returns:
- percentage * totalAmt / 100, rounded to the currency's standard precision
-
createFactCashVAT
@Deprecated public static String createFactCashVAT(AcctSchema as, ConnectionProvider conn, Fact fact, String fact_Acct_Group_ID, DocLineCashVATReady_PaymentTransactionReconciliation line, Invoice invoice, String documentType, String cCurrencyID, String SeqNo)
-
createFactCashVAT
public static String createFactCashVAT(AcctSchema as, ConnectionProvider conn, Fact fact, String fact_Acct_Group_ID, DocLineCashVATReady_PaymentTransactionReconciliation line, Invoice invoice, String documentType, String SeqNo)
Create the accounting fact lines related to Cash VAT for payments, transactions and reconciliations that come from a cash VAT invoice
-
-