From: Anneli <an...@us...> - 2005-01-17 10:24:17
|
Update of /cvsroot/redpos/RedPOS/src/org/redpos/client/device In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17783/src/org/redpos/client/device Modified Files: ReceiptPrinter.java ReceiptPrinterRowFactory.java Log Message: New type of payment SimpleCurrencyExchange, enter rate on one currency in properties.xml, when using this payment type the amount will be shown in the currency entered, this is just for the gui part, no info about rate or will be saved in the database. Index: ReceiptPrinterRowFactory.java =================================================================== RCS file: /cvsroot/redpos/RedPOS/src/org/redpos/client/device/ReceiptPrinterRowFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReceiptPrinterRowFactory.java 11 Jan 2005 17:02:46 -0000 1.2 --- ReceiptPrinterRowFactory.java 17 Jan 2005 10:23:23 -0000 1.3 *************** *** 26,30 **** --- 26,34 ---- import java.text.DateFormat; + import javax.management.JMException; + import org.redpos.amount.Amount; + import org.redpos.client.contract.POSEngineUtility; + import org.redpos.client.contract.properties.PropertiesUtility; import org.redpos.client.contract.receipt.DiscountReceiptRow; import org.redpos.client.contract.receipt.ReceiptConstants; *************** *** 62,65 **** --- 66,74 ---- private Language lang = null; + + private double currencyRate; + private Amount toPay = new Amount(0); + private Amount entered = new Amount(0); + private Amount back = new Amount(0); /** *************** *** 379,383 **** discountAmount.toNumberString(), false)); printableRow.append(NEW_LINE); ! break; --- 388,392 ---- discountAmount.toNumberString(), false)); printableRow.append(NEW_LINE); ! break; *************** *** 390,394 **** discountRowAmount.toNumberString(), false)); printableRow.append(NEW_LINE); ! break; --- 399,403 ---- discountRowAmount.toNumberString(), false)); printableRow.append(NEW_LINE); ! break; *************** *** 401,412 **** totalDiscountPercentAmount.toNumberString(), false)); printableRow.append(NEW_LINE); ! break; case ReceiptConstants.TYPE_RECEIPTROW_PAYMENT: Amount paymentAmount = rr.getAmount(); ! printableRow.append(formatString(rr.getText(), rr.getAmount().absolute().toNumberString(), false)); ! printableRow.append(NEW_LINE); /* if (paymentAmount.doubleValue() < 0) --- 410,441 ---- totalDiscountPercentAmount.toNumberString(), false)); printableRow.append(NEW_LINE); ! break; case ReceiptConstants.TYPE_RECEIPTROW_PAYMENT: Amount paymentAmount = rr.getAmount(); ! ! // the amount to receive will be shown in a different currency ! if ((rr.getObject().equals("SICUEX")) && (rr.getText().equals(lang.getString( ! "client.receiptprinter.change.text", "Change")))) ! { ! toPay.multiply(currencyRate); ! back.add(toPay); ! back.subtract(entered); ! ! paymentAmount.multiply(currencyRate); ! String text = rr.getText() + lang.getString("ui.plugin.receiptprinter.change2.text", ! "Currency: "); ! printableRow.append(formatString(text, ! back.absolute().toNumberString(), false)); ! printableRow.append(NEW_LINE); ! } ! else ! { ! printableRow.append(formatString(rr.getText(), rr.getAmount().absolute().toNumberString(), false)); ! printableRow.append(NEW_LINE); ! entered.add(rr.getAmount()); ! } /* if (paymentAmount.doubleValue() < 0) *************** *** 431,435 **** break; } - return printableRow.toString(); } --- 460,463 ---- *************** *** 447,450 **** --- 475,479 ---- "client.receiptprinter.subtotal.text", "Total"), total.toNumberString(), false)); + toPay.add(total); printableTotalRow.append(NEW_LINE); return printableTotalRow.toString(); *************** *** 546,549 **** return row.toString(); } ! } \ No newline at end of file --- 575,598 ---- return row.toString(); } ! ! /** ! * Sets currency rate ! * ! */ ! public void setCurrencyRate(double rate) ! { ! currencyRate = rate; ! } ! ! /** ! * Resets a number of variables ! * ! */ ! public void reset() ! { ! toPay = new Amount(0.0); ! entered = new Amount(0.0); ! back = new Amount(0.0); ! } ! } \ No newline at end of file Index: ReceiptPrinter.java =================================================================== RCS file: /cvsroot/redpos/RedPOS/src/org/redpos/client/device/ReceiptPrinter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReceiptPrinter.java 11 Jan 2005 17:02:46 -0000 1.2 --- ReceiptPrinter.java 17 Jan 2005 10:23:23 -0000 1.3 *************** *** 41,44 **** --- 41,45 ---- import org.redpos.amount.Amount; + import org.redpos.client.contract.POSEngineUtility; import org.redpos.client.contract.properties.PropertiesUtility; import org.redpos.client.contract.receipt.PaymentReceiptRow; *************** *** 70,73 **** --- 71,76 ---- private ReceiptSessionUtility receiptUtility; + + private POSEngineUtility posEngineUtility; private POSPrinter posPrinter; *************** *** 86,90 **** private int receiptType; ! /** Payments started flag */ private boolean paymentsStarted; --- 89,94 ---- private int receiptType; ! ! /** Payments started flag */ private boolean paymentsStarted; *************** *** 107,110 **** --- 111,116 ---- // load properties // + posEngineUtility = new POSEngineUtility(getServer()); + Boolean enabled = (Boolean)po.getProperty("receiptprinter", "enabled"); if(enabled != null && enabled.booleanValue() == false) *************** *** 511,514 **** --- 517,529 ---- // the receipt is finished ReceiptPrinterRowFactory rowFactory = ReceiptPrinterRowFactory.getInstance(); + + try + { + rowFactory.setCurrencyRate(posEngineUtility.getCurrencyRate()); + } + catch(JMException e1) + { + log.error(e1.getMessage(), e1); + } Vector rows = data.receiptRows; *************** *** 569,572 **** --- 584,588 ---- receipt = new StringBuffer(); + rowFactory.reset(); } else if(n.getType().equals( |