Saturday 16 October 2010

OpenBravo

Found below link very useful:

http://forge.openbravo.com/plugins/espforum/view.php?group_id=101&forumid=434922&topicid=7015387

Keeing a copy here, in case the orginal is moved or broken.


==============
Discount Fixed
==============

Step 1: Create a new button for the main screen.

Login as Admin and goto maintainence --> resources and add the following line to "Ticket.Buttons"

< button key="button.discount" name="button.discount" code="Code.Discount" />


Step 2: Create a new resource called "Code.Discount" and add the follwing code to it.

import com.openbravo.format.Formats;
import com.openbravo.pos.ticket.TicketLineInfo;
import com.openbravo.pos.ticket.TicketProductInfo;

discountamount = sales.getInputValue();

index = sales.getSelectedIndex();
if (index >= 0) {
line = ticket.getLine(index);
if (line.getPrice() > 0.0 && discountamount > 0.0) {

sdiscount = Formats.CURRENCY.formatValue(discountamount);

ticket.insertLine(index + 1,
new TicketLineInfo(
"Discount " + sdiscount,
line.getProductTaxCategoryID(),
line.getMultiply(),
-discountamount,
line.getTaxInfo()));
sales.setSelectedIndex(index + 1);
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}


Step 3: Add permission to who all can use this function.

Either Administrator, Manager or Employees etc...

The following line will be added to maintainence ==> roles.


< class name="button.discount" />


Restart your POS and goto sales screen to check out your new button........ Viola


I would add one more step:

add following line in the pos_messages.properties located in Locales folder so a proper label on the button is placed.


button.discount=Discount



==================
Discount Percentag
==================

Here is the code for a user entered discount percentage rate.

Pros: You can enter discount amount. i.e. 10% of total ticket entered as 10

20% of total ticket entered as 20 and so on

Cons: You can not remove the discount once entered. ( can anyone point me how to add this exception as it gives out a strange error )



Input this code in a new resource called "discount.Total"



// % Discount for the total of the receipt

import com.openbravo.format.Formats;
import com.openbravo.pos.ticket.TicketLineInfo;
import com.openbravo.pos.ticket.TicketProductInfo;
import java.util.Properties;

discountperc = JOptionPane.showInputDialog(null, "Input percentage.....");
double discountrate = Double.parseDouble(discountperc);
discountrate = discountrate/100.00;

total = ticket.getTotal();
if (total > 0.0) {
sdiscount = Formats.PERCENT.formatValue(discountrate);

taxes = ticket.getTaxLines();
for (int i = 0; i < taxes.length; i++) {
taxline = taxes[i];
ticket.insertLine(ticket.getLinesCount(),
new TicketLineInfo(
"Discount " + sdiscount + " of " + taxline.printSubTotal(),
taxline.getTaxInfo().getTaxCategoryID(),
1.0,
-taxline.getSubTotal() * discountrate,
taxline.getTaxInfo()));
}
sales.setSelectedIndex(ticket.getLinesCount() - 1);
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}


now create a new button in "Ticket.Buttons"


< button key="button.discount" name="button.discount" code="discount.Total" />


and also add the permission in maintenance -> roles


< class name="button.discount" />

Wednesday 6 October 2010

Temp tablespace


CREATE TEMPORARY TABLESPACE temp_n TEMPFILE '/u01/oracle/oradata/NIDEV/temp_01.dbf' SIZE 500M
autoextend off extent management local UNIFORM SIZE 1M;

alter database default temporary tablespace temp_n;



col PROPERTY_VALUE for a40
col DESCRIPTION for a40
select * from database_properties;