Search in sources :

Example 1 with BPartnerNoAddressException

use of org.adempiere.exceptions.BPartnerNoAddressException in project adempiere by adempiere.

the class DunningRunCreate method createPaymentLine.

//	addPayments
/**
	 * 	Create Payment Line
	 *	@param C_Payment_ID
	 *	@param C_Currency_ID
	 *	@param PayAmt
	 *	@param OpenAmt
	 *	@param C_BPartner_ID
	 *  @param c_DunningLevel_ID 
	 */
private boolean createPaymentLine(int C_Payment_ID, int C_Currency_ID, BigDecimal PayAmt, BigDecimal OpenAmt, int C_BPartner_ID, int c_DunningLevel_ID) {
    MDunningRunEntry entry = null;
    try {
        entry = m_run.getEntry(C_BPartner_ID, p_C_Currency_ID, p_SalesRep_ID, c_DunningLevel_ID);
    } catch (BPartnerNoAddressException e) {
        MPayment payment = new MPayment(getCtx(), C_Payment_ID, null);
        String msg = "@Skip@ @C_Payment_ID@ " + payment.getDocumentInfo() + ", @C_BPartner_ID@ " + MBPartner.get(getCtx(), C_BPartner_ID).getName() + " @No@ @IsActive@ @C_BPartner_Location_ID@";
        getProcessInfo().addLog(getProcessInfo().getAD_PInstance_ID(), null, null, msg);
        return false;
    }
    if (entry.get_ID() == 0)
        if (!entry.save())
            throw new IllegalStateException("Cannot save MDunningRunEntry");
    //
    MDunningRunLine line = new MDunningRunLine(entry);
    line.setPayment(C_Payment_ID, C_Currency_ID, PayAmt, OpenAmt);
    if (!line.save())
        throw new IllegalStateException("Cannot save MDunningRunLine");
    return true;
}
Also used : MDunningRunEntry(org.compiere.model.MDunningRunEntry) MPayment(org.compiere.model.MPayment) MDunningRunLine(org.compiere.model.MDunningRunLine) BPartnerNoAddressException(org.adempiere.exceptions.BPartnerNoAddressException)

Example 2 with BPartnerNoAddressException

use of org.adempiere.exceptions.BPartnerNoAddressException in project adempiere by adempiere.

the class DunningRunCreate method createInvoiceLine.

//	addInvoices
/**
	 * 	Create Invoice Line
	 *	@param C_Invoice_ID
	 *	@param C_Currency_ID
	 *	@param GrandTotal
	 *	@param Open
	 *	@param DaysDue
	 *	@param IsInDispute
	 *	@param C_BPartner_ID
	 *	@param TimesDunned
	 *	@param DaysAfterLast
	 *  @param c_DunningLevel_ID 
	 */
private boolean createInvoiceLine(int C_Invoice_ID, int C_InvoicePaySchedule_ID, int C_Currency_ID, BigDecimal GrandTotal, BigDecimal Open, int DaysDue, boolean IsInDispute, int C_BPartner_ID, int TimesDunned, int DaysAfterLast, int c_DunningLevel_ID) {
    MDunningRunEntry entry = null;
    try {
        entry = m_run.getEntry(C_BPartner_ID, p_C_Currency_ID, p_SalesRep_ID, c_DunningLevel_ID);
    } catch (BPartnerNoAddressException e) {
        String msg = "@Skip@ @C_Invoice_ID@ " + MInvoice.get(getCtx(), C_Invoice_ID).getDocumentInfo() + ", @C_BPartner_ID@ " + MBPartner.get(getCtx(), C_BPartner_ID).getName() + " @No@ @IsActive@ @C_BPartner_Location_ID@";
        getProcessInfo().addLog(getProcessInfo().getAD_PInstance_ID(), null, null, msg);
        return false;
    }
    if (entry.get_ID() == 0) {
        if (!entry.save())
            throw new IllegalStateException("Cannot save MDunningRunEntry");
    }
    //
    MDunningRunLine line = new MDunningRunLine(entry);
    line.setInvoice(C_Invoice_ID, C_Currency_ID, GrandTotal, Open, new BigDecimal(0), DaysDue, IsInDispute, TimesDunned, DaysAfterLast);
    line.setC_InvoicePaySchedule_ID(C_InvoicePaySchedule_ID);
    if (!line.save())
        throw new IllegalStateException("Cannot save MDunningRunLine");
    return true;
}
Also used : MDunningRunEntry(org.compiere.model.MDunningRunEntry) MDunningRunLine(org.compiere.model.MDunningRunLine) BPartnerNoAddressException(org.adempiere.exceptions.BPartnerNoAddressException) BigDecimal(java.math.BigDecimal)

Example 3 with BPartnerNoAddressException

use of org.adempiere.exceptions.BPartnerNoAddressException in project adempiere by adempiere.

the class MInvoice method setBPartner.

//	setClientOrg
/**
	 * 	Set Business Partner Defaults & Details
	 * 	@param bp business partner
	 */
public void setBPartner(MBPartner bp) {
    if (bp == null)
        return;
    setC_BPartner_ID(bp.getC_BPartner_ID());
    //	Set Defaults
    int ii = 0;
    if (isSOTrx())
        ii = bp.getC_PaymentTerm_ID();
    else
        ii = bp.getPO_PaymentTerm_ID();
    if (ii != 0)
        setC_PaymentTerm_ID(ii);
    //
    if (isSOTrx())
        ii = bp.getM_PriceList_ID();
    else
        ii = bp.getPO_PriceList_ID();
    if (ii != 0)
        setM_PriceList_ID(ii);
    //
    String ss = bp.getPaymentRule();
    if (ss != null)
        setPaymentRule(ss);
    //	Set Locations
    MBPartnerLocation[] locs = bp.getLocations(false);
    if (locs != null) {
        for (int i = 0; i < locs.length; i++) {
            if ((locs[i].isBillTo() && isSOTrx()) || (locs[i].isPayFrom() && !isSOTrx()))
                setC_BPartner_Location_ID(locs[i].getC_BPartner_Location_ID());
        }
        //	set to first
        if (getC_BPartner_Location_ID() == 0 && locs.length > 0)
            setC_BPartner_Location_ID(locs[0].getC_BPartner_Location_ID());
    }
    if (getC_BPartner_Location_ID() == 0)
        //TODO: throw exception?
        log.log(Level.SEVERE, new BPartnerNoAddressException(bp).getLocalizedMessage());
    //	Set Contact
    MUser[] contacts = bp.getContacts(false);
    if (//	get first User
    contacts != null && contacts.length > 0)
        setAD_User_ID(contacts[0].getAD_User_ID());
}
Also used : BPartnerNoAddressException(org.adempiere.exceptions.BPartnerNoAddressException)

Aggregations

BPartnerNoAddressException (org.adempiere.exceptions.BPartnerNoAddressException)3 MDunningRunEntry (org.compiere.model.MDunningRunEntry)2 MDunningRunLine (org.compiere.model.MDunningRunLine)2 BigDecimal (java.math.BigDecimal)1 MPayment (org.compiere.model.MPayment)1