BF [ 2000929 ] Invoice History, Discount - wrong scale
This commit is contained in:
parent
b633da8b49
commit
20fa496489
|
@ -188,9 +188,10 @@ public class InvoiceHistory extends CDialog
|
||||||
*/
|
*/
|
||||||
private Vector<Vector<Object>> queryProduct ()
|
private Vector<Vector<Object>> queryProduct ()
|
||||||
{
|
{
|
||||||
String sql = "SELECT p.Name,l.PriceActual,l.PriceList,l.QtyInvoiced,"
|
String sql = "SELECT p.Name,l.PriceActual,l.PriceList,l.QtyInvoiced," // 1,2,3,4
|
||||||
+ "i.DateInvoiced,dt.PrintName || ' ' || i.DocumentNo As DocumentNo,"
|
+ "i.DateInvoiced,dt.PrintName || ' ' || i.DocumentNo As DocumentNo," // 5,6
|
||||||
+ "o.Name "
|
+ "o.Name, " // 7
|
||||||
|
+ "NULL, i.M_PriceList_ID " // 8,9
|
||||||
+ "FROM C_Invoice i"
|
+ "FROM C_Invoice i"
|
||||||
+ " INNER JOIN C_InvoiceLine l ON (i.C_Invoice_ID=l.C_Invoice_ID)"
|
+ " INNER JOIN C_InvoiceLine l ON (i.C_Invoice_ID=l.C_Invoice_ID)"
|
||||||
+ " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)"
|
+ " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)"
|
||||||
|
@ -213,7 +214,8 @@ public class InvoiceHistory extends CDialog
|
||||||
{
|
{
|
||||||
String sql = "SELECT bp.Name,l.PriceActual,l.PriceList,l.QtyInvoiced," // 1,2,3,4
|
String sql = "SELECT bp.Name,l.PriceActual,l.PriceList,l.QtyInvoiced," // 1,2,3,4
|
||||||
+ "i.DateInvoiced,dt.PrintName || ' ' || i.DocumentNo As DocumentNo," // 5,6
|
+ "i.DateInvoiced,dt.PrintName || ' ' || i.DocumentNo As DocumentNo," // 5,6
|
||||||
+ "o.Name "
|
+ "o.Name," // 7
|
||||||
|
+ "NULL, i.M_PriceList_ID" // 8,9
|
||||||
+ " FROM C_Invoice i"
|
+ " FROM C_Invoice i"
|
||||||
+ " INNER JOIN C_InvoiceLine l ON (i.C_Invoice_ID=l.C_Invoice_ID)"
|
+ " INNER JOIN C_InvoiceLine l ON (i.C_Invoice_ID=l.C_Invoice_ID)"
|
||||||
+ " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)"
|
+ " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)"
|
||||||
|
@ -250,14 +252,18 @@ public class InvoiceHistory extends CDialog
|
||||||
line.add(rs.getString(1)); // Name
|
line.add(rs.getString(1)); // Name
|
||||||
line.add(rs.getBigDecimal(2)); // Price
|
line.add(rs.getBigDecimal(2)); // Price
|
||||||
line.add(new Double(rs.getDouble(4))); // Qty
|
line.add(new Double(rs.getDouble(4))); // Qty
|
||||||
BigDecimal discountBD = Env.ZERO;
|
BigDecimal discountBD = rs.getBigDecimal(8);
|
||||||
try // discoint can be indefinate
|
if (discountBD == null) {
|
||||||
{
|
double priceList = rs.getDouble(3);
|
||||||
double discountD = (rs.getDouble(3)-rs.getDouble(2)) / rs.getDouble(3) * 100;
|
double priceActual = rs.getDouble(2);
|
||||||
discountBD = new BigDecimal(discountD);
|
if (priceList != 0) {
|
||||||
|
discountBD = new BigDecimal((priceList - priceActual)/priceList * 100);
|
||||||
|
// Rounding:
|
||||||
|
int precision = MPriceList.getStandardPrecision(Env.getCtx(), rs.getInt(9));
|
||||||
|
if (discountBD.scale() > precision)
|
||||||
|
discountBD = discountBD.setScale(precision, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
else
|
||||||
{
|
|
||||||
discountBD = Env.ZERO;
|
discountBD = Env.ZERO;
|
||||||
}
|
}
|
||||||
line.add(discountBD); // Discount
|
line.add(discountBD); // Discount
|
||||||
|
@ -346,7 +352,8 @@ public class InvoiceHistory extends CDialog
|
||||||
{
|
{
|
||||||
String sql = "SELECT bp.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved,"
|
String sql = "SELECT bp.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved,"
|
||||||
+ "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, "
|
+ "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, "
|
||||||
+ "w.Name "
|
+ "w.Name,"
|
||||||
|
+ "ol.Discount, 0 " // 8,9=M_PriceList_ID
|
||||||
+ "FROM C_Order o"
|
+ "FROM C_Order o"
|
||||||
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)"
|
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)"
|
||||||
+ " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)"
|
+ " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)"
|
||||||
|
@ -362,7 +369,8 @@ public class InvoiceHistory extends CDialog
|
||||||
{
|
{
|
||||||
String sql = "SELECT p.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved,"
|
String sql = "SELECT p.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved,"
|
||||||
+ "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, "
|
+ "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, "
|
||||||
+ "w.Name "
|
+ "w.Name,"
|
||||||
|
+ "ol.Discount, 0 " // 8,9=M_PriceList_ID
|
||||||
+ "FROM C_Order o"
|
+ "FROM C_Order o"
|
||||||
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)"
|
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)"
|
||||||
+ " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)"
|
+ " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)"
|
||||||
|
|
Loading…
Reference in New Issue