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;
}
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++;
}
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;
}
Aggregations