|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| Invoice.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/**
|
|
| 2 |
* This class is only generated once! It will never be overwritten.
|
|
| 3 |
* You can (and have to!) safely modify it by hand.
|
|
| 4 |
*/
|
|
| 5 |
/*
|
|
| 6 |
* Invoice.java
|
|
| 7 |
* Copyright 2002-2004 Bill2, Inc.
|
|
| 8 |
*
|
|
| 9 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 10 |
* you may not use this file except in compliance with the License.
|
|
| 11 |
* You may obtain a copy of the License at
|
|
| 12 |
*
|
|
| 13 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 14 |
*
|
|
| 15 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 16 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 17 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 18 |
* See the License for the specific language governing permissions and
|
|
| 19 |
* limitations under the License.
|
|
| 20 |
*/
|
|
| 21 |
package example.entity;
|
|
| 22 |
|
|
| 23 |
import java.math.BigDecimal;
|
|
| 24 |
import java.util.HashSet;
|
|
| 25 |
import java.util.Iterator;
|
|
| 26 |
|
|
| 27 |
/**
|
|
| 28 |
* @hibernate.class
|
|
| 29 |
* table="Invoice"
|
|
| 30 |
*/
|
|
| 31 |
public class Invoice |
|
| 32 |
extends InvoiceBase
|
|
| 33 |
{
|
|
| 34 | 0 |
public Invoice() {
|
| 35 | 0 |
setCcCharges(new HashSet());
|
| 36 | 0 |
setLineItems(new HashSet());
|
| 37 |
} |
|
| 38 |
|
|
| 39 |
// concrete business methods that were declared
|
|
| 40 |
// abstract in class Invoice ...
|
|
| 41 |
|
|
| 42 | 0 |
public void compute() { |
| 43 |
// subtotal
|
|
| 44 | 0 |
double subTotal = 0.0;
|
| 45 | 0 |
for (Iterator it = getLineItems().iterator(); it.hasNext();) {
|
| 46 | 0 |
LineItem lineItem = (LineItem) it.next(); |
| 47 | 0 |
subTotal += lineItem.getAmount().doubleValue(); |
| 48 |
} |
|
| 49 | 0 |
double total = subTotal;
|
| 50 |
|
|
| 51 |
// taxes
|
|
| 52 | 0 |
Address shipAddress = getShipAddress(); |
| 53 | 0 |
if (shipAddress != null && shipAddress.getState() != null && shipAddress.getState().equals("NY")) { |
| 54 | 0 |
double taxTotal = .0825 * subTotal;
|
| 55 | 0 |
this.taxTotal = new BigDecimal(taxTotal).setScale(2, BigDecimal.ROUND_HALF_DOWN); |
| 56 | 0 |
total += taxTotal; |
| 57 |
} |
|
| 58 |
|
|
| 59 |
// shipping
|
|
| 60 | 0 |
if (getShippingMethod() != null) { |
| 61 | 0 |
total += getShippingMethod().getPrice().doubleValue(); |
| 62 |
} |
|
| 63 | 0 |
this.subTotal = new BigDecimal(subTotal).setScale(2, BigDecimal.ROUND_HALF_DOWN); |
| 64 | 0 |
this.total = new BigDecimal(total).setScale(2, BigDecimal.ROUND_HALF_DOWN); |
| 65 |
} |
|
| 66 |
|
|
| 67 |
} |
|
| 68 |
|
|
||||||||||