use of org.compiere.model.MInvoice in project lar_361 by comitsrl.
the class InvoiceGenerate method createLine.
// generate
/**
************************************************************************
* Create Invoice Line from Order Line
* @param order order
* @param orderLine line
* @param qtyInvoiced qty
* @param qtyEntered qty
*/
private void createLine(MOrder order, MOrderLine orderLine, BigDecimal qtyInvoiced, BigDecimal qtyEntered) {
if (m_invoice == null) {
m_invoice = new MInvoice(order, 0, p_DateInvoiced);
// @emmie custom
m_invoice.set_ValueOfColumn("C_POS_ID", p_C_POS_ID);
// @emmie custom
if (!m_invoice.save())
throw new IllegalStateException("Could not create Invoice (o)");
}
//
MInvoiceLine line = new MInvoiceLine(m_invoice);
line.setOrderLine(orderLine);
line.setQtyInvoiced(qtyInvoiced);
line.setQtyEntered(qtyEntered);
line.setLine(m_line + orderLine.getLine());
if (!line.save())
throw new IllegalStateException("Could not create Invoice Line (o)");
log.fine(line.toString());
}
use of org.compiere.model.MInvoice in project lar_361 by comitsrl.
the class InvoiceGenerateRMA method createInvoice.
private MInvoice createInvoice(MRMA rma) {
int docTypeId = getInvoiceDocTypeId(rma.get_ID());
if (docTypeId == -1) {
throw new IllegalStateException("Could not get invoice document type for Vendor RMA");
}
MInvoice invoice = new MInvoice(getCtx(), 0, get_TrxName());
invoice.setRMA(rma);
// @fchiappano Obtener el ID de la factura Origen, desde el remito
// vinculado en la RMA.
int c_Invoice_ID = rma.getInOut().getC_Invoice_ID();
if (c_Invoice_ID == 0) {
int c_OrderLine_ID = rma.getShipment().getLines()[0].getC_OrderLine_ID();
String sql = "SELECT i.C_Invoice_ID" + " FROM C_OrderLine ol" + " JOIN C_InvoiceLine il ON ol.C_OrderLine_ID = il.C_OrderLine_ID" + " JOIN C_Invoice i ON il.C_Invoice_ID = i.C_Invoice_ID" + " WHERE ol.C_OrderLine_ID = ?";
c_Invoice_ID = DB.getSQLValue(get_TrxName(), sql, c_OrderLine_ID);
}
invoice.set_ValueOfColumn("Source_Invoice_ID", c_Invoice_ID);
// @emmie custom
invoice.set_ValueOfColumn("C_POS_ID", p_C_POS_ID);
// @emmie custom
invoice.setC_DocTypeTarget_ID(docTypeId);
if (!invoice.save()) {
throw new IllegalStateException("Could not create invoice");
}
return invoice;
}
use of org.compiere.model.MInvoice in project lar_361 by comitsrl.
the class PosSubPanel method printTicket.
// actionPerformed
/**
* Print Ticket
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) ConSerTi
*/
public void printTicket() {
if (p_posPanel.m_order == null)
return;
final MOrder order = p_posPanel.m_order;
boolean isFiscal = false;
boolean isElectronic = false;
boolean isJavaPOS = p_pos.get_ValueAsBoolean("IsJavaPOS");
int reportType = 0;
int documentId = 0;
String impresoraFactura = "";
if (order != null) {
if (p_pos.get_ValueAsBoolean("IsShipment")) {
// /// Procesa Remitos /////
final MInOut shipment = p_posPanel.m_order.getShipments()[0];
int C_DocType_ID = shipment.getC_DocType_ID();
isFiscal = LAR_Utils.isFiscalDocType(C_DocType_ID);
if (isFiscal) {
// Impresión fiscal del de remito generado
if (!p_posPanel.printFiscalTicket(shipment)) {
log.log(Level.SEVERE, "Error in Fiscal Printing Ticket");
return;
}
} else {
reportType = ReportEngine.SHIPMENT;
documentId = order.getC_Order_ID();
}
} else {
// /// Procesa Facturas /////
final MInvoice invoice = p_posPanel.m_order.getInvoices()[0];
int C_DocType_ID = invoice.getC_DocType_ID();
isFiscal = LAR_Utils.isFiscalDocType(C_DocType_ID);
isElectronic = MDocType.isElectronicDocType(C_DocType_ID);
// Si DocType es fiscal se utiliza el controlador fiscal
if (isFiscal && !isElectronic) {
// Impresión fiscal de factura
if (!p_posPanel.printFiscalTicket(invoice)) {
log.log(Level.SEVERE, "Error en impresi\u00f3n de factura fiscal");
return;
}
} else {
reportType = ReportEngine.INVOICE;
documentId = invoice.getC_Invoice_ID();
if (isElectronic) {
ReportCtl.startDocumentPrint(reportType, null, documentId, null, Env.getWindowNo(this), true, impresoraFactura);
}
}
}
// Si no se trata de un documento fiscal, se imprime de forma tradicional
if (!isFiscal) {
if (isJavaPOS) {
final MInvoice invoice = p_posPanel.m_order.getInvoices()[0];
final ImprimeTicketCompra ticketCompra = new ImprimeTicketCompra(invoice);
try {
ticketCompra.imprimir();
// @fchiappano Imprimir ticket de envio a domicilio.
if (p_posPanel.m_order.get_ValueAsBoolean("ImprimirEnvio")) {
final ImprimeTicketEnvio ticketEnvio = new ImprimeTicketEnvio(order);
ticketEnvio.imprimir();
}
} catch (JposException e) {
log.log(Level.SEVERE, "Error al imprimir v\u00eda Java POS", e);
}
}
p_posPanel.newOrder();
ReportCtl.startDocumentPrint(reportType, documentId, null, Env.getWindowNo(this), false);
}
p_posPanel.stopGlassPane();
}
// if (order != null)
}
use of org.compiere.model.MInvoice in project lar_361 by comitsrl.
the class ImprimeTicketCompra method imprimirDocumento.
@Override
protected void imprimirDocumento() throws JposException {
printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, 11);
final MInvoice factura = (MInvoice) documento;
datos = new DatosImpresion(factura);
printEncabezado(factura);
printDetalle(factura);
printTotales(factura);
printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, LF);
printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, CUT);
printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_NORMAL);
}
use of org.compiere.model.MInvoice in project lar_361 by comitsrl.
the class LAR_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(final PO po, int type) throws Exception {
log.info(po.get_TableName() + " Type: " + type);
String msg;
// Changes on BPartners
if (po.get_TableName().equals(MBPartner.Table_Name) && (type == TYPE_BEFORE_CHANGE || type == TYPE_BEFORE_NEW)) {
MBPartner bp = (MBPartner) po;
LAR_TaxPayerType taxPayerType = LAR_TaxPayerType.getTaxPayerType(bp);
if (MSysConfig.getBooleanValue("LAR_ValidarCuitSdN", true, Env.getAD_Client_ID(Env.getCtx())) && !taxPayerType.equals(LAR_TaxPayerType.CONSUMIDOR_FINAL)) {
// Check CUIT number
String cuit = bp.get_ValueAsString("TaxID");
if (!LAR_Utils.validateCUIT(cuit)) {
return "ERROR: CUIT invalido";
}
}
String checkDuplicidad = MSysConfig.getValue("LAR_PermitirDuplicidadCuit/Dni", "N", Env.getAD_Client_ID(Env.getCtx()));
if ((checkDuplicidad.equals("N") || (checkDuplicidad.equals("A") && type == TYPE_BEFORE_NEW)) && LAR_Utils.checkDuplicateCUIT(bp.getTaxID(), bp.getC_BPartner_ID()))
return "ERROR: CUIT/DNI Duplicado";
}
// Changes on OrderLines
if (po.get_TableName().equals(MOrderLine.Table_Name) && (type == TYPE_AFTER_NEW || type == TYPE_AFTER_DELETE || type == TYPE_AFTER_CHANGE)) {
MOrderLine ol = (MOrderLine) po;
int c_BPartner_ID = ol.getC_BPartner_ID();
MBPartner bp = new MBPartner(ol.getCtx(), c_BPartner_ID, ol.get_TrxName());
msg = LAR_CalcularPercepcion.calculateWhithholdingLine(bp, ol, type);
if (msg != null) {
return msg;
}
}
// Changes on Order
if (po.get_TableName().equals(MOrder.Table_Name) && type == TYPE_BEFORE_DELETE) {
MOrder order = (MOrder) po;
msg = LAR_CalcularPercepcion.deleteWhithholdingLine(order);
if (msg != null) {
return msg;
}
}
// con el asignado en su orden de remito origen
if (po.get_TableName().equals(MInOut.Table_Name) && type == TYPE_BEFORE_NEW) {
msg = changeShipmentDocumentNo((MInOut) po);
if (msg != null)
return msg;
}
// Elimina la retención sobre los pagos cuando se modifica el header
if (po.get_TableName().equals(MLARPaymentHeader.Table_Name) && type == TYPE_AFTER_CHANGE) {
msg = clearPaymentWithholdingFromHeader((MLARPaymentHeader) po);
if (msg != null) {
return msg;
}
}
// Determine letter for sales invoices (from PosOrders)
if (po.get_TableName().equals(MInvoice.Table_Name) && type == TYPE_AFTER_NEW) {
MInvoice invoice = (MInvoice) po;
msg = changeDocTypeForInvoice(invoice);
if (msg != null) {
return msg;
}
}
// Despues de modificar un pago, se actualiza la retención y el total de al cabecera
if (po.get_TableName().equals(MPayment.Table_Name) && (type == TYPE_AFTER_NEW || type == TYPE_AFTER_CHANGE || type == TYPE_AFTER_DELETE)) {
msg = clearPaymentWithholdingFromPayments((MPayment) po, type);
if (msg != null)
return msg;
msg = updatePaymentHeaderTotalAmt((MPayment) po, type);
if (msg != null)
return msg;
}
// Despues de modificar/agregar una factura se actualiza la retención y el total de la cabecera
if (po.get_TableName().equals(MPaymentAllocate.Table_Name) && (type == TYPE_AFTER_NEW || type == TYPE_AFTER_CHANGE || type == TYPE_AFTER_DELETE)) {
msg = clearPaymentWithholdingFromPaymentAllocate((MPaymentAllocate) po, type);
if (msg != null)
return msg;
}
// {
if (po.get_TableName().equals(MPayment.Table_Name) && (type == ModelValidator.TYPE_BEFORE_NEW || type == ModelValidator.TYPE_BEFORE_CHANGE)) {
MPayment pay = (MPayment) po;
Integer source = (Integer) pay.get_Value("LAR_PaymentSource_ID");
if ((source == null) || (source <= 0))
return null;
msg = setReconciled(source, "N", pay.get_TrxName());
if (msg != null)
return msg;
// Marcos Zúñiga -Excludes payment source from drawer (when is not reversal payment)
if (pay.getReversal_ID() == 0) {
msg = setIsOnDrawer(source, "N", pay.get_TrxName());
if (msg != null)
return msg;
}
msg = setReconciled(pay.getC_Payment_ID(), "N", pay.get_TrxName());
if (msg != null)
return msg;
}
if (po.get_TableName().equals(MPayment.Table_Name) && (type == ModelValidator.TYPE_BEFORE_DELETE)) {
MPayment pay = (MPayment) po;
Integer source = (Integer) pay.get_Value("LAR_PaymentSource_ID");
if ((source == null) || (source <= 0))
return null;
msg = setReconciled(source, "N", pay.get_TrxName());
if (msg != null)
return msg;
// Marcos Zúñiga
msg = setIsOnDrawer(source, "Y", pay.get_TrxName());
if (msg != null)
return msg;
}
return null;
}
Aggregations