From cd2facf1b6723190d00236c4f12628e4b16d17be Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Thu, 8 Nov 2007 22:47:52 +0000 Subject: [PATCH] fixed [ 1828629 ] Posterita pnly support dd-MMM-yyyy format date http://sourceforge.net/tracker/index.php?func=detail&aid=1828629&group_id=176962&atid=928568 --- .../org/posterita/beans/ReportImageBean.java | 9 +- .../posterita/businesslogic/CashManager.java | 21 +- .../businesslogic/CustomPOSReportManager.java | 6 +- .../businesslogic/CustomerManager.java | 19 +- .../posterita/businesslogic/POSManager.java | 19 +- .../businesslogic/POSProductManager.java | 51 ++-- .../businesslogic/POSReportManager.java | 81 +++--- .../SalesAnalysisReportManager.java | 236 +++++++++++------- .../core/PDFReportPageEventHelper.java | 5 +- .../org/posterita/core/TimeSeriesChart.java | 4 +- .../struts/pos/CustomPOSReportAction.java | 21 +- .../pos/FastMovingItemReportAction.java | 7 +- .../posterita/struts/pos/POSInfoAction.java | 18 +- .../posterita/struts/pos/POSReportAction.java | 4 +- .../struts/pos/POSSalesReportAction.java | 16 +- .../struts/pos/SalesAnalysisReportAction.java | 7 +- .../pos/SlowMovingItemReportAction.java | 7 +- .../struts/pos/StockMovementReportAction.java | 19 +- 18 files changed, 354 insertions(+), 196 deletions(-) diff --git a/posterita/src/main/org/posterita/beans/ReportImageBean.java b/posterita/src/main/org/posterita/beans/ReportImageBean.java index 197d9da23f..e17f187be2 100644 --- a/posterita/src/main/org/posterita/beans/ReportImageBean.java +++ b/posterita/src/main/org/posterita/beans/ReportImageBean.java @@ -27,6 +27,9 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; +import org.compiere.model.*; +import org.compiere.util.DisplayType; + public class ReportImageBean { @@ -45,7 +48,8 @@ public class ReportImageBean private void initDateFrom() { - SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat df = DisplayType.getDateFormat(DisplayType.Date); Calendar calendar = GregorianCalendar.getInstance(); @@ -66,7 +70,8 @@ public class ReportImageBean private void initDateTo() { - SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat df = DisplayType.getDateFormat(DisplayType.Date); Calendar calendar = GregorianCalendar.getInstance(); //int maxNoOfDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); diff --git a/posterita/src/main/org/posterita/businesslogic/CashManager.java b/posterita/src/main/org/posterita/businesslogic/CashManager.java index 953c3b85fd..114d1acd66 100644 --- a/posterita/src/main/org/posterita/businesslogic/CashManager.java +++ b/posterita/src/main/org/posterita/businesslogic/CashManager.java @@ -244,16 +244,19 @@ public class CashManager String sql1 ="select c_cash_id from C_CASH where C_CASHBOOK_ID="+cashBookId+ - " and created between to_date('"+ fromDate+"','DD-MM-YYYY HH24:MI:SS') " + - " and to_date('" + toDate+"','DD-MON-YYYY HH24:MI:SS') " ; + //" and created between to_date('"+ fromDate+"','DD-MM-YYYY HH24:MI:SS') " + + //" and to_date('" + toDate+"','DD-MON-YYYY HH24:MI:SS') " ; + " and created between "+ fromDate + " and " + toDate ; String sql="select nvl(sum(AMOUNT),0)" + " from C_CASHLINE" + " where C_CASH_ID in (" +sql1+")"+ " and AD_CLIENT_ID= " +Env.getAD_Client_ID(ctx)+ " and CASHTYPE='I'"+ - " and created between to_date('"+ fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - " and to_date('" + toDate+"','DD-MON-YYYY HH24:MI:SS') " ; + //" and created between to_date('"+ fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" and to_date('" + toDate+"','DD-MON-YYYY HH24:MI:SS') " ; + "and created between " + toDate + " and " + fromDate ; + CashBookDetailBean bean; @@ -776,8 +779,9 @@ public class CashManager String sql = "select ca.CashType, sum(ca.Amount)" + " from C_CASHLINE ca where ca.AD_Client_ID=" + adClientId + " and ca.AD_Org_ID in (" + userOrg + ")" - + " and ca.Created between to_date('" + fromDate + "','DD-MM-YYYY HH24:MI:SS')" - + " and to_date('" + toDate + "','DD-MM-YYYY HH24:MI:SS') " + //+ " and ca.Created between to_date('" + fromDate + "','DD-MM-YYYY HH24:MI:SS')" + //+ " and to_date('" + toDate + "','DD-MM-YYYY HH24:MI:SS') " + + " and ca.Created between "+ fromDate + " and "+ toDate + " group by ca.cashtype"; return getCashSummary(ctx, sql, trxName); @@ -846,8 +850,9 @@ public class CashManager + " and rl.AD_Reference_ID = " + MCashLine.CASHTYPE_AD_Reference_ID + " and cl.CashType = rl.Value" + " and cu.C_Currency_ID = cl.C_Currency_ID" - + " and cl.Created between to_date('"+ fromDate+"','DD-MM-YYYY HH24:MI:SS') " - + " and to_date('" + todate+"','DD-MM-YYYY HH24:MI:SS') " + //+ " and cl.Created between to_date('"+ fromDate+"','DD-MM-YYYY HH24:MI:SS') " + //+ " and to_date('" + todate+"','DD-MM-YYYY HH24:MI:SS') " + + " and cl.Created between "+fromDate + " and " + todate + " order by cl.created"; return getCashLineHistory(ctx, sql, trxName); diff --git a/posterita/src/main/org/posterita/businesslogic/CustomPOSReportManager.java b/posterita/src/main/org/posterita/businesslogic/CustomPOSReportManager.java index 71adebf6b9..064f80359f 100644 --- a/posterita/src/main/org/posterita/businesslogic/CustomPOSReportManager.java +++ b/posterita/src/main/org/posterita/businesslogic/CustomPOSReportManager.java @@ -202,6 +202,7 @@ public class CustomPOSReportManager "Cause:Invalid date format, the date returned should have the following format 'DD-MM-YYYY'"); SimpleDateFormat sdf = new SimpleDateFormat(); + //SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); Calendar cal = Calendar.getInstance(); Date d = null; @@ -263,9 +264,10 @@ public class CustomPOSReportManager XYPlot plot = (XYPlot) timeSeriesChart.getChart().getPlot(); DateAxis axis = (DateAxis) plot.getDomainAxis(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); Date d1 = null; - Date d2 = null;; + Date d2 = null; try { d1 = sdf.parse(fromDate); diff --git a/posterita/src/main/org/posterita/businesslogic/CustomerManager.java b/posterita/src/main/org/posterita/businesslogic/CustomerManager.java index c6badc40bf..fdc99daaf2 100644 --- a/posterita/src/main/org/posterita/businesslogic/CustomerManager.java +++ b/posterita/src/main/org/posterita/businesslogic/CustomerManager.java @@ -52,6 +52,7 @@ import org.compiere.model.MRegion; import org.compiere.model.MUser; import org.compiere.model.X_I_BPartner; import org.compiere.util.DB; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.posterita.beans.CustomerBean; import org.posterita.core.RandomStringGenerator; @@ -440,7 +441,7 @@ public class CustomerManager return list; } - + public static CustomerBean getCustomerDetails(Properties ctx, int bpartnerId) throws OperationException,BPartnerNotFoundException, InvalidDateTimeException, Exception { @@ -509,8 +510,10 @@ public class CustomerManager if ((date != null)) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); - SimpleDateFormat sdfOutput = new SimpleDateFormat ("dd/MM/yyyy"); + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + //SimpleDateFormat sdfOutput = new SimpleDateFormat ("dd/MM/yyyy"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.DateTime); + SimpleDateFormat sdfOutput = DisplayType.getDateFormat(DisplayType.Date); String textDate = date.toString(); Date date2 = sdf.parse (textDate); @@ -770,8 +773,8 @@ public class CustomerManager sql.append(" order by bp.name"); - PreparedStatement pstmt = DB.prepareStatement(sql.toString(),null); - pstmt.execute(sql.toString()); + String select = sql.toString(); + PreparedStatement pstmt = DB.prepareStatement(select,null); ResultSet rs = null; @@ -807,8 +810,10 @@ public class CustomerManager if (rs.getString(10) != null) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat sdfOutput = new SimpleDateFormat ("dd-MMM-yyyy"); + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //SimpleDateFormat sdfOutput = new SimpleDateFormat ("dd-MMM-yyyy"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.DateTime); + SimpleDateFormat sdfOutput = DisplayType.getDateFormat(DisplayType.Date); String textDate = rs.getString(10); Date date2 = sdf.parse (textDate); diff --git a/posterita/src/main/org/posterita/businesslogic/POSManager.java b/posterita/src/main/org/posterita/businesslogic/POSManager.java index c772fc37a1..b40b344bca 100644 --- a/posterita/src/main/org/posterita/businesslogic/POSManager.java +++ b/posterita/src/main/org/posterita/businesslogic/POSManager.java @@ -1047,15 +1047,17 @@ public class POSManager int posId=Env.getContextAsInt(ctx,UdiConstants.POS_ID); BigDecimal grandTotal =null; - long date = toDate.getTime(); + //long date = toDate.getTime(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String sqlDate = sdf.format(new Date(date)); + //String sqlDate = sdf.format(new Date(date)); \ + String sqlDate = DB.TO_DATE(toDate); String sql="select sum(pay.payAmt) " + " from C_order ord,c_payment pay right outer join C_invoice inv on inv.c_Invoice_id=pay.c_Invoice_id" + - " where pay.created>=TO_DATE('" +sqlDate+"','YYYY-MM-DD HH24:MI:SS')"+ + //" where pay.created>=TO_DATE('" +sqlDate+"','YYYY-MM-DD HH24:MI:SS')"+ + " where pay.created>="+sqlDate+ " and inv.c_order_id=ord.c_order_id"+ " and ord.POSID="+posId+ " and ord.AD_CLIENT_ID="+Env.getAD_Client_ID(ctx)+ @@ -1229,11 +1231,11 @@ public class POSManager bean=CashManager.getData(ctx,pos.getC_CashBook_ID(),false,null); if (bean==null) { - Timestamp time = new Timestamp(System.currentTimeMillis()); + /*Timestamp time = new Timestamp(System.currentTimeMillis()); Date adate= new Date(time.getTime()); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String newDate=sdf.format(adate); - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); + //SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); Date date; Timestamp timestamp = null; try @@ -1245,7 +1247,8 @@ public class POSManager { throw new OperationException(e); } - return timestamp; + return timestamp;*/ + return new Timestamp(System.currentTimeMillis()); } MCash cash = new MCash(ctx,bean.getCashJournalId().intValue(),null); diff --git a/posterita/src/main/org/posterita/businesslogic/POSProductManager.java b/posterita/src/main/org/posterita/businesslogic/POSProductManager.java index 33dd50c19c..ce0ec92376 100644 --- a/posterita/src/main/org/posterita/businesslogic/POSProductManager.java +++ b/posterita/src/main/org/posterita/businesslogic/POSProductManager.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.Timestamp; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -965,9 +966,12 @@ public class POSProductManager extends ProductManager Date startDate = ReportDateManager.getStartDateForPeriod(period); Date endDate = ReportDateManager.getEndDateForPeriod(period); - SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); - String fromDate = f.format(startDate); - String toDate = f.format(endDate); + //SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //String fromDate = f.format(startDate); + //String toDate = f.format(endDate); + //SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + String fromDate = DB.TO_DATE(new Timestamp(startDate.getTime())); + String toDate = DB.TO_DATE(new Timestamp(endDate.getTime())); String sql = "select " + "(qtyordered - qtyreturned) as NetQtySold," + //1.net qty sold @@ -982,8 +986,9 @@ public class POSProductManager extends ProductManager " and bp.ISCUSTOMER = 'Y' " + " and ORDERTYPE in ('POS Order','Credit Order') " + " and ord.DATEORDERED between " + - " to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------2.startDate - " and to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------3.endDate + //" to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------2.startDate + //" and to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------3.endDate + fromDate + " and "+ toDate + ") QTYORDERED, " + "( select nvl(sum(ordline.QTYORDERED),0) as qtyreturned, nvl(sum(ordline.LINENETAMT),0) as returnAmt " + @@ -994,8 +999,9 @@ public class POSProductManager extends ProductManager " and bp.ISCUSTOMER = 'Y' " + " and ORDERTYPE = 'Customer Return Order' " + " and ord.DATEORDERED between " + - " to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------5.startDate - " and to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------6.endDate + //" to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------5.startDate + //" and to_date( ? , 'DD-MM-YYYY HH24:MI:SS' )" + //<----------6.endDate + fromDate + " AND " + toDate + ") QtyReturned " ; PreparedStatement pstmt = null; @@ -1314,8 +1320,6 @@ public class POSProductManager extends ProductManager */ public static ProductBean getProduct(Properties ctx, String barcode, String trxName) throws OperationException { - String msg = null; - if((barcode == null) || (barcode.length() == 0)) { throw new InvalidBarcodeException("Invalid Barcode! Barcode is either empty or null."); @@ -1329,23 +1333,20 @@ public class POSProductManager extends ProductManager if((ids == null) || (ids.length == 0)) { //throw new ProductNotFoundException("Found no product with barcode: " + barcode); - msg = "Found no product with barcode: " + barcode; + String msg = "Found no product with barcode: " + barcode; + + whereClause = "Value = '" + barcode + "' " + + "and AD_CLIENT_ID = " + Env.getAD_Client_ID(ctx); + + ids = MProduct.getAllIDs(MProduct.Table_Name, whereClause, trxName); + + if((ids == null) || (ids.length == 0)) + { + msg = msg + " , Found no product with search key: " + barcode; + throw new ProductNotFoundException(msg); + } } - - whereClause = "Value = '" + barcode + "' " + - "and AD_CLIENT_ID = " + Env.getAD_Client_ID(ctx); - - if((ids == null) || (ids.length == 0)) - { - msg = msg + " , Found no product with search key: " + barcode; - } - - if(msg != null) - { - throw new ProductNotFoundException(msg); - } - - + int productId = ids[0]; ProductBean productDetails = viewPOSProduct(ctx, productId); diff --git a/posterita/src/main/org/posterita/businesslogic/POSReportManager.java b/posterita/src/main/org/posterita/businesslogic/POSReportManager.java index e1da3d513e..569cb37c74 100644 --- a/posterita/src/main/org/posterita/businesslogic/POSReportManager.java +++ b/posterita/src/main/org/posterita/businesslogic/POSReportManager.java @@ -53,6 +53,7 @@ import org.compiere.model.MWarehouse; import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; +import org.compiere.util.TimeUtil; import org.compiere.utils.DBUtils; import org.posterita.Constants; import org.posterita.beans.BPartnerBean; @@ -83,6 +84,7 @@ import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; + public class POSReportManager { private static final String ASCENDING_SORT = "asc"; @@ -105,12 +107,14 @@ public class POSReportManager { + " and ol.AD_CLIENT_ID=" + Env.getAD_Client_ID(ctx) + " and ord.ISACTIVE='Y'" - + " and ol.CREATED between to_date('" + //+ " and ol.CREATED between to_date('" + + " and ol.CREATED between " + fromDate - + "','DD-Mon-YYYY HH24:MI:SS') " - + " and to_date('" + //+ "','DD-Mon-YYYY HH24:MI:SS') " + + " and " + //+ " and to_date('" + todate - + "','DD-Mon-YYYY HH24:MI:SS') " + //+ "','DD-Mon-YYYY HH24:MI:SS') " + " and ord.ORDERTYPE='" + UDIOrderTypes.POS_ORDER.getOrderType() + "'" @@ -199,9 +203,10 @@ public class POSReportManager { + " and ord.AD_CLIENT_ID=" + Env.getAD_Client_ID(ctx) + " and ol.M_PRODUCT_ID=" + productId + " and ord.orderType='" + UDIOrderTypes.CUSTOMER_RETURN_ORDER.getOrderType() + "'" - + " and ol.CREATED between to_date('" + fromDate - + "','DD-MM-YYYY HH24:MI:SS') " + " and to_date('" + todate - + "','DD-MM-YYYY HH24:MI:SS') "; + //+ " and ol.CREATED between to_date('" + fromDate + //+ "','DD-MM-YYYY HH24:MI:SS') " + " and to_date('" + todate + + " and ol.CREATED between "+ fromDate + " and "+ todate; + //+ "','DD-MM-YYYY HH24:MI:SS') "; PreparedStatement pstmt = DB.prepareStatement(sql, null); @@ -229,13 +234,14 @@ public class POSReportManager { public static ArrayList getStockMovementReport( Properties ctx, String fromDate, String todate) throws OperationException { - String sql = "select distinct v.m_product_id," + " pr.name" + " from M_TRANSACTION_V v,m_product pr" + " where v.m_product_id=pr.m_product_id" - + " and v.CREATED between to_date('" + fromDate - + "','DD-MON-YYYY HH24:MI:SS') " + " and to_date('" + todate - + "','DD-MON-YYYY HH24:MI:SS') " + " and v.AD_CLIENT_ID=" + //+ " and v.CREATED between to_date('" + fromDate + //+ "','DD-MON-YYYY HH24:MI:SS') " + " and to_date('" + todate + //+ "','DD-MON-YYYY HH24:MI:SS') " + " and v.AD_CLIENT_ID=" + + " and v.CREATED between " + fromDate +" AND "+todate + + " and v.AD_CLIENT_ID=" + Env.getAD_Client_ID(ctx) + " and v.AD_ORG_ID=" + Env.getAD_Org_ID(ctx) + " order by pr.name"; @@ -255,8 +261,12 @@ public class POSReportManager { PreparedStatement pstmt = DB.prepareStatement(sql, null); + ResultSet rs; try { + //pstmt.setTimestamp(1, Timestamp.valueOf(fromDate)); + //pstmt.setTimestamp(2, Timestamp.valueOf(todate)); + rs = pstmt.executeQuery(); while (rs.next()) { int qtyOfSales; @@ -394,9 +404,10 @@ public class POSReportManager { + " from c_orderLine ol,C_ORDER ord" + " where ol.C_ORDER_ID=ord.C_ORDER_ID and " + whereClause + " and M_PRODUCT_ID=" + productId - + " and ol.CREATED between to_date('" + fromDate - + "','DD-MON-YYYY HH24:MI:SS') " + " and to_date('" + toDate - + "','DD-MON-YYYY HH24:MI:SS') " + " and ord.ORDERTYPE='" + //+ " and ol.CREATED between to_date('" + fromDate + //+ "','DD-MON-YYYY HH24:MI:SS') " + " and to_date('" + toDate + //+ "','DD-MON-YYYY HH24:MI:SS') " + " and ord.ORDERTYPE='" + + "and ol.CREATED between "+ fromDate + "and "+ toDate + " and ord.ORDERTYPE='" + orderType + "'" + " and ord.DOCSTATUS in ('CO','CL')" + " and ord.M_WAREHOUSE_ID=" + warehouse.get_ID() + " and ord.ISACTIVE='Y'"; @@ -408,7 +419,8 @@ public class POSReportManager { + warehouse.getDefaultLocator().get_ID() + " and AD_CLIENT_ID=" + Env.getAD_Client_ID(ctx) + " and AD_ORG_ID=" + Env.getAD_Org_ID(ctx) - + " and createdto_date('" + fromDate - + "','DD-MON-YYYY HH24:MI:SS')" + " and MOVEMENTTYPE='" + //+ " and created>to_date('" + fromDate + //+ "','DD-MON-YYYY HH24:MI:SS')" + " and MOVEMENTTYPE='" + + " and created>"+fromDate + "and " + " and MOVEMENTTYPE='" + MTransaction.MOVEMENTTYPE_InventoryIn + "'"; else if (queryType.equalsIgnoreCase("inventoryOut")) @@ -428,8 +441,9 @@ public class POSReportManager { + warehouse.getDefaultLocator().get_ID() + " and AD_CLIENT_ID=" + Env.getAD_Client_ID(ctx) + " and AD_ORG_ID=" + Env.getAD_Org_ID(ctx) - + " and created>to_date('" + fromDate - + "','DD-MON-YYYY HH24:MI:SS')" + " and MOVEMENTTYPE='" + //+ " and created>to_date('" + fromDate + //+ "','DD-MON-YYYY HH24:MI:SS')" + " and MOVEMENTTYPE='" + + " and created>"+fromDate + "and " + " and MOVEMENTTYPE='" + MTransaction.MOVEMENTTYPE_InventoryOut + "'"; else if (queryType.equalsIgnoreCase("closing")) @@ -439,7 +453,8 @@ public class POSReportManager { + warehouse.getDefaultLocator().get_ID() + " and AD_CLIENT_ID=" + Env.getAD_Client_ID(ctx) + " and AD_ORG_ID=" + Env.getAD_Org_ID(ctx) - + " and created 0 " + " GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),BP.NAME" + @@ -405,9 +423,11 @@ public class SalesAnalysisReportManager " and attrSetIns.M_ATTRIBUTESET_ID = " + attributeSetId + " and attr.M_ATTRIBUTE_ID = " + attributeId + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS')" + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS')" + + fromDate + " and" + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS')" + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS')" + + toDate + ")" + "group by ATTRIBUTE_VALUE,to_char(DATEACCT,'DD-MON-YYYY') " + "order by to_char(DATEACCT,'DD-MON-YYYY') desc,ATTRIBUTE_VALUE asc"; @@ -483,10 +503,12 @@ public class SalesAnalysisReportManager "and fact.M_PRODUCT_ID = prod.M_PRODUCT_ID " + //"and rev.C_REVENUERECOGNITION_ID(+) = prod.C_REVENUERECOGNITION_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate + + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ + " and fact.AD_CLIENT_ID = "+ad_client_id + " group by rev.NAME"; } else if(salesGroup.equalsIgnoreCase(Constants.ATTRIBUTESET)) @@ -500,10 +522,12 @@ public class SalesAnalysisReportManager "and prod.M_ATTRIBUTESETINSTANCE_ID = attrSetIns.M_ATTRIBUTESETINSTANCE_ID " + "and attrSet.M_ATTRIBUTESET_ID = attrSetIns.M_ATTRIBUTESET_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ + " and fact.AD_CLIENT_ID = "+ad_client_id + " group by attrSet.name"; } else if(salesGroup.equalsIgnoreCase(Constants.PRODUCT)) @@ -514,10 +538,12 @@ public class SalesAnalysisReportManager "(select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + "AND FACT.M_PRODUCT_ID = PROD.M_PRODUCT_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate + + " and fact.AD_CLIENT_ID = "+ad_client_id + " GROUP BY PROD.NAME"; } else if(salesGroup.equalsIgnoreCase(Constants.GROUP1)) @@ -529,10 +555,12 @@ public class SalesAnalysisReportManager "(select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + "AND FACT.M_PRODUCT_ID = PROD.M_PRODUCT_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ + " and fact.AD_CLIENT_ID = "+ad_client_id + " GROUP BY PROD.GROUP1"; } else if(salesGroup.equalsIgnoreCase(Constants.GROUP2)) @@ -544,10 +572,12 @@ public class SalesAnalysisReportManager "(select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + "AND FACT.M_PRODUCT_ID = PROD.M_PRODUCT_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ + " and fact.AD_CLIENT_ID = "+ad_client_id + " GROUP BY PROD.GROUP2"; } else if(salesGroup.equalsIgnoreCase(Constants.CUSTOMER)) @@ -560,10 +590,12 @@ public class SalesAnalysisReportManager "(select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + "AND FACT.C_BPARTNER_ID = BP.C_BPARTNER_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ + " and fact.AD_CLIENT_ID = "+ad_client_id + //" having SUM(0 - FACT.QTY) <> 0 " + "GROUP BY BP.NAME Order by BP.NAME asc"; //"GROUP BY BP.NAME || ' ' || BP.NAME2 Order by BP.NAME || ' ' || BP.NAME2 asc"; @@ -598,9 +630,11 @@ public class SalesAnalysisReportManager " and attrSetIns.M_ATTRIBUTESET_ID = " + attributeSetId + " and attr.M_ATTRIBUTE_ID = " + attributeId + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ " and " + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ ")" + "group by ATTRIBUTE_VALUE"; @@ -631,7 +665,8 @@ public class SalesAnalysisReportManager sql = "" + //"select DECODE(rev.NAME, null, 'others', rev.Name) RevenueRecognition," + //1.Revenue Recognition "select CASE WHEN rev.NAME = null THEN 'others' ELSE rev.Name END AS RevenueRecognition," + //1.Revenue Recognition - "to_char(fact.DATEACCT,'DD-MON-YYYY')," + //2.Date + //"to_char(fact.DATEACCT,'DD-MON-YYYY')," + //2.Date + "fact.DATEACCT,"+ "SUM(fact.AMTACCTCR-fact.AMTACCTDR) as REVENUE," + //3.Value "SUM(0-fact.QTY) " + //4.Qty "from FACT_ACCT fact, (M_PRODUCT prod left outer join C_REVENUERECOGNITION rev on rev.C_REVENUERECOGNITION_ID = prod.C_REVENUERECOGNITION_ID ) " + @@ -640,15 +675,19 @@ public class SalesAnalysisReportManager "and fact.M_PRODUCT_ID = prod.M_PRODUCT_ID " + //"and rev.C_REVENUERECOGNITION_ID(+) = prod.C_REVENUERECOGNITION_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + - " group by rev.NAME,to_char(fact.DATEACCT,'DD-MON-YYYY')"; + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ + " and fact.AD_CLIENT_ID = "+ad_client_id + + //" group by rev.NAME,to_char(fact.DATEACCT,'DD-MON-YYYY')"; + " group by rev.NAME,fact.DATEACCT"; } else if(salesGroup.equalsIgnoreCase(Constants.ATTRIBUTESET)) { - sql = "select attrSet.name as attributeset,to_char(fact.DATEACCT,'DD-MON-YYYY'),SUM(fact.AMTACCTCR-fact.AMTACCTDR) as REVENUE,SUM(0-fact.QTY) " + + //sql = "select attrSet.name as attributeset,to_char(fact.DATEACCT,'DD-MON-YYYY'),SUM(fact.AMTACCTCR-fact.AMTACCTDR) as REVENUE,SUM(0-fact.QTY) " + + sql = "select attrSet.name as attributeset,fact.DATEACCT,SUM(fact.AMTACCTCR-fact.AMTACCTDR) as REVENUE,SUM(0-fact.QTY) " + "from FACT_ACCT fact, (M_PRODUCT prod left outer join C_REVENUERECOGNITION rev on rev.C_REVENUERECOGNITION_ID = prod.C_REVENUERECOGNITION_ID ),M_ATTRIBUTESETINSTANCE attrSetIns, M_ATTRIBUTESET attrSet " + "where fact.ACCOUNT_ID = " + "(select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + @@ -657,17 +696,21 @@ public class SalesAnalysisReportManager "and prod.M_ATTRIBUTESETINSTANCE_ID = attrSetIns.M_ATTRIBUTESETINSTANCE_ID " + "and attrSet.M_ATTRIBUTESET_ID = attrSetIns.M_ATTRIBUTESET_ID " + "and fact.DATEACCT between " + - "to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and " + - "to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + - "and fact.AD_CLIENT_ID = "+ad_client_id + - " group by attrSet.name,to_char(fact.DATEACCT,'DD-MON-YYYY')"; + //"to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ + " and " + + //"to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ + " and fact.AD_CLIENT_ID = "+ad_client_id + + //" group by attrSet.name,to_char(fact.DATEACCT,'DD-MON-YYYY')"; + " group by attrSet.name,fact.DATEACCT"; } else if(salesGroup.equalsIgnoreCase(Constants.PRODUCT)) { sql = "" + " select PROD.NAME as \"Product\"," + //1.Product - " to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + //" to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + " fact.DATEACCT as \"Date\"," + //2.Date " SUM(FACT.AMTACCTCR - FACT.AMTACCTDR) as \"Value\"," + //3.Value " SUM(0 - FACT.QTY) as \"Qty\" " + //4.Qty " from FACT_ACCT FACT, M_PRODUCT PROD " + @@ -675,17 +718,21 @@ public class SalesAnalysisReportManager " (select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + " AND FACT.M_PRODUCT_ID = PROD.M_PRODUCT_ID " + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ " and " + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ " and fact.AD_CLIENT_ID = "+ad_client_id + - " GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.NAME"; + //" GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.NAME"; + " GROUP BY fact.DATEACCT,PROD.NAME"; } else if(salesGroup.equalsIgnoreCase(Constants.PRODUCT)) { sql = "" + " select PROD.NAME as \"Product\"," + //1.Product - " to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + //" to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + " fact.DATEACCT as \"Date\"," + " SUM(FACT.AMTACCTCR - FACT.AMTACCTDR) as \"Value\"," + //3.Value " SUM(0 - FACT.QTY) \"Qty\" " + //4.Qty " from FACT_ACCT FACT, M_PRODUCT PROD " + @@ -693,17 +740,21 @@ public class SalesAnalysisReportManager " (select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + " AND FACT.M_PRODUCT_ID = PROD.M_PRODUCT_ID " + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ " and " + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ " and fact.AD_CLIENT_ID = "+ad_client_id + - " GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.NAME"; + //" GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.NAME"; + " GROUP BY fact.DATEACCT,PROD.NAME"; } else if(salesGroup.equalsIgnoreCase(Constants.GROUP1)) { sql = "" + " select PROD.GROUP1 as \"Group1\"," + //1.Product - " to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + //" to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + " fact.DATEACCT as \"Date\"," + //2.Date " SUM(FACT.AMTACCTCR - FACT.AMTACCTDR) as \"Value\"," + //3.Value " SUM(0 - FACT.QTY) as \"Qty\" " + //4.Qty " from FACT_ACCT FACT, M_PRODUCT PROD " + @@ -711,17 +762,21 @@ public class SalesAnalysisReportManager " (select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + " AND FACT.M_PRODUCT_ID = PROD.M_PRODUCT_ID " + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ " and " + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ " and fact.AD_CLIENT_ID = "+ad_client_id + - " GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.GROUP1"; + //" GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.GROUP1"; + " GROUP BY fact.DATEACCT,PROD.GROUP1"; } else if(salesGroup.equalsIgnoreCase(Constants.GROUP2)) { sql = "" + " select PROD.GROUP2 as \"Group2\"," + //1.Product - " to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + //" to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + " DATEACCT as \"Date\"," + " SUM(FACT.AMTACCTCR - FACT.AMTACCTDR) as \"Value\"," + //3.Value " SUM(0 - FACT.QTY) as \"Qty\" " + //4.Qty " from FACT_ACCT FACT, M_PRODUCT PROD " + @@ -729,18 +784,22 @@ public class SalesAnalysisReportManager " (select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + " AND FACT.M_PRODUCT_ID = PROD.M_PRODUCT_ID " + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ " and " + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ " and fact.AD_CLIENT_ID = "+ad_client_id + - " GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.GROUP2"; + //" GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),PROD.GROUP2"; + " GROUP BY fact.DATEACCT,PROD.GROUP2"; } else if(salesGroup.equalsIgnoreCase(Constants.CUSTOMER)) { sql = "" + //" select BP.NAME||' '||BP.NAME2 as \"Customer\"," + //1.Customer "Select BP.NAME as \"Customer\","+ - " to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + //" to_char(fact.DATEACCT,'DD-MON-YYYY') as \"Date\"," + //2.Date + " fact.DATEACCT as \"Date\"," + //2.Date " SUM(FACT.AMTACCTCR - FACT.AMTACCTDR) as \"Value\"," + //3.Value " SUM(0 - FACT.QTY) as \"Qty\" " + //4.Qty " from FACT_ACCT FACT, C_BPARTNER BP " + @@ -748,12 +807,15 @@ public class SalesAnalysisReportManager " (select C_ELEMENTVALUE_ID from C_ELEMENTVALUE where value = '"+account_id+"' and AD_CLIENT_ID = "+ad_client_id +") " + " AND FACT.C_BPARTNER_ID = BP.C_BPARTNER_ID " + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS') " + + fromDate+ " and " + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS') " + + toDate+ " and fact.AD_CLIENT_ID = "+ad_client_id + //" having SUM(0 - FACT.QTY) <> 0 " + - " GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),BP.NAME"; + //" GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),BP.NAME"; + " GROUP BY fact.DATEACCT,BP.NAME"; //" GROUP BY to_char(fact.DATEACCT,'DD-MON-YYYY'),BP.NAME||' '||BP.NAME2"; } @@ -769,7 +831,8 @@ public class SalesAnalysisReportManager int attributeSetId = Integer.parseInt(s[0]); int attributeId = Integer.parseInt(s[1]); - sql = "select ATTRIBUTE_VALUE,to_char(DATEACCT,'DD-MON-YYYY'),sum(AMTACCTCR-AMTACCTDR),SUM(0-QTY) from " + + //sql = "select ATTRIBUTE_VALUE,to_char(DATEACCT,'DD-MON-YYYY'),sum(AMTACCTCR-AMTACCTDR),SUM(0-QTY) from " + + sql = "select ATTRIBUTE_VALUE,DATEACCT,sum(AMTACCTCR-AMTACCTDR),SUM(0-QTY) from " + "(" + " select attrIns.m_attribute_id,prod.m_product_category_id, attrIns.m_attributevalue_id,attr.name ATTRIBUTE_NAME,attrSet.name ATTRIBUTESET_NAME,attrSet.M_ATTRIBUTESET_ID,prod.m_product_id, attrVal.name ATTRIBUTE_VALUE, attrVal.description,fact.AMTACCTCR,fact.AMTACCTDR,fact.DATEACCT,fact.QTY" + " from M_PRODUCT prod,M_ATTRIBUTEINSTANCE attrIns ,M_attribute attr,M_attributeValue attrVal, M_ATTRIBUTESETINSTANCE attrSetIns, M_ATTRIBUTESET attrSet, FACT_ACCT fact" + @@ -785,11 +848,14 @@ public class SalesAnalysisReportManager " and attrSetIns.M_ATTRIBUTESET_ID = " + attributeSetId + " and attr.M_ATTRIBUTE_ID = " + attributeId + " and fact.DATEACCT between " + - " to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS')" + - " and" + - " to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS')" + + //" to_date('"+fromDate+"','DD-MON-YYYY HH24:MI:SS')" + + fromDate+ + " and " + + //" to_date('"+toDate+"','DD-MON-YYYY HH24:MI:SS')" + + toDate+ ")" + - "group by ATTRIBUTE_VALUE,to_char(DATEACCT,'DD-MON-YYYY')"; + //"group by ATTRIBUTE_VALUE,to_char(DATEACCT,'DD-MON-YYYY')"; + "group by ATTRIBUTE_VALUE,DATEACCT"; } return sql; diff --git a/posterita/src/main/org/posterita/core/PDFReportPageEventHelper.java b/posterita/src/main/org/posterita/core/PDFReportPageEventHelper.java index 393734875d..b0240bf8fd 100644 --- a/posterita/src/main/org/posterita/core/PDFReportPageEventHelper.java +++ b/posterita/src/main/org/posterita/core/PDFReportPageEventHelper.java @@ -24,6 +24,8 @@ package org.posterita.core; import java.text.SimpleDateFormat; import java.util.Calendar; +import org.compiere.util.DisplayType; + import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; @@ -49,7 +51,8 @@ public class PDFReportPageEventHelper extends PdfPageEventHelper public void onOpenDocument(PdfWriter writer, Document document) { - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); dateAndTime = sdf.format(Calendar.getInstance().getTime()); table = new PdfPTable(2); diff --git a/posterita/src/main/org/posterita/core/TimeSeriesChart.java b/posterita/src/main/org/posterita/core/TimeSeriesChart.java index 131252f760..ddf4d562a1 100644 --- a/posterita/src/main/org/posterita/core/TimeSeriesChart.java +++ b/posterita/src/main/org/posterita/core/TimeSeriesChart.java @@ -31,6 +31,7 @@ import java.util.Calendar; import java.util.Date; import org.compiere.util.DB; +import org.compiere.util.DisplayType; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.labels.StandardXYItemLabelGenerator; @@ -153,7 +154,8 @@ public class TimeSeriesChart extends AbstractChart throw new OperationException("Unable to generate timeseries. " + "Cause:Invalid date format, the date returned should have the following format 'DD-MM-YYYY'"); - SimpleDateFormat sdf = new SimpleDateFormat(); + //SimpleDateFormat sdf = new SimpleDateFormat(); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); Calendar cal = Calendar.getInstance(); Date d = null; diff --git a/posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java b/posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java index 6456c12779..51b51ca2dd 100644 --- a/posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java +++ b/posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java @@ -26,10 +26,14 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; +import java.sql.Timestamp; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.compiere.util.DB; +import org.compiere.util.DisplayType; + import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; @@ -144,16 +148,20 @@ public class CustomPOSReportAction extends POSDispatchAction Date startDate = ReportDateManager.getStartDateForPeriod(timePeriod); Date endDate = ReportDateManager.getEndDateForPeriod(timePeriod); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); - fromDate = sdf.format(startDate); - toDate = sdf.format(endDate); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //fromDate = sdf.format(startDate); + //toDate = sdf.format(endDate); + fromDate = DB.TO_DATE(new Timestamp(startDate.getTime())); + toDate = DB.TO_DATE(new Timestamp(endDate.getTime())); subtitle = "For " + timePeriod; } else if(dateRange.endsWith(Constants.CUSTOM_DATE_RANGE)) { - fromDate = ReportDateManager.getFromDate(bean); - toDate = ReportDateManager.getToDate(bean); + //fromDate = ReportDateManager.getFromDate(bean); + //toDate = ReportDateManager.getToDate(bean); + fromDate = bean.getFromDate(); + toDate = bean.getToDate(); subtitle = "For period:"+fromDate+" to "+toDate; } @@ -337,7 +345,8 @@ public class CustomPOSReportAction extends POSDispatchAction if(!error) { - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); fromDate = ReportDateManager.getFromDate(bean); toDate = ReportDateManager.getToDate(bean); diff --git a/posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java b/posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java index 0888763f9b..84d4504018 100644 --- a/posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java +++ b/posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java @@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.compiere.util.DisplayType; import org.posterita.Constants; import org.posterita.beans.ReportBean; @@ -56,7 +57,8 @@ public class FastMovingItemReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); @@ -83,7 +85,8 @@ public class FastMovingItemReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); diff --git a/posterita/src/main/org/posterita/struts/pos/POSInfoAction.java b/posterita/src/main/org/posterita/struts/pos/POSInfoAction.java index 56db3b6391..edcb75fb8a 100644 --- a/posterita/src/main/org/posterita/struts/pos/POSInfoAction.java +++ b/posterita/src/main/org/posterita/struts/pos/POSInfoAction.java @@ -27,10 +27,14 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.Properties; +import java.sql.Timestamp; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.compiere.util.DB; +import org.compiere.util.DisplayType; + import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; @@ -60,7 +64,8 @@ public class POSInfoAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); @@ -87,7 +92,8 @@ public class POSInfoAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); @@ -136,9 +142,11 @@ public class POSInfoAction extends POSDispatchAction Date startDate = ReportDateManager.getStartDateForPeriod(timePeriod); Date endDate = ReportDateManager.getEndDateForPeriod(timePeriod); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); - fromDate = sdf.format(startDate); - toDate = sdf.format(endDate); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //fromDate = sdf.format(startDate); + //toDate = sdf.format(endDate); + fromDate =DB.TO_DATE(new Timestamp(startDate.getTime())); + toDate = DB.TO_DATE(new Timestamp(endDate.getTime())); subtitle = "For " + timePeriod; } diff --git a/posterita/src/main/org/posterita/struts/pos/POSReportAction.java b/posterita/src/main/org/posterita/struts/pos/POSReportAction.java index 5d564083fa..1ed4a9d829 100644 --- a/posterita/src/main/org/posterita/struts/pos/POSReportAction.java +++ b/posterita/src/main/org/posterita/struts/pos/POSReportAction.java @@ -36,6 +36,7 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.compiere.util.DisplayType; import org.posterita.Constants; import org.posterita.beans.POSHistoryBean; @@ -230,7 +231,8 @@ public class POSReportAction extends BaseDispatchAction Date startDate = ReportDateManager.getStartDateForPeriod(timePeriod); Date endDate = ReportDateManager.getEndDateForPeriod(timePeriod); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); fromDate = sdf.format(startDate); toDate = sdf.format(endDate); diff --git a/posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java b/posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java index 3ee318cbcd..892371ac31 100644 --- a/posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java +++ b/posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java @@ -28,6 +28,10 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Properties; +import java.sql.Timestamp; + +import org.compiere.util.DB; +import org.compiere.util.DisplayType; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -144,7 +148,8 @@ public class POSSalesReportAction extends POSDispatchAction XYPlot plot = (XYPlot) timeSeriesChart.getChart().getPlot(); DateAxis axis = (DateAxis) plot.getDomainAxis(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); Date d1 = null; Date d2 = null;; try @@ -236,9 +241,12 @@ public class POSSalesReportAction extends POSDispatchAction Date startDate = ReportDateManager.getStartDateForPeriod(timeperiod); Date endDate = ReportDateManager.getEndDateForPeriod(timeperiod); - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - String fromDate = sdf.format(startDate); - String toDate = sdf.format(endDate); + //SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + //String fromDate = sdf.format(startDate); + //String toDate = sdf.format(endDate); + String fromDate = DB.TO_DATE( new Timestamp (startDate.getTime())); + String toDate = DB.TO_DATE( new Timestamp (endDate.getTime())); + reportForm.setFromDate(fromDate); reportForm.setToDate(toDate); diff --git a/posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java b/posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java index be70eaf31b..51abfd86a3 100644 --- a/posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java +++ b/posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java @@ -35,6 +35,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.compiere.util.DisplayType; import org.posterita.beans.ReportBean; import org.posterita.businesslogic.POSReportManager; import org.posterita.businesslogic.ReportDateManager; @@ -58,7 +59,8 @@ public class SalesAnalysisReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); @@ -85,7 +87,8 @@ public class SalesAnalysisReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); diff --git a/posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java b/posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java index 2122bd20c3..f0da957fd6 100644 --- a/posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java +++ b/posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java @@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.compiere.util.DisplayType; import org.posterita.Constants; import org.posterita.beans.ReportBean; import org.posterita.businesslogic.POSReportManager; @@ -55,7 +56,8 @@ public class SlowMovingItemReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); @@ -82,7 +84,8 @@ public class SlowMovingItemReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); diff --git a/posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java b/posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java index 8b4d197ac4..68efd84887 100644 --- a/posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java +++ b/posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java @@ -26,6 +26,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.sql.*; import java.util.Properties; import javax.servlet.http.HttpServletRequest; @@ -36,6 +37,8 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.compiere.util.DisplayType; +import org.compiere.util.DB; import org.posterita.Constants; import org.posterita.beans.ReportBean; @@ -61,7 +64,8 @@ public class StockMovementReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); String toDate = sdf.format(new Date(cal.getTimeInMillis())); @@ -88,9 +92,10 @@ public class StockMovementReportAction extends POSDispatchAction Properties ctx = TmkJSPEnv.getCtx(request); Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); - - String toDate = sdf.format(new Date(cal.getTimeInMillis())); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); + //String toDate = sdf.format(new Date(cal.getTimeInMillis())); + String toDate = DB.TO_DATE(new Timestamp(cal.getTimeInMillis())); cal.set(Calendar.DATE,1); cal.set(Calendar.HOUR_OF_DAY,0); @@ -98,7 +103,8 @@ public class StockMovementReportAction extends POSDispatchAction cal.set(Calendar.SECOND,0); cal.set(Calendar.MILLISECOND,0); - String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + //String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + String fromDate = DB.TO_DATE(new Timestamp(cal.getTimeInMillis())); ArrayList list=POSReportManager.getStockMovementReport(ctx,fromDate,toDate); request.getSession().setAttribute(Constants.STOCK_MOVEMENT,list); @@ -137,7 +143,8 @@ public class StockMovementReportAction extends POSDispatchAction Date startDate = ReportDateManager.getStartDateForPeriod(timePeriod); Date endDate = ReportDateManager.getEndDateForPeriod(timePeriod); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + //SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + SimpleDateFormat sdf = DisplayType.getDateFormat(DisplayType.Date); fromDate = sdf.format(startDate); toDate = sdf.format(endDate);