Attached Files | sc1.png [^] (179,848 bytes) 2015-08-19 15:06

step2.pdf [^] (7,604 bytes) 2015-08-19 15:08
step3.png [^] (178,717 bytes) 2015-08-19 15:08

step4.pdf [^] (7,603 bytes) 2015-08-19 15:09
30607_Q2_posterminal.patch [^] (9,953 bytes) 2015-08-27 18:35 [Show Content] [Hide Content]# HG changeset patch
# User Rafa Alonso <ral@openbravo.com>
# Date 1440693219 -7200
# Thu Aug 27 18:33:39 2015 +0200
# Node ID 7fa3a6199d4d87fa08ccc92512831ca597c83630
# Parent 9c5f3f405dcd036005bdd7acc4823f0952c54433
Fixes issue 30607: The sales section of the cashup report is recovered from the already existing cashup information
The problem was that the cashup report was being generated on demand and we do not keep track of the cashupId to which a sale belonged before it is assigned to a new cashupId when it is paid.
The solution has been to retrieve the information from the already existing data.
This solucion could be extended to the other sections of the cashup report. We like the fact that is being regenerated because it has been a good source of catching issues
diff -r 9c5f3f405dcd -r 7fa3a6199d4d src/org/openbravo/retail/posterminal/ad_reports/CashUpReport.java
--- a/src/org/openbravo/retail/posterminal/ad_reports/CashUpReport.java Tue Aug 25 15:42:43 2015 +0200
+++ b/src/org/openbravo/retail/posterminal/ad_reports/CashUpReport.java Thu Aug 27 18:33:39 2015 +0200
@@ -72,16 +72,9 @@
private static final Logger log = Logger.getLogger(CashUpReport.class);
OBPOSAppCashup cashup;
- List<?> salesTaxList;
- List<?> returnsTaxList;
- BigDecimal totalNetSalesAmount;
- BigDecimal totalGrossSalesAmount;
- BigDecimal totalNetReturnsAmount;
- BigDecimal totalGrossReturnsAmount;
BigDecimal cashToDeposit;
BigDecimal conversionRate;
String isoCode;
- BigDecimal totalRetailTransactions;
BigDecimal totalDrops;
BigDecimal totalDeposits;
BigDecimal expected;
@@ -100,21 +93,14 @@
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException {
- totalNetSalesAmount = BigDecimal.ZERO;
- totalGrossSalesAmount = BigDecimal.ZERO;
- totalNetReturnsAmount = BigDecimal.ZERO;
- totalGrossReturnsAmount = BigDecimal.ZERO;
cashToDeposit = BigDecimal.ZERO;
conversionRate = BigDecimal.ONE;
isoCode = new String();
- totalRetailTransactions = BigDecimal.ZERO;
totalDrops = BigDecimal.ZERO;
totalDeposits = BigDecimal.ZERO;
taxAmount = BigDecimal.ZERO;
hqlWhere = new String();
- salesTaxList = new ArrayList<Object[]>();
- returnsTaxList = new ArrayList<Object[]>();
hashMapList = new ArrayList<HashMap<String, String>>();
hashMapStartingsList = new ArrayList<HashMap<String, String>>();
hashMapSalesList = new ArrayList<HashMap<String, String>>();
@@ -531,67 +517,51 @@
hashMapCashToDepositList.add(psData);
}
- /******************************* SALES ***************************************************************/
- String hqlSales = "select abs(sum(ordLine.lineNetAmount)) from OrderLine as ordLine"
- + " where ordLine.salesOrder.obposAppCashup = " + "'" + cashupId + "' ";
- hqlWhere = "and ordLine.salesOrder.documentType.sOSubType = 'WR' and ordLine.orderedQuantity > 0";
- Query salesQuery = OBDal.getInstance().getSession().createQuery(hqlSales + hqlWhere);
- BigDecimal totalSalesAmount = (BigDecimal) salesQuery.list().get(0);
- if (totalSalesAmount != null)
- totalNetSalesAmount = totalNetSalesAmount.add(totalSalesAmount);
+ /******************************* SALES AREA ***************************************************************/
+ final String hqlCashup = "SELECT netsales, grosssales, netreturns, grossreturns, totalretailtransactions " //
+ + " FROM OBPOS_App_Cashup " //
+ + " WHERE id = '" + cashupId + "' "; //
+ final Query cashupQuery = OBDal.getInstance().getSession().createQuery(hqlCashup);
+ final Object[] arrayOfCashupResults = (Object[]) cashupQuery.list().get(0);
+ final BigDecimal totalNetSalesAmount = (BigDecimal) arrayOfCashupResults[0];
+ final BigDecimal totalGrossSalesAmount = (BigDecimal) arrayOfCashupResults[1];
+ final BigDecimal totalNetReturnsAmount = (BigDecimal) arrayOfCashupResults[2];
+ final BigDecimal totalGrossReturnsAmount = (BigDecimal) arrayOfCashupResults[3];
+ final BigDecimal totalRetailTransactions = (BigDecimal) arrayOfCashupResults[4];
- /******************************* RETURNS ***************************************************************/
- hqlWhere = "and (ordLine.salesOrder.documentType.sOSubType = 'SO' or ordLine.salesOrder.documentType.sOSubType = 'WR') and ordLine.orderedQuantity < 0";
- Query returnsQuery = OBDal.getInstance().getSession().createQuery(hqlSales + hqlWhere);
- BigDecimal totalReturnsAmount = (BigDecimal) returnsQuery.list().get(0);
- if (totalReturnsAmount != null)
- totalNetReturnsAmount = totalNetReturnsAmount.add(totalReturnsAmount);
+ // SALES TAXES
+ final String hqlTaxes = String.format("SELECT name, STR(ABS(amount)) " //
+ + " FROM OBPOS_Taxcashup " //
+ + " WHERE obpos_app_cashup_id='%s' AND ordertype='0' " //
+ + " ORDER BY name ", cashupId);
+ final Query salesTaxesQuery = OBDal.getInstance().getSession().createQuery(hqlTaxes);
+ final JRDataSource salesTaxesDataSource = new ListOfArrayDataSource(salesTaxesQuery.list(),
+ new String[] { "LABEL", "VALUE" });
+
+ // RETURNS TAXES
+ final String hqlReturnTaxes = String.format("SELECT name, STR(ABS(amount)) " //
+ + " FROM OBPOS_Taxcashup " //
+ + " WHERE obpos_app_cashup_id='%s' AND ordertype='1' " //
+ + " ORDER BY name ", cashupId);
+ final Query returnsTaxesQuery = OBDal.getInstance().getSession().createQuery(hqlReturnTaxes);
+ final JRDataSource returnTaxesDatasource = new ListOfArrayDataSource(
+ returnsTaxesQuery.list(), new String[] { "LABEL", "VALUE" });
+
+ /******************************* BUILD REPORT ***************************************************************/
try {
JasperReport subReportSalesTaxes;
- String strLanguage = vars.getLanguage();
- String strBaseDesign = getBaseDesignPath(strLanguage);
- JasperDesign jasperDesignLines = JRXmlLoader.load(strBaseDesign
+ final String strLanguage = vars.getLanguage();
+ final String strBaseDesign = getBaseDesignPath(strLanguage);
+ final JasperDesign jasperDesignLines = JRXmlLoader.load(strBaseDesign
+ "/org/openbravo/retail/posterminal/ad_reports/CashUpSubreport.jrxml");
subReportSalesTaxes = JasperCompileManager.compileReport(jasperDesignLines);
parameters.put("SUBREP_CASHUP", subReportSalesTaxes);
- } catch (JRException e) {
+ } catch (final JRException e) {
throw new ServletException(e.getMessage());
}
- // SALES TAXES
- String hqlTaxes = "select orderLineTax.tax.name ,str(abs(sum(orderLineTax.taxAmount))) from OrderLineTax as orderLineTax "
- + " where orderLineTax.salesOrderLine.salesOrder.obposAppCashup = "
- + "'"
- + cashupId
- + "' ";
- hqlWhere = "and orderLineTax.salesOrderLine.salesOrder.documentType.sOSubType = 'WR' and orderLineTax.salesOrderLine.orderedQuantity > 0 group by orderLineTax.tax.name order by orderLineTax.tax.name";
- Query salesTaxesQuery = OBDal.getInstance().getSession().createQuery(hqlTaxes + hqlWhere);
- salesTaxList = salesTaxesQuery.list();
- totalGrossSalesAmount = totalNetSalesAmount;
- for (Object obj : salesTaxList) {
- Object[] obja = (Object[]) obj;
- taxAmount = new BigDecimal(obja[1].toString());
- totalGrossSalesAmount = totalGrossSalesAmount.add(taxAmount);
- }
- dataSource = new ListOfArrayDataSource(salesTaxList, new String[] { "LABEL", "VALUE" });
- parameters.put("SALES_TAXES", dataSource);
-
- // RETURNS TAXES
- hqlWhere = "and (orderLineTax.salesOrderLine.salesOrder.documentType.sOSubType = 'SO' or orderLineTax.salesOrderLine.salesOrder.documentType.sOSubType = 'WR') and orderLineTax.salesOrderLine.orderedQuantity < 0 group by orderLineTax.tax.name order by orderLineTax.tax.name";
- Query returnsTaxesQuery = OBDal.getInstance().getSession().createQuery(hqlTaxes + hqlWhere);
- returnsTaxList = returnsTaxesQuery.list();
- totalGrossReturnsAmount = totalNetReturnsAmount;
- for (Object obj : returnsTaxList) {
- Object[] obja = (Object[]) obj;
- taxAmount = new BigDecimal(obja[1].toString());
- totalGrossReturnsAmount = totalGrossReturnsAmount.add(taxAmount);
- }
- dataSource = new ListOfArrayDataSource(returnsTaxList, new String[] { "LABEL", "VALUE" });
- parameters.put("RETURNS_TAXES", dataSource);
-
- totalRetailTransactions = totalGrossSalesAmount.subtract(totalGrossReturnsAmount);
parameters.put("STORE", OBMessageUtils.getI18NMessage("OBPOS_LblStore", new String[] {})
+ ": " + cashup.getPOSTerminal().getOrganization().getIdentifier());
parameters.put("TERMINAL",
@@ -605,12 +575,14 @@
parameters.put("NET_SALES_LABEL",
OBMessageUtils.getI18NMessage("OBPOS_LblNetSales", new String[] {}));
parameters.put("NET_SALES_VALUE", totalNetSalesAmount.toString());
+ parameters.put("SALES_TAXES", salesTaxesDataSource);
parameters.put("GROSS_SALES_LABEL",
OBMessageUtils.getI18NMessage("OBPOS_LblGrossSales", new String[] {}));
parameters.put("GROSS_SALES_VALUE", totalGrossSalesAmount.toString());
parameters.put("NET_RETURNS_LABEL",
OBMessageUtils.getI18NMessage("OBPOS_LblNetReturns", new String[] {}));
parameters.put("NET_RETURNS_VALUE", totalNetReturnsAmount.toString());
+ parameters.put("RETURNS_TAXES", returnTaxesDatasource);
parameters.put("GROSS_RETURNS_LABEL",
OBMessageUtils.getI18NMessage("OBPOS_LblGrossReturns", new String[] {}));
parameters.put("GROSS_RETURNS_VALUE", totalGrossReturnsAmount.toString());
|