Skip to content

Commit

Permalink
Se agrega soporte para la moneda fiscal en la información de
Browse files Browse the repository at this point in the history
organización para que se pueda tomar la referencia de la moneda de
cálculo en las retenciones de ISLR
  • Loading branch information
yamelsenih committed Aug 19, 2024
1 parent c2d550f commit 4a19546
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Properties;

import org.adempiere.core.domains.models.I_C_Payment;
import org.compiere.model.MBPartner;
import org.compiere.model.MBank;
import org.compiere.model.MBankAccount;
import org.compiere.model.MClient;
import org.compiere.model.MClientInfo;
import org.compiere.model.MOrgInfo;
import org.compiere.model.MPayment;
import org.compiere.model.ModelValidationEngine;
import org.compiere.model.ModelValidator;
Expand All @@ -33,6 +35,7 @@
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.erpya.lve.util.LVEUtil;

/**
* Class added from standard values
Expand Down Expand Up @@ -95,6 +98,15 @@ public String modelChange(PO po, int type) throws Exception {
return null;
}

private int getDefaultcurrencyId(Properties context, int organizationId) {
MOrgInfo info = MOrgInfo.get(context, organizationId, null);
int currencyId = info.get_ValueAsInt(LVEUtil.COLUMNNAME_LVE_FiscalCurrency_ID);
if(currencyId <= 0) {
currencyId = MClient.get(context).getC_Currency_ID();
}
return currencyId;
}

/**
* Process source payment
* @param sourcePayment
Expand All @@ -120,7 +132,7 @@ private String createFBTTForPayment(MPayment sourcePayment) {
return null;
}
// Validate currency
int defaultCurrencyId = MClient.get(sourcePayment.getCtx()).getC_Currency_ID();
int defaultCurrencyId = getDefaultcurrencyId(sourcePayment.getCtx(), sourcePayment.getAD_Org_ID());
MBankAccount bankAccount = MBankAccount.get(sourcePayment.getCtx(), sourcePayment.getC_BankAccount_ID());
if(bankAccount == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.compiere.model.MClient;
import org.compiere.model.MClientInfo;
import org.compiere.model.MDocType;
import org.compiere.model.MOrgInfo;
import org.compiere.model.MPayment;
import org.compiere.model.MSequence;
import org.compiere.model.PO;
Expand All @@ -33,6 +34,7 @@
import org.erpya.lve.model.I_LVE_List;
import org.erpya.lve.model.I_LVE_ListLine;
import org.erpya.lve.model.MLVEList;
import org.erpya.lve.util.LVEUtil;

/**
* Process for generate FBTT from unprocessed payments
Expand All @@ -50,6 +52,15 @@ protected void prepare() {
super.prepare();
}

private int getDefaultcurrencyId(int organizationId) {
MOrgInfo info = MOrgInfo.get(getCtx(), organizationId, null);
int currencyId = info.get_ValueAsInt(LVEUtil.COLUMNNAME_LVE_FiscalCurrency_ID);
if(currencyId <= 0) {
currencyId = MClient.get(getCtx()).getC_Currency_ID();
}
return currencyId;
}

@Override
protected String doIt() {
// Iterate
Expand All @@ -58,7 +69,6 @@ protected String doIt() {
BigDecimal sourcePayAmt = Env.ZERO;
MPayment fbttPayment = new MPayment(getCtx(), 0, get_TrxName());
// Validate currency
int defaultCurrencyId = MClient.get(getCtx()).getC_Currency_ID();
for(int key : getSelectionKeys()) {
MPayment sourcePayment = new MPayment(getCtx(), key, get_TrxName());
// Validate FBTT reversed
Expand All @@ -82,6 +92,7 @@ protected String doIt() {
// Validate Account
bankAccountId = sourcePayment.getC_BankAccount_ID();
MBankAccount bankAccount = MBankAccount.get(getCtx(), bankAccountId);
int defaultCurrencyId = getDefaultcurrencyId(sourcePayment.getAD_Org_ID());
// Verify currency
if(bankAccount.getC_Currency_ID() != defaultCurrencyId) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,13 @@ class WHConceptSetting{
* @param amtBase
*/
public WHConceptSetting(MInvoice invoice,BigDecimal amtBase) {
MOrgInfo info = MOrgInfo.get(invoice.getCtx(), invoice.getAD_Org_ID(), null);
int currencyId = info.get_ValueAsInt(LVEUtil.COLUMNNAME_LVE_FiscalCurrency_ID);
if(currencyId <= 0) {
currencyId = MClient.get(invoice.getCtx()).getC_Currency_ID();
}
currencyRate = MConversionRate.getRate(invoice.getC_Currency_ID(),
MClient.get(invoice.getCtx()).getC_Currency_ID(),
currencyId,
invoice.getDateAcct(),
invoice.getC_ConversionType_ID(),
invoice.getAD_Client_ID(),
Expand Down

0 comments on commit 4a19546

Please sign in to comment.