use of org.compiere.model.MPOS in project lar_361 by comitsrl.
the class FiscalDocumentPrintTest method createTestData.
private void createTestData() throws Exception {
// Mock objetcs
fiscalDocumentListener = EasyMock.createMock(FiscalDocumentListener.class);
fiscalPrinterListener = EasyMock.createMock(FiscalPrinterListener.class);
// Fiscal Printer Type
fiscalPrinterType = new X_LAR_Fiscal_Printer_Type(getCtx(), 0, getTrxName());
fiscalPrinterType.setClazz("ar.com.ergio.print.fiscal.hasar.HasarPrinterP320F");
fiscalPrinterType.setIsActive(true);
fiscalPrinterType.setName("Test Printer Type");
fiscalPrinterType.save();
// Fiscal Printer
fiscalPrinter = new MFiscalPrinter(getCtx(), 0, getTrxName());
fiscalPrinter.setLAR_Fiscal_Printer_Type_ID(fiscalPrinterType.getLAR_Fiscal_Printer_Type_ID());
fiscalPrinter.setName("Test Printer");
fiscalPrinter.setHost("localhost");
fiscalPrinter.setPort(SERVER_PORT);
// TODO - should be init AD config with this status?
fiscalPrinter.setStatus("IDL");
fiscalPrinter.save();
// POS Model
posModel = new MPOS(getCtx(), 0, getTrxName());
posModel.setName("Test POS");
posModel.setC_DocType_ID(m_C_DocType_ID);
posModel.setSalesRep_ID(getAD_User_ID());
posModel.setM_PriceList_ID(m_M_PriceList_ID);
posModel.setC_CashBook_ID(m_C_CashBook_ID);
posModel.setM_Warehouse_ID(m_M_Warehouse_ID);
posModel.setC_BankAccount_ID(m_C_BankAccount_ID);
posModel.save();
// POS Order Model
MBPartner partner = new MBPartner(getCtx(), m_C_BPartner_ID, getTrxName());
if (partner.getTaxID() == null || partner.getTaxID().equals("")) {
partner.setTaxID("30-71135312-3");
partner.save();
}
MProduct product = new MProduct(getCtx(), m_M_Product_ID, getTrxName());
posOrder = PosOrderModel.createOrder(posModel, partner, 0, getTrxName());
posOrder.createLine(product, BigDecimal.valueOf(1), BigDecimal.valueOf(100), 0);
posOrder.payCash(BigDecimal.valueOf(100));
if (posOrder.processOrder()) {
commit();
}
}
use of org.compiere.model.MPOS in project lar_361 by comitsrl.
the class PosBasePanel method getPOSs.
// setMPOS
/**
* Get POSs for specific Sales Rep and Org
* @param SalesRep_ID
* @return array of POS
*/
private MPOS[] getPOSs(int SalesRep_ID) {
String whereClause = "AD_Org_ID=?";
Object[] params = new Object[] { Env.getAD_Org_ID(m_ctx) };
List<MPOS> list = new Query(m_ctx, MPOS.Table_Name, whereClause, null).setParameters(params).setOnlyActiveRecords(true).list();
return list.toArray(new MPOS[list.size()]);
}
use of org.compiere.model.MPOS in project lar_361 by comitsrl.
the class WsfeV1 method createInputFile.
/**
* @author: Horacio Alvarez
* @descripcion: Crea el archivo de entrada para el WSFE.PY.
* Setea los valores necesarios con el objeto MInvoice.
*/
@Override
protected void createInputFile() {
try {
StringBuffer line = new StringBuffer();
// *****NRO. COMPROBANTE
if (this.getInvoice().getNumeroComprobante() == 0) {
this.setMessageError(Msg.translate(this.getM_ctx(), "CaeNoNumeroComprobante"));
return;
}
line.append(this.getInvoice().getNumeroComprobante() + "\n");
// *****PUNTO DE VENTA
final MPOS pos = new MPOS(getM_ctx(), this.getInvoice().get_ValueAsInt("C_Pos_ID"), getTrxName());
if (pos.get_ValueAsInt("PosNumber") == 0) {
this.setMessageError(Msg.translate(this.getM_ctx(), "CaeNoPuntoDeVenta"));
return;
}
line.append(pos.get_ValueAsInt("PosNumber") + "\n");
// *****TIPO DE COMPROBANTE
MDocType docType = new MDocType(Env.getCtx(), this.getInvoice().getC_DocTypeTarget_ID(), getTrxName());
line.append(docType.getdocsubtypecae() + "\n");
// *****TIPO DOC: 80 CUIT / 96 DNI
MBPartner partner = new MBPartner(this.getM_ctx(), this.getInvoice().getC_BPartner_ID(), getTrxName());
final X_LCO_TaxPayerType taxPayerType = new X_LCO_TaxPayerType(getM_ctx(), partner.get_ValueAsInt("LCO_TaxPayerType_ID"), getTrxName());
if (taxPayerType.getName().equals("ConsumidorFinal")) {
line.append("96" + "\n");
line.append("1" + "\n");
} else {
line.append("80" + "\n");
if (partner.getTaxID() == null || partner.getTaxID().equals("")) {
this.setMessageError(Msg.translate(this.getM_ctx(), "CaeNoCUIT"));
return;
}
line.append(partner.getTaxID().replaceAll("-", "") + "\n");
}
// *****IMPORTE TOTAL
// line.append(this.getInvoice().getGrandTotal().toString().replace(".", "")+"\n");
line.append(this.getInvoice().getGrandTotal().setScale(2, BigDecimal.ROUND_HALF_UP) + "\n");
// *****IMPORTE NETO
// line.append(this.getInvoice().getTotalLines().toString().replace(".", "")+"\n");
line.append(this.getInvoice().getTotalLines().setScale(2, BigDecimal.ROUND_HALF_UP) + "\n");
// *****FECHA
if (this.getInvoice().getDateAcct() == null) {
this.setMessageError(Msg.translate(this.getM_ctx(), "CaeNoDateAcct"));
return;
}
line.append(formatTime(this.getInvoice().getDateAcct(), "yyyyMMdd") + "\n");
// *****PRESTA SERVICIOS 0-->NO 1-->SI
line.append(MSysConfig.getValue("LAR_PrestaServicios_FE", Env.getAD_Client_ID(Env.getCtx())) + "\n");
// *****MONEDA
MCurrency currency = new MCurrency(this.getM_ctx(), this.getInvoice().getC_Currency_ID(), getTrxName());
line.append(currency.get_ValueAsString("WSFECode") + "\n");
// *****CONVERSION
// Se debe convertir a la moneda del comprobante desde la moneda de la compañía
BigDecimal cotizacion = MCurrency.currencyConvert(Env.ONE, Env.getContextAsInt(this.getM_ctx(), "$C_Currency_ID"), this.getInvoice().getC_Currency_ID(), this.getInvoice().getDateInvoiced(), 0, this.getM_ctx());
line.append(cotizacion + "\n");
// *****IMPUESTO
BigDecimal total_Impuesto = BigDecimal.ZERO;
MInvoiceTax[] taxes = this.getInvoice().getTaxes(false);
MTax tax = null;
int size = taxes.length;
boolean firstLineAppended = false;
for (int i = 0; i < size; i++) {
tax = MTax.get(this.getM_ctx(), taxes[i].getC_Tax_ID());
if (!tax.get_ValueAsBoolean("IsPerception")) {
total_Impuesto = total_Impuesto.add(taxes[i].getTaxAmt().setScale(2, BigDecimal.ROUND_HALF_UP));
taxes[i].getTaxAmt();
taxes[i].getTaxBaseAmt();
tax.get_ValueAsString("WSFECode");
if (firstLineAppended) {
line.append(";");
}
line.append(tax.get_ValueAsString("WSFECode") + ":" + (getTaxBaseAmt(taxes[i].getTaxBaseAmt(), this.getInvoice().getGrandTotal(), getTaxesAmt(this.getInvoice()))).setScale(2, BigDecimal.ROUND_HALF_UP) + ":" + taxes[i].getTaxAmt().setScale(2, BigDecimal.ROUND_HALF_UP));
firstLineAppended = true;
}
}
line.append("\n");
// *****MONTO TOTAL DE IMPUESTOS
line.append(total_Impuesto + "\n");
// *****IMPUESTOS PERCEPCIONES
BigDecimal total_Perception = BigDecimal.ZERO;
MInvoiceTax[] taxesPerc = this.getInvoice().getTaxes(true);
MTax taxPerc = null;
int sizePerc = taxesPerc.length;
boolean firstLineAppended2 = false;
for (int i = 0; i < sizePerc; i++) {
taxPerc = MTax.get(this.getM_ctx(), taxesPerc[i].getC_Tax_ID());
if (taxPerc.get_ValueAsBoolean("IsPerception")) {
total_Perception = total_Perception.add(taxesPerc[i].getTaxAmt().setScale(2, BigDecimal.ROUND_HALF_UP));
taxesPerc[i].getTaxAmt();
taxesPerc[i].getTaxBaseAmt();
taxPerc.get_ValueAsInt("WSFECode");
if (firstLineAppended2) {
line.append(";");
}
BigDecimal alic = (taxPerc.getRate().setScale(2, BigDecimal.ROUND_HALF_UP)).negate();
line.append(taxPerc.get_ValueAsInt("WSFECode") + ":" + (getTaxBaseAmt(taxesPerc[i].getTaxBaseAmt(), this.getInvoice().getGrandTotal(), getTaxesAmt(this.getInvoice()))).setScale(2, BigDecimal.ROUND_HALF_UP) + ":" + taxesPerc[i].getTaxAmt().setScale(2, BigDecimal.ROUND_HALF_UP) + ":" + alic);
firstLineAppended2 = true;
}
}
if (total_Perception.equals(Env.ZERO))
line.append("0");
line.append("\n");
// *****MONTO TOTAL DE PERCEPCIONES
line.append(total_Perception + "\n");
// *****C_INVOICE_ID para seguimiento
line.append(this.getInvoice().getC_Invoice_ID() + "\n");
File textFile = new File(getPath() + "entrada.txt");
FileWriter textOut;
textOut = new FileWriter(textFile);
textOut.write(line.toString());
textOut.close();
} catch (Exception ex) {
this.setMessageError(Msg.translate(this.getM_ctx(), "caeErrorCreateInputFile"));
log.log(Level.SEVERE, this.getMessageError(), ex);
}
}
use of org.compiere.model.MPOS in project adempiere by adempiere.
the class WPOS method setMPOS.
// dynInit
/**
* Set MPOS
* @return true if found/set
*/
private void setMPOS() {
int salesRep_ID = Env.getAD_User_ID(getCtx());
setPOS(salesRep_ID);
if (getM_POS() != null) {
validLocator();
return;
}
int orgId = Env.getAD_Org_ID(getCtx());
poss = getPOSByOrganization(orgId);
// Select POS
String msg = Msg.getMsg(ctx, "SelectPOS");
selection = new Window();
Panel mainPanel = new Panel();
Panel panel = new Panel();
selection.setTitle(msg);
Borderlayout mainLayout = new Borderlayout();
Grid layout = GridFactory.newGridLayout();
selection.appendChild(panel);
selection.setWidth("200px");
selection.setHeight("140px");
// North
Panel centerPanel = new Panel();
mainPanel.appendChild(mainLayout);
mainPanel.setStyle("width: 100%; height: 100%; padding: 0; margin: 0");
mainLayout.setHeight("100%");
mainLayout.setWidth("100%");
//
Center center = new Center();
center.setStyle("border: none");
mainLayout.appendChild(center);
center.appendChild(centerPanel);
centerPanel.appendChild(layout);
layout.setWidth("100%");
layout.setHeight("100%");
selection.appendChild(mainPanel);
Rows rows = null;
Row row = null;
rows = layout.newRows();
row = rows.newRow();
for (MPOS pos : poss) {
listTerminal.addItem(pos.getKeyNamePair());
}
okButton.addActionListener(this);
cancelButton.addEventListener("onClick", this);
okButton.setWidth("45px");
okButton.setHeight("45px");
cancelButton.setWidth("45px");
cancelButton.setHeight("45px");
listTerminal.setHeight("45px");
listTerminal.setStyle("height:45px;" + WPOS.FONTSIZEMEDIUM);
row.setSpans("2");
row.appendChild(listTerminal);
row.setHeight("45px");
row = rows.newRow();
confirm = new ConfirmPanel(true);
confirm.addActionListener(this);
confirm.getOKButton().setWidth("55px");
confirm.getOKButton().setHeight("55px");
confirm.getButton(ConfirmPanel.A_CANCEL).setWidth("55px");
confirm.getButton(ConfirmPanel.A_CANCEL).setHeight("55px");
row.appendChild(confirm);
row.setHeight("55px");
AEnv.showWindow(selection);
}
use of org.compiere.model.MPOS in project lar_361 by comitsrl.
the class Wsfe method getPath.
/**
* @author Horacio Alvarez
* @return: Devuelve el path donde se encuentra alojado el proceso wsfe.py en el
* sistema de archvos local. Este path se guarda en la tabla AD_Preference (Valores Predeterminados)
*/
protected String getPath() {
/**
* El nombre de AD_Preference a consultar se forma concatenando el valor
* WSFE_PV y el Nro de Punto de Venta
*/
if (path != "")
return path;
else {
MPOS pos = new MPOS(m_ctx, invoice.get_ValueAsInt("C_Pos_ID"), trxName);
String atributo = "WSFE_PV" + pos.get_ValueAsInt("PosNumber");
// @fchiappano Si el SO es Windows, busco la preferencia del mismo.
String osName = System.getProperty("os.name");
if (!osName.equals("Linux"))
atributo = atributo + "_WIN";
MPreference preference = MPreference.getOrgPreference(Env.getAD_Client_ID(getM_ctx()), Env.getAD_Org_ID(getM_ctx()), atributo, getM_ctx(), getTrxName());
// por defecto que es: WSFE
if (preference == null) {
atributo = "WSFE";
preference = MPreference.getOrgPreference(Env.getAD_Client_ID(getM_ctx()), Env.getAD_Org_ID(getM_ctx()), atributo, getM_ctx(), getTrxName());
}
path = preference.getValue();
return path;
}
}
Aggregations