Hi Everyone
I built a simple EPOS for a client using Perch Shop. It works fine - other than the following issue with total figures being different in the cart than the final order (which is used to print the receipt).
If we have an item costing £80 and then apply a 50% discount to the item, the correct total is shown in the cart, like this:
However, when this order is submitted, the following is shown as the order total:
Which, as you can see, is 1p out. The difference seems to be in the way the VAT is calculated as this is also 1p out.
Here's the template I'm using for the cart:
- <h1>Items in Basket (<perch:shop id="item_count" />)</h1>
- <perch:form id="cart" app="perch_shop" action="/epos/">
- <table class="cart">
- <tr>
- <th>Item</th>
- <th>Remove</th>
- <th>Quantity</th>
- <th>Price</th>
- <th>Total</th>
- </tr>
- <perch:cartitems>
- <tr>
- <td>
- <b><perch:cartitem id="title" /></b>
- <p><i><perch:cartitem id="variant_desc" /></i></p>
- <div class="desc">
- <perch:cartitem id="description" type="textarea" markdown="true" />
- </div>
- </td>
- <td>
- <button type="submit" class="remove_cart" name="del:<perch:cartitem id="identifier" />" value="1">
- Remove
- </button>
- </td>
- <td><perch:input id="qty:<perch:cartitem id="identifier" />" value="<perch:cartitem id="quantity" />" type="number" min="0" /></td>
- <td class="money"><perch:cartitem id="price_with_tax" /></td>
- <td class="money"><perch:cartitem id="total_with_tax_formatted" /></td>
- </tr>
- </perch:cartitems>
- <perch:if id="total_discounts" match="gt" value="0.00">
- <tr class="total">
- <th colspan="4">
- Discount (<perch:shop id="discount_code" />)
- </th>
- <td class="money">
- <perch:shop id="total_discounts_formatted" />
- </td>
- </tr>
- <tr class="total">
- <th colspan="4">
- Total
- </th>
- <td class="money">
- <perch:shop id="total_items_discounted_formatted" />
- </td>
- </tr>
- <perch:else />
- <tr class="total">
- <th colspan="4">
- Total
- </th>
- <td class="money">
- <perch:shop id="total_items_formatted" />
- </td>
- </tr>
- </perch:if>
- <tr class="total">
- <th colspan="4">
- Tax
- </th>
- <td class="money">
- <perch:shop id="total_tax_formatted" />
- </td>
- </tr>
- <tr class="total">
- <th colspan="4">
- Grand total
- </th>
- <td class="money">
- <perch:shop id="grand_total_formatted" />
- </td>
- </tr>
- </table>
- <perch:input type="submit" value="Update Cart" class="update_cart" />
- </perch:form>
- <p>
- <a class="epos_button" href="/epos/?function=checkout">Process Sale</a>
- </p>
And here's the template for the final order:
- <perch:shop id="orderCreated" type="date" format="d F Y H:i" />
- <table>
- <tr>
- <th>Item</th>
- <th class="right">Quantity</th>
- <th class="right">Price</th>
- <th class="right">Total</th>
- </tr>
- </perch:before>
- <perch:orderitems>
- <tr>
- <td>
- <perch:orderitem id="title" type="hidden" />
- (<perch:orderitem id="variant_desc" type="hidden" />)
- </td>
- <td align="left">
- <perch:orderitem id="quantity" type="hidden" />
- </td>
- <td align="right">
- <perch:orderitem id="price_with_tax" type="hidden" format="$:%.2n" />
- </td>
- <td align="right">
- <perch:orderitem id="total_with_tax" type="hidden" format="$:%.2n" />
- </td>
- </tr>
- </perch:orderitems>
- <perch:if id="total_discounts" match="gt" value="0.00">
- <tr class="total">
- <th colspan="3">
- Discount (<perch:shop id="discount_code" />)
- </th>
- <td class="money" align="right">
- <perch:shop id="total_discounts_formatted" />
- </td>
- </tr>
- <tr>
- <td colspan="3">VAT</td>
- <td align="right"><perch:shop id="total_tax_formatted" /></td>
- </tr>
- <tr class="total">
- <th colspan="3">
- Total
- </th>
- <td class="money" align="right">
- <perch:shop id="grand_total_formatted" />
- </td>
- </tr>
- <perch:else />
- <tr>
- <td colspan="3">VAT</td>
- <td align="right"><perch:shop id="total_tax_formatted" /></td>
- </tr>
- <tr class="total">
- <th colspan="3">
- Total
- </th>
- <td class="money" align="right">
- <perch:shop id="grand_total_formatted" />
- </td>
- </tr>
- </perch:if>
- <perch:after>
- </table>
- </perch:after>
You can see I'm using the same <perch:shop id="" /> tags for the discount value, tax and grand totals - so I can't work out why these would be calculated any differently between the cart and the final order. Anyone else seen this or can suggest a fix?
Thanks!