Related to issue 0033836: wrong "net unit price" with tax include taxes and price precision 6
authorMiguel de Juana <miguel.dejuana@openbravo.com>
Thu, 22 Sep 2016 12:14:58 +0200
changeset 5843 ddf5d9469812
parent 5842 5a39aa67b666
child 5844 ac890f93aaed
Related to issue 0033836: wrong "net unit price" with tax include taxes and price precision 6

- Checking invoice, check also: totalNet + totalTaxAmount = totalGross
src-test/org/openbravo/test/mobile/common/selenium/database/InvoiceLinesOfDocumentnoRow.java
src-test/org/openbravo/test/mobile/common/selenium/database/WebPOSDatabaseHelper.java
--- a/src-test/org/openbravo/test/mobile/common/selenium/database/InvoiceLinesOfDocumentnoRow.java	Thu Sep 22 11:46:05 2016 +0200
+++ b/src-test/org/openbravo/test/mobile/common/selenium/database/InvoiceLinesOfDocumentnoRow.java	Thu Sep 22 12:14:58 2016 +0200
@@ -39,4 +39,6 @@
   public String c_bpartner_id;
   public OBNumber linenetamt;
   public OBNumber linegrossamt;
+  public OBNumber c_invoice_totallines;
+  public OBNumber c_invoice_totaltaxamount;
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/mobile/common/selenium/database/WebPOSDatabaseHelper.java	Thu Sep 22 11:46:05 2016 +0200
+++ b/src-test/org/openbravo/test/mobile/common/selenium/database/WebPOSDatabaseHelper.java	Thu Sep 22 12:14:58 2016 +0200
@@ -493,6 +493,8 @@
     assertThat(row1.c_invoice_outstandingamt, equalTo(OBNumber.ZERO));
     assertThat(row1.c_invoice_finalsettlement, not(nullValue()));
     assertThat(row1.fin_payment_schedule_id, not(nullValue()));
+    assertThat(row1.c_invoice_grandtotal,
+        equalTo(row1.c_invoice_totallines.add(row1.c_invoice_totaltaxamount)));
   }
 
   public static void verifyInvoicePaidWithCredit(final String documentNo, final OBNumber gross,
@@ -523,7 +525,7 @@
     final String sql = "SELECT c_invoice.documentno as c_invoice_documentno, c_order.documentno as c_order_documentno, fin_payment_schedule.fin_payment_schedule_id,"
         + " c_invoice.ispaid as c_invoice_paymentcomplete, fin_payment_schedule.amount as fin_pmnt_schle_expectedamount, fin_payment_schedule.paidamt as fin_pmnt_schle_receivedamount,"
         + " c_invoice.grandtotal as c_invoice_grandtotal, c_invoice.totalpaid as c_invoice_totalpaid, c_invoice.outstandingamt as c_invoice_outstandingamt, c_invoice.finalsettlement as c_invoice_finalsettlement,"
-        + " c_invoiceline.line, c_invoice.c_bpartner_id, c_invoiceline.linenetamt, c_invoiceline.line_gross_amount"
+        + " c_invoiceline.line, c_invoice.c_bpartner_id, c_invoiceline.linenetamt, c_invoiceline.line_gross_amount, c_invoice.totallines as c_invoice_totallines, (SELECT sum(c_invoicetax.taxamt) FROM c_invoicetax where c_invoicetax.c_invoice_id = c_invoice.c_invoice_id) as c_invoice_totaltaxamount "
         + " FROM c_invoiceline" //
         + " INNER JOIN c_invoice ON c_invoiceline.c_invoice_id = c_invoice.c_invoice_id" //
         + " LEFT JOIN fin_payment_schedule ON c_invoice.c_invoice_id = fin_payment_schedule.c_invoice_id" //
@@ -536,7 +538,7 @@
         + "     INNER JOIN c_orderline ON c_invoiceline.c_orderline_id = c_orderline.c_orderline_id " //
         + "     INNER JOIN c_order ON c_orderline.c_order_id = c_order.c_order_id" //
         + "     WHERE c_order.documentno = '" + documentNo + "')" //
-        + " " + orderbyClause;
+        + orderbyClause;
 
     final ArrayList<InvoiceLinesOfDocumentnoRow> ils = new ArrayList<InvoiceLinesOfDocumentnoRow>();
 
@@ -564,6 +566,13 @@
         il.c_bpartner_id = rs.getString("c_bpartner_id");
         il.linenetamt = new OBNumber(rs.getBigDecimal("linenetamt"));
         il.linegrossamt = new OBNumber(rs.getBigDecimal("line_gross_amount"));
+        final BigDecimal c_invoice_totallines = rs.getBigDecimal("c_invoice_totallines") == null ? BigDecimal.ZERO
+            : rs.getBigDecimal("c_invoice_totallines");
+        il.c_invoice_totallines = new OBNumber(c_invoice_totallines);
+        final BigDecimal c_invoice_totaltaxamount = rs.getBigDecimal("c_invoice_totaltaxamount") == null ? BigDecimal.ZERO
+            : rs.getBigDecimal("c_invoice_totaltaxamount");
+        il.c_invoice_totaltaxamount = new OBNumber(c_invoice_totaltaxamount);
+
         ils.add(il);
       }
     }.execute(sql, expectedRecords);