Permalink
Browse files

cleaned up saleTransaction, added payment amounts to transactions

  • Loading branch information...
1 parent 06d5cb3 commit fc88a0c9abdad92ec0260b4485e4ab240c2de91c Steve Vlaminck committed Jun 22, 2012
@@ -83,17 +83,17 @@ class CartController {
def cash
if (params.paymentType1 == 'Cash')
{
- cash = changeDue > 0 ? params.paymentAmount1.toDouble() - changeDue : params.paymentAmount1
+ cash = changeDue > 0 ? params.paymentAmount1.toDouble() - changeDue : params.paymentAmount1 as Double
transaction.paymentAmount1 = cash
}
else if (params.paymentType2 == 'Cash')
{
- cash = changeDue > 0 ? params.paymentAmount2.toDouble() - changeDue : params.paymentAmount2
+ cash = changeDue > 0 ? params.paymentAmount2.toDouble() - changeDue : params.paymentAmount2 as Double
transaction.paymentAmount2 = cash
}
else if (params.paymentType3 == 'Cash')
{
- cash = changeDue > 0 ? params.paymentAmount3.toDouble() - changeDue : params.paymentAmount3
+ cash = changeDue > 0 ? params.paymentAmount3.toDouble() - changeDue : params.paymentAmount3 as Double
transaction.paymentAmount3 = cash
}
@@ -1,71 +1,90 @@
<li>
<h1>Transaction ${transaction.id}
- <g:link controller="sale" action="voidTransaction" params="[saleId: sale.id, transactionId: transaction.id]" class="btn btn-danger" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');">Void Transaction</g:link>
+ <g:link controller="sale" action="voidTransaction" params="[saleId: sale.id, transactionId: transaction.id]"
+ class="btn btn-danger"
+ onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');">Void Transaction</g:link>
</h1>
<table class="table table-striped">
- <thead>
- <tr>
+ <thead>
+ <tr>
- <g:sortableColumn property="title" title="Title"/>
+ <g:sortableColumn property="title" title="Title"/>
- <g:sortableColumn property="artist" title="Artist"/>
+ <g:sortableColumn property="artist" title="Artist"/>
- <g:sortableColumn property="price" title="Price"/>
+ <g:sortableColumn property="price" title="Price"/>
- <g:sortableColumn property="artworkQty"
- title="Qty"/>
+ <g:sortableColumn property="artworkQty"
+ title="Qty"/>
- <g:sortableColumn property="totalPrice" title="Total Price"></g:sortableColumn>
+ <g:sortableColumn property="totalPrice" title="Total Price"></g:sortableColumn>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <g:each in="${transaction.transactionItems}" var="transactionItem">
- <g:set var="artworkInstance" value="${transactionItem.artwork}"/>
- <tr>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <g:each in="${transaction.transactionItems}" var="transactionItem">
+ <g:set var="artworkInstance" value="${transactionItem.artwork}"/>
+ <tr>
- <td>${artworkInstance.title}</td>
+ <td>${artworkInstance.title}</td>
- <td>${artworkInstance.artist.fullName}</td>
+ <td>${artworkInstance.artist.fullName}</td>
- <td><g:formatNumber number="${transactionItem.priceEach.round(2)}" type="currency" currencyCode="USD"/></td>
+ <td><g:formatNumber number="${transactionItem.priceEach.round(2)}" type="currency"
+ currencyCode="USD"/></td>
- <td>${transactionItem.qtySold}</td>
+ <td>${transactionItem.qtySold}</td>
- <td><g:formatNumber number="${transactionItem.totalPrice.round(2)}" type="currency"
+ <td><g:formatNumber number="${transactionItem.totalPrice.round(2)}" type="currency"
+ currencyCode="USD"/></td>
+ </tr>
+ </g:each>
+ <tr>
+ <td colspan="5">
+ <hr/>
+ </td>
+ </tr>
+ <tr>
+ <td class="rightAlign">Payment 1:</td>
+ <td>
+ <g:formatNumber number="${transaction.paymentAmount1.round(2)}" type="currency"
+ currencyCode="USD"/>
+ ${transaction.paymentType1}
+ </td>
+ <td></td>
+ <td class="rightAlign">Total Before Tax:</td>
+ <td><g:formatNumber number="${transaction.totalBeforeTax.round(2)}" type="currency"
currencyCode="USD"/></td>
</tr>
- </g:each>
- <tr>
- <td colspan="5">
- <hr/>
- </td>
- </tr>
- <tr>
- <td></td>
- <td></td>
- <td></td>
- <td class="rightAlign">Total Before Tax:</td>
- <td><g:formatNumber number="${transaction.totalBeforeTax.round(2)}" type="currency" currencyCode="USD"/></td>
- </tr>
- <tr>
- <td></td>
- <td></td>
- <td></td>
- <td class="rightAlign">Total Tax:</td>
- <td><g:formatNumber number="${transaction.totalTax.round(2)}" type="currency" currencyCode="USD"/></td>
- </tr>
- <tr>
- <td>
- </td>
- <td></td>
- <td></td>
- <td class="bold rightAlign">Total Including Tax:</td>
- <td class="bold"><g:formatNumber number="${transaction.totalWithTax.round(2)}" type="currency"
- currencyCode="USD"/></td>
+ <tr>
+ <td class="rightAlign">${transaction.paymentAmount2 ? 'Payment 2:' : ''}</td>
+ <td>
+ <g:if test="${transaction.paymentAmount2}">
+ <g:formatNumber number="${transaction.paymentAmount2.round(2)}" type="currency"
+ currencyCode="USD"/>
+ ${transaction.paymentType2}
+ </g:if>
+ </td>
+ <td></td>
+ <td class="rightAlign">Total Tax:</td>
+ <td><g:formatNumber number="${transaction.totalTax.round(2)}" type="currency" currencyCode="USD"/></td>
+ </tr>
+ <tr>
+ <td class="rightAlign">${transaction.paymentAmount3 ? 'Payment 3:' : ''}</td>
+ <td>
+ <g:if test="${transaction.paymentAmount3}">
+ <g:formatNumber number="${transaction.paymentAmount3.round(2)}" type="currency"
+ currencyCode="USD"/>
+ ${transaction.paymentType3}
+ </g:if>
+ </td>
+ <td></td>
+ <td class="bold rightAlign">Total Including Tax:</td>
+ <td class="bold"><g:formatNumber number="${transaction.totalWithTax.round(2)}" type="currency"
+ currencyCode="USD"/></td>
- </tr>
- </tbody>
-</table>
+ </tr>
+ </tbody>
+ </table>
</li>
@@ -8,8 +8,10 @@
<body>
<g:render template="../flashMessages"/>
<ul>
-<g:each var="transaction" in="${sale.transactions}">
+<g:each var="transaction" in="${sale.transactions.sort{it.id}}">
<g:render template="saleTransaction" model="[transaction: transaction, sale: sale]"/>
+ <br/>
+ <br/>
</g:each>
</ul>
</body>

0 comments on commit fc88a0c

Please sign in to comment.