use of org.compiere.model.MBankAccount in project lar_361 by comitsrl.
the class MLARRetiroCaja method completeIt.
// rejectIt
@Override
public String completeIt() {
for (X_LAR_RetiroCajaLine linea : obtenerLineas()) {
// Verifico que el importe ingresado, sea mayor a 0.
if (linea.getMonto().compareTo(Env.ZERO) <= 0) {
m_processMsg = "Por favor, ingrese un importe.";
return STATUS_Drafted;
}
// Pago que debita los valores transferidos de la cuenta.
final MPayment paymentBankFrom = new MPayment(getCtx(), 0, get_TrxName());
final MPayment cobro = new MPayment(getCtx(), linea.getCobro_ID(), get_TrxName());
// Si se trata de una Extaccion Bancaria, tomo la cuenta bancaria origen.
if (get_ValueAsBoolean("ExtraccionBancaria") || get_ValueAsBoolean("TransferenciaBancaria"))
paymentBankFrom.setC_BankAccount_ID(get_ValueAsInt("CuentaOrigen_ID"));
else
paymentBankFrom.setC_BankAccount_ID(getC_BankAccountFrom_ID());
paymentBankFrom.setDateAcct(new Timestamp(System.currentTimeMillis()));
paymentBankFrom.setDateTrx(new Timestamp(System.currentTimeMillis()));
paymentBankFrom.setDescription(getDescription());
paymentBankFrom.setC_BPartner_ID(MSysConfig.getIntValue("LAR_SdN_MovimientosDeCaja", 0, Env.getAD_Client_ID(getCtx())));
paymentBankFrom.setC_Currency_ID(getC_Currency_ID());
paymentBankFrom.setPayAmt(linea.getMonto());
paymentBankFrom.setOverUnderAmt(Env.ZERO);
paymentBankFrom.setPosted(true);
paymentBankFrom.setLAR_C_DoctType_ID(false, ((MBankAccount) paymentBankFrom.getC_BankAccount()).get_ValueAsBoolean("IsDrawer") ? paymentBankFrom.getC_BankAccount().getAD_Org_ID() : Env.getAD_Org_ID(p_ctx));
// Si el TenderType es cheque, cambio la marca IsOnDrawer a false.
if (linea.getTenderType().equals("Z")) {
paymentBankFrom.setTenderType(cobro.getTenderType());
paymentBankFrom.setRoutingNo(cobro.getRoutingNo());
paymentBankFrom.setCheckNo(cobro.getCheckNo());
paymentBankFrom.setAccountNo(cobro.getAccountNo());
paymentBankFrom.setA_Name(cobro.getA_Name());
paymentBankFrom.set_ValueOfColumn("LAR_PaymentSource_ID", cobro.getC_Payment_ID());
final String sql = "UPDATE C_Payment" + " SET IsOnDrawer='N'" + " WHERE C_Payment_ID='" + cobro.getC_Payment_ID() + "'";
DB.executeUpdate(sql, get_TrxName());
} else {
paymentBankFrom.setTenderType(MPayment.TENDERTYPE_Cash);
paymentBankFrom.set_ValueOfColumn("IsOnDrawer", false);
}
paymentBankFrom.saveEx();
if (paymentBankFrom.processIt(MPayment.DOCACTION_Complete)) {
paymentBankFrom.saveEx();
linea.setPago_ID(paymentBankFrom.getC_Payment_ID());
linea.saveEx();
} else {
m_processMsg = "No se ha podido procesar el pago correspondiente al retiro de efectivo.";
return STATUS_Drafted;
}
if (isTransferencia() || get_ValueAsBoolean("Deposito") || get_ValueAsBoolean("ExtraccionBancaria") || get_ValueAsBoolean("TransferenciaBancaria")) {
final MPayment paymentBankTo = new MPayment(getCtx(), 0, get_TrxName());
// Si el tenderType es cheque, copio los campos pertinentes al mismo.
if (linea.getTenderType().equals("Z")) {
paymentBankTo.setTenderType(linea.getTenderType());
paymentBankTo.setRoutingNo(cobro.getRoutingNo());
paymentBankTo.setCheckNo(cobro.getCheckNo());
paymentBankTo.setAccountNo(cobro.getAccountNo());
paymentBankTo.setA_Name(cobro.getA_Name());
paymentBankTo.set_ValueOfColumn("LAR_PaymentSource_ID", cobro.getC_Payment_ID());
if (isTransferencia())
paymentBankTo.set_ValueOfColumn("IsOnDrawer", true);
else {
paymentBankTo.set_ValueOfColumn("IsOnDrawer", false);
cobro.set_ValueOfColumn("IsDeposited", true);
cobro.saveEx();
}
} else {
paymentBankTo.setTenderType(MPayment.TENDERTYPE_Cash);
paymentBankTo.set_ValueOfColumn("IsOnDrawer", false);
}
// Si es una trasferencia o una extraccion bancaria, seteo la caja destino. Si no, seteo la cuenta bancaria destino.
MBankAccount destino = null;
if (isTransferencia() || get_ValueAsBoolean("ExtraccionBancaria"))
destino = (MBankAccount) getC_BankAccountTo();
else
destino = new MBankAccount(p_ctx, get_ValueAsInt("CuentaDestino_ID"), get_TrxName());
paymentBankTo.setPosted(true);
paymentBankTo.setC_BankAccount_ID(destino.getC_BankAccount_ID());
paymentBankTo.setDateAcct(new Timestamp(System.currentTimeMillis()));
paymentBankTo.setDateTrx(new Timestamp(System.currentTimeMillis()));
paymentBankTo.setDescription(getDescription());
paymentBankTo.setC_BPartner_ID(MSysConfig.getIntValue("LAR_SdN_MovimientosDeCaja", 0, Env.getAD_Client_ID(getCtx())));
paymentBankTo.setC_Currency_ID(getC_Currency_ID());
paymentBankTo.setPayAmt(linea.getMonto());
paymentBankTo.setOverUnderAmt(Env.ZERO);
paymentBankTo.setLAR_C_DoctType_ID(true, destino.get_ValueAsBoolean("IsDrawer") ? destino.getAD_Org_ID() : Env.getAD_Org_ID(p_ctx));
paymentBankTo.setIsReceipt(true);
paymentBankTo.saveEx();
if (paymentBankTo.processIt(MPayment.DOCACTION_Complete)) {
paymentBankTo.saveEx();
linea.setCobro_ID(paymentBankTo.getC_Payment_ID());
linea.saveEx();
} else {
m_processMsg = "No se ha podido efectuar la transferencia de efectivo. Error al crear el cobro en la cuenta Destino.";
return STATUS_Drafted;
}
}
}
setProcessed(true);
setDocAction(DOCACTION_Void);
if (!save())
return STATUS_Drafted;
return STATUS_Completed;
}
use of org.compiere.model.MBankAccount in project lar_361 by comitsrl.
the class DrawerTransfer method doIt.
// prepare
/**
* Perform process.
*
* @return Message (translated text)
* @throws Exception
* if not successful
*/
protected String doIt() throws Exception {
String msg = String.format("From Bank=%d - To Bank=%d - DocumentNo=%s - Description=%s - Statement Date=%s - Date Account=%s", p_From_C_BankAccount_ID, p_To_C_BankAccount_ID, p_DocumentNo, p_Description, p_StatementDate, p_DateAcct);
log.info(msg);
if (p_From_C_BankAccount_ID == 0)
throw new IllegalArgumentException("Número de Caja Requerido");
// if (p_DocumentNo == null || p_DocumentNo.length() == 0)
// throw new IllegalArgumentException("Document No required");
// if (p_To_C_BankAccount_ID == p_From_C_BankAccount_ID)
// throw new AdempiereUserError("Accounts From and To must be different");
p_C_BPartner_ID = new MUser(getCtx(), Env.getAD_User_ID(getCtx()), get_TrxName()).getC_BPartner_ID();
if (p_C_BPartner_ID == 0)
throw new AdempiereUserError("Socio de Negocio requerido");
// Login Date
if (p_StatementDate == null)
p_StatementDate = Env.getContextAsDate(getCtx(), "#Date");
if (p_StatementDate == null)
p_StatementDate = new Timestamp(System.currentTimeMillis());
if (p_DateAcct == null)
p_DateAcct = p_StatementDate;
if (p_BankStatement_ID == 0)
throw new AdempiereUserError("Por favor, seleccione un cierre de caja a transferir.");
// Si la cuenta, es una caja principal, se transfieren los valores segun
// la forma de pago.
final MBankAccount cuenta = new MBankAccount(getCtx(), p_From_C_BankAccount_ID, get_TrxName());
return "@Se transfirieron@ " + m_transferred + " líneas.";
}
Aggregations