Search in sources :

Example 21 with MPayment

use of org.compiere.model.MPayment in project adempiere by adempiere.

the class Collect method payDirectDebit.

// payCheck
/**
	 * 	Payment with direct debit
	 * @param amt
	 * @param routingNo
	 * @param accountCountry
	 * @param cVV
	 * @return true if payment processed correctly; otherwise false
	 */
public boolean payDirectDebit(BigDecimal amt, String routingNo, String accountCountry, String cVV) {
    MPayment payment = createPayment(MPayment.TENDERTYPE_DirectDebit);
    payment.setC_CashBook_ID(entityPOS.getC_CashBook_ID());
    payment.setAmount(order.getC_Currency_ID(), amt);
    payment.setC_BankAccount_ID(entityPOS.getC_BankAccount_ID());
    payment.setRoutingNo(routingNo);
    payment.setA_Country(accountCountry);
    payment.setCreditCardVV(cVV);
    payment.setDateTrx(getDateTrx());
    payment.setDateAcct(getDateTrx());
    payment.saveEx();
    payment.setDocAction(MPayment.DOCACTION_Complete);
    payment.setDocStatus(MPayment.DOCSTATUS_Drafted);
    if (payment.processIt(MPayment.DOCACTION_Complete)) {
        payment.saveEx();
        MBankStatement.addPayment(payment);
        return true;
    } else {
        return false;
    }
}
Also used : MPayment(org.compiere.model.MPayment)

Example 22 with MPayment

use of org.compiere.model.MPayment in project adempiere by adempiere.

the class Collect method createPayment.

// payCheck
/**
	 * 	Create Payment object
	 *  Refer to invoice if there is an invoice.
	 *  Otherwise refer to order (it is a prepayment)
	 * 
	 * @return Payment object
	 * 
	 */
private MPayment createPayment(String tenderType) {
    MPayment payment = new MPayment(Env.getCtx(), 0, trxName);
    payment.setAD_Org_ID(entityPOS.getAD_Org_ID());
    payment.setC_POS_ID(entityPOS.getC_POS_ID());
    payment.setTenderType(tenderType);
    payment.setIsReceipt(true);
    payment.setC_Order_ID(order.getC_Order_ID());
    payment.setIsPrepayment(true);
    payment.setC_BPartner_ID(getC_BPartner_ID());
    payment.setDateTrx(getDateTrx());
    payment.setDateAcct(getDateTrx());
    int invoiceId = order.getC_Invoice_ID();
    if (invoiceId > 0) {
        payment.setC_Invoice_ID(invoiceId);
        MInvoice invoice = new MInvoice(Env.getCtx(), payment.getC_Invoice_ID(), trxName);
        payment.setDescription(Msg.getMsg(Env.getCtx(), "Invoice No ") + invoice.getDocumentNo());
    } else {
        payment.setDescription(Msg.getMsg(Env.getCtx(), "Order No ") + order.getDocumentNo());
    }
    order.setC_POS_ID(entityPOS.getC_POS_ID());
    order.saveEx(trxName);
    return payment;
}
Also used : MPayment(org.compiere.model.MPayment) MInvoice(org.compiere.model.MInvoice)

Example 23 with MPayment

use of org.compiere.model.MPayment in project adempiere by adempiere.

the class Collect method payCheck.

// payCash
/**
	 * Payment with check
	 * @param amount
	 * @param accountNo
	 * @param routingNo
	 * @param checkNo
	 * @return true if payment processed correctly; otherwise false
	 */
public boolean payCheck(BigDecimal amount, String accountNo, String routingNo, String checkNo) {
    MPayment payment = createPayment(MPayment.TENDERTYPE_Check);
    payment.setC_CashBook_ID(entityPOS.getC_CashBook_ID());
    payment.setAmount(order.getC_Currency_ID(), amount);
    payment.setC_BankAccount_ID(entityPOS.getC_BankAccount_ID());
    payment.setAccountNo(accountNo);
    payment.setRoutingNo(routingNo);
    payment.setCheckNo(checkNo);
    payment.setDescription(checkNo);
    payment.setDateTrx(getDateTrx());
    payment.setDateAcct(getDateTrx());
    payment.saveEx();
    payment.setDocAction(MPayment.DOCACTION_Complete);
    payment.setDocStatus(MPayment.DOCSTATUS_Drafted);
    if (payment.processIt(MPayment.DOCACTION_Complete)) {
        payment.saveEx();
        MBankStatement.addPayment(payment);
        return true;
    } else {
        return false;
    }
}
Also used : MPayment(org.compiere.model.MPayment)

Example 24 with MPayment

use of org.compiere.model.MPayment in project adempiere by adempiere.

the class Collect method payCash.

/**
	 * Process Payment
	 * @param amount
	 * @return true if payment processed correctly; otherwise false
	 */
public boolean payCash(BigDecimal amount, BigDecimal overUnderAmt) {
    MPayment payment = createPayment(MPayment.TENDERTYPE_Cash);
    if (payment.isCashTrx() && !MSysConfig.getBooleanValue("CASH_AS_PAYMENT", true, payment.getAD_Client_ID()))
        payment.setC_CashBook_ID(entityPOS.getC_CashBook_ID());
    else
        payment.setC_BankAccount_ID(entityPOS.getC_BankAccount_ID());
    payment.setAmount(order.getC_Currency_ID(), amount);
    payment.setC_BankAccount_ID(entityPOS.getC_BankAccount_ID());
    payment.setDateTrx(getDateTrx());
    payment.setDateAcct(getDateTrx());
    payment.saveEx();
    payment.setOverUnderAmt(overUnderAmt);
    payment.saveEx();
    payment.setDocAction(MPayment.DOCACTION_Complete);
    payment.setDocStatus(MPayment.DOCSTATUS_Drafted);
    if (payment.processIt(MPayment.DOCACTION_Complete)) {
        payment.saveEx();
        MBankStatement.addPayment(payment);
        return true;
    } else
        return false;
}
Also used : MPayment(org.compiere.model.MPayment)

Example 25 with MPayment

use of org.compiere.model.MPayment in project adempiere by adempiere.

the class Collect method payCreditCard.

// payDirectDebit
/**
	 * 	Payment with credit card
	 * 
	 * @return true if payment processed correctly; otherwise false
	 * 
	 */
public boolean payCreditCard(BigDecimal amount, String accountName, int month, int year, String cardNo, String cvc, String cardtype) {
    MPayment payment = createPayment(MPayment.TENDERTYPE_CreditCard);
    payment.setAmount(order.getC_Currency_ID(), amount);
    payment.setC_BankAccount_ID(entityPOS.getC_BankAccount_ID());
    payment.setDateTrx(getDateTrx());
    payment.setDateAcct(getDateTrx());
    payment.setCreditCard(MPayment.TRXTYPE_Sales, cardtype, cardNo, cvc, month, year);
    payment.saveEx();
    payment.setDocAction(MPayment.DOCACTION_Complete);
    payment.setDocStatus(MPayment.DOCSTATUS_Drafted);
    if (payment.processIt(MPayment.DOCACTION_Complete)) {
        payment.saveEx();
        MBankStatement.addPayment(payment);
        return true;
    } else {
        return false;
    }
}
Also used : MPayment(org.compiere.model.MPayment)

Aggregations

MPayment (org.compiere.model.MPayment)47 BigDecimal (java.math.BigDecimal)14 MInvoice (org.compiere.model.MInvoice)12 Timestamp (java.sql.Timestamp)8 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 ArrayList (java.util.ArrayList)7 MCashLine (org.compiere.model.MCashLine)5 AdempiereSystemError (org.compiere.util.AdempiereSystemError)5 MAllocationLine (org.compiere.model.MAllocationLine)4 MBankStatement (org.compiere.model.MBankStatement)4 MOrder (org.compiere.model.MOrder)4 Properties (java.util.Properties)3 RequestDispatcher (javax.servlet.RequestDispatcher)3 HttpSession (javax.servlet.http.HttpSession)3 MAllocationHdr (org.compiere.model.MAllocationHdr)3 MBankAccount (org.compiere.model.MBankAccount)3 MBankStatementLine (org.compiere.model.MBankStatementLine)3 AdempiereUserError (org.compiere.util.AdempiereUserError)3 KeyNamePair (org.compiere.util.KeyNamePair)3