Search in sources :

Example 96 with MInvoice

use of org.compiere.model.MInvoice in project lar_361 by comitsrl.

the class LCO_Validator method modelChange.

// initialize
/**
 *	Model Change of a monitored Table.
 *	Called after PO.beforeSave/PO.beforeDelete
 *	when you called addModelChange for the table
 *	@param po persistent object
 *	@param type TYPE_
 *	@return error message or null
 *	@exception Exception if the recipient wishes the change to be not accept.
 */
public String modelChange(PO po, int type) throws Exception {
    log.info(po.get_TableName() + " Type: " + type);
    String msg;
    if (po.get_TableName().equals(MInvoice.Table_Name) && type == ModelValidator.TYPE_BEFORE_CHANGE) {
        msg = clearInvoiceWithholdingAmtFromInvoice((MInvoice) po);
        if (msg != null)
            return msg;
    }
    // in order to force a regeneration
    if (po.get_TableName().equals(MInvoiceLine.Table_Name) && (type == ModelValidator.TYPE_BEFORE_NEW || type == ModelValidator.TYPE_BEFORE_CHANGE || type == ModelValidator.TYPE_BEFORE_DELETE)) {
        msg = clearInvoiceWithholdingAmtFromInvoiceLine((MInvoiceLine) po, type);
        if (msg != null)
            return msg;
    }
    // Check Digit based on TaxID
    if (po.get_TableName().equals(MBPartner.Table_Name) && (type == TYPE_BEFORE_NEW || type == TYPE_BEFORE_CHANGE)) {
        MBPartner bpartner = (MBPartner) po;
        msg = mcheckTaxIdDigit(bpartner);
        if (msg != null)
            return msg;
        msg = mfillName(bpartner);
        if (msg != null)
            return msg;
    }
    if (po.get_TableName().equals(X_LCO_TaxIdType.Table_Name) && (type == TYPE_BEFORE_NEW || type == TYPE_BEFORE_CHANGE)) {
        X_LCO_TaxIdType taxidtype = (X_LCO_TaxIdType) po;
        if ((!taxidtype.isUseTaxIdDigit()) && taxidtype.isDigitChecked())
            taxidtype.setIsDigitChecked(false);
    }
    if (po.get_TableName().equals(X_LCO_WithholdingCalc.Table_Name) && (type == ModelValidator.TYPE_BEFORE_CHANGE || type == ModelValidator.TYPE_BEFORE_NEW)) {
        X_LCO_WithholdingCalc lwc = (X_LCO_WithholdingCalc) po;
        if (lwc.isCalcOnInvoice() && lwc.isCalcOnPayment())
            lwc.setIsCalcOnPayment(false);
    }
    return null;
}
Also used : MInvoiceLine(org.compiere.model.MInvoiceLine) MInvoice(org.compiere.model.MInvoice) MBPartner(org.compiere.model.MBPartner)

Example 97 with MInvoice

use of org.compiere.model.MInvoice in project lar_361 by comitsrl.

the class InvoiceGenerateRMA method generateInvoice.

private void generateInvoice(int M_RMA_ID) {
    MRMA rma = new MRMA(getCtx(), M_RMA_ID, get_TrxName());
    MInvoice invoice = createInvoice(rma);
    MInvoiceLine[] invoiceLines = createInvoiceLines(rma, invoice);
    if (invoiceLines.length == 0) {
        log.log(Level.WARNING, "No invoice lines created: M_RMA_ID=" + M_RMA_ID + ", M_Invoice_ID=" + invoice.get_ID());
    }
    StringBuffer processMsg = new StringBuffer(invoice.getDocumentNo());
    if (!invoice.processIt(p_docAction)) {
        processMsg.append(" (NOT Processed)");
        log.warning("Invoice Processing failed: " + invoice + " - " + invoice.getProcessMsg());
        throw new IllegalStateException("Invoice Processing failed: " + invoice + " - " + invoice.getProcessMsg());
    }
    if (!invoice.save()) {
        throw new IllegalStateException("Could not update invoice");
    } else // @fchiappano Impresion Fiscal, si se completa la factura.
    {
        if (p_docAction.equals(MInvoice.DOCACTION_Complete) && LAR_Utils.isFiscalDocType(invoice.getC_DocType_ID())) {
            final InvoiceFiscalDocumentPrintManager manager = new InvoiceFiscalDocumentPrintManager(invoice);
            manager.print();
        }
    }
    // Add processing information to process log
    addLog(invoice.getC_Invoice_ID(), invoice.getDateInvoiced(), null, invoice.getDocumentNo());
    m_created++;
}
Also used : InvoiceFiscalDocumentPrintManager(ar.com.ergio.print.fiscal.view.InvoiceFiscalDocumentPrintManager) MInvoiceLine(org.compiere.model.MInvoiceLine) MInvoice(org.compiere.model.MInvoice) MRMA(org.compiere.model.MRMA)

Example 98 with MInvoice

use of org.compiere.model.MInvoice in project lar_361 by comitsrl.

the class OrderFiscalPrinting method doIt.

@Override
protected String doIt() throws Exception {
    log.info(String.format("Procesando orden %s", order));
    // Determina si la orden es POS o de Nota de Crédito para continuar con el proceso
    final MDocType dtTarget = new MDocType(getCtx(), order.getC_DocTypeTarget_ID(), get_TrxName());
    if (order.isSOTrx() && (dtTarget.getDocSubTypeSO().equals(MDocType.DOCSUBTYPESO_OnCreditOrder) || dtTarget.getDocSubTypeSO().equals(MDocType.DOCSUBTYPESO_POSOrder))) {
        final MInvoice invoice = new MInvoice(getCtx(), order.getC_Invoice_ID(), get_TrxName());
        // para imprimirla o no en el controlador fiscal
        if (invoice != null && LAR_Utils.isFiscalDocType(invoice.getC_DocType_ID())) {
            final InvoiceFiscalDocumentPrintManager manager = new InvoiceFiscalDocumentPrintManager(invoice);
            manager.print();
        }
    }
    return m_ResultMsg;
}
Also used : MDocType(org.compiere.model.MDocType) InvoiceFiscalDocumentPrintManager(ar.com.ergio.print.fiscal.view.InvoiceFiscalDocumentPrintManager) MInvoice(org.compiere.model.MInvoice)

Aggregations

MInvoice (org.compiere.model.MInvoice)98 BigDecimal (java.math.BigDecimal)29 MInvoiceLine (org.compiere.model.MInvoiceLine)27 MPayment (org.compiere.model.MPayment)16 MBPartner (org.compiere.model.MBPartner)15 MOrder (org.compiere.model.MOrder)15 MInOut (org.compiere.model.MInOut)14 ResultSet (java.sql.ResultSet)13 PreparedStatement (java.sql.PreparedStatement)12 Timestamp (java.sql.Timestamp)11 MDocType (org.compiere.model.MDocType)9 MInOutLine (org.compiere.model.MInOutLine)8 MOrderLine (org.compiere.model.MOrderLine)7 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 AdempiereException (org.adempiere.exceptions.AdempiereException)5 MClient (org.compiere.model.MClient)5 MLocation (org.compiere.model.MLocation)5 KeyNamePair (org.compiere.util.KeyNamePair)5 ValueNamePair (org.compiere.util.ValueNamePair)5