Commit 4ecaadf5 by Tuukka Kivilahti

vat is nice

1 parent a7ab8ee8
......@@ -225,7 +225,7 @@ public class BillBean implements BillBeanLocal {
ac.setEventTime(when);
ac.setBill(bill);
ac.setSeller(permbean.getCurrentUser());
bill.setAccountEvent(ac);
bill.setPaidDate(when.getTime());
......
......@@ -33,6 +33,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "ALTER TABLE tournament_participants ADD COLUMN tournament integer NOT NULL REFERENCES tournaments(id)" });
dbUpdates.add(new String[] { "DELETE FROM application_permissions WHERE application = 'MAP' and permission = 'RELEASE_PLACE'" });
dbUpdates.add(new String[] { "ALTER TABLE site_page_content ADD COLUMN locale varchar(10)" });
dbUpdates.add(new String[] { "ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)" });
}
@EJB
......
......@@ -77,13 +77,13 @@ public class BillLine extends GenericEntity {
private FoodWave foodwave;
/**
* Calculate the total price for the items on this line
* Calculate the total price for the items on this line,
* includes vat
*
* @return
*/
public BigDecimal getLinePrice() {
BigDecimal vatMultiplicand = BigDecimal.ONE.add(getVat());
return getLinePriceVatless().multiply(vatMultiplicand);
return getUnitPrice().multiply(getQuantity());
}
public BigDecimal getLineVat() {
......@@ -91,12 +91,13 @@ public class BillLine extends GenericEntity {
}
/**
* Calculate the total VAT-less price for the items on this lin
* return the total VAT-less price for the items on this line
*
* @return
*/
public BigDecimal getLinePriceVatless() {
return getUnitPrice().multiply(getQuantity());
BigDecimal vatMultiplicand = BigDecimal.ONE.add(getVat());
return getLinePrice().divide(vatMultiplicand, 2, RoundingMode.HALF_UP);
}
public BillLine() {
......@@ -143,12 +144,12 @@ public class BillLine extends GenericEntity {
super();
this.bill = bill2;
BigDecimal unitPrice = product.getPrice().subtract(product.getPrice().multiply(disc.getPercentage())).negate().setScale(2, RoundingMode.HALF_UP);
BigDecimal vatPrice = product.getVat().subtract(product.getVat().multiply(disc.getPercentage())).negate().setScale(2, RoundingMode.HALF_UP);
this.name = disc.getShortdesc();
this.unitName = product.getUnitName();
this.quantity = count;
this.unitPrice = unitPrice;
this.vat = vatPrice;
this.vat = product.getVat();
}
public String getName() {
......@@ -183,10 +184,18 @@ public class BillLine extends GenericEntity {
return unitPrice;
}
/**
* Set vat-% for this line, value betveen 0 and 1
* @param vat
*/
public void setVat(BigDecimal vat) {
this.vat = vat;
}
/**
* Return vat percent for this line
* @return vat-%, value between 0.00 and 0.99
*/
public BigDecimal getVat() {
return vat;
}
......
......@@ -201,10 +201,18 @@ public class Product extends GenericEntity {
this.name = productName;
}
/**
* Get product price, includes vat
* @return
*/
public BigDecimal getPrice() {
return price;
}
/**
* Set price, including vat
* @param price
*/
public void setPrice(BigDecimal price) {
this.price = price;
}
......@@ -257,10 +265,18 @@ public class Product extends GenericEntity {
return foodWaveTemplates;
}
/**
* Set product vat-%, value between 0 and 1
* @param vat
*/
public void setVat(BigDecimal vat) {
this.vat = vat;
}
/**
* Get product vat-%, value between 0 and 1
* @return
*/
public BigDecimal getVat() {
return vat;
}
......
......@@ -53,6 +53,14 @@
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['bill.vat']}" />
</f:facet>
<h:outputText value="#{bill.totalVat()}">
<f:convertNumber currencyCode="EUR" maxFractionDigits="2" minFractionDigits="2" type="currency" />
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['bill.totalPrice']}" />
</f:facet>
<h:outputText value="#{bill.totalPrice()}">
......
......@@ -22,6 +22,11 @@
<h:outputText id="billAmount" value="#{cc.attrs.bill.totalPrice()}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<h:outputLabel for="billVat" value="#{i18n['bill.vat']}" />
<h:outputText id="billVat" value="#{cc.attrs.bill.totalVat()}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<h:outputLabel for="sentDate" value="#{i18n['bill.sentDate']}:" />
<h:outputText id="sentDate" value="#{cc.attrs.bill.sentDateTime}">
......@@ -110,7 +115,22 @@
<h:outputText value="#{line.unitPrice}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['billine.vatp']}" />
</f:facet>
<h:outputText value="#{line.vat}">
<f:convertNumber type="percent" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['billine.vat']}" />
</f:facet>
<h:outputText value="#{line.lineVat}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
......@@ -120,6 +140,7 @@
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</h:column>
</h:dataTable>
</composite:implementation>
......
......@@ -33,6 +33,8 @@ bill.markPaid.show = Show Mark paid -buttons
bill.save = Save
bill.showPayButtons = Show pay buttons
billine.vatp = vat-%
bortalApplication.BILL = Creating, and managing bills
bortalApplication.COMPO = Managing compos
bortalApplication.CONTENT = Product & shop management
......
......@@ -61,7 +61,7 @@ bill.addr3 = Address 3
bill.addr4 = Address 4
bill.addr5 = Address 5
bill.address = Payers address
bill.billAmount = Bill amount
bill.billAmount = Bill amount (inc. vat)
bill.billIsPaid = Bill is paid
bill.billLines = Products
bill.billMarkedPaidMail.message = Your deposit number {0} has been marked as paid.
......@@ -94,6 +94,7 @@ bill.show = Show
bill.theirReference = Clients reference
bill.totalPrice = Total
bill.totalprice = Total
bill.vat = VAT
billLine.eventuser = Customer
billLine.nick = Nick
......@@ -104,7 +105,7 @@ billLine.time = Order Date
billedit.billnotfound = Bill not found. Select again.
billine.linePrice = Total
billine.linePrice = Total (inc. vat)
billine.name = Product
billine.quantity = Quantity
billine.referencedProduct = Referenced product
......@@ -112,6 +113,7 @@ billine.save = Save
billine.unitName = Unit
billine.unitPrice = Unit price
billine.vat = VAT
billine.vatp = vat-%
bills.noBills = No bills
......@@ -737,7 +739,7 @@ product.name = Name of product
product.paid = Paid
product.prepaid = Prepaid
product.prepaidInstant = Created when prepaid is paid
product.price = Price of product
product.price = Price of product (inc. vat)
product.providedRole = Product defines role
product.returnProductEdit = Return to product:
product.save = Save
......@@ -746,7 +748,7 @@ product.shopInstant = Create automatic cashpayment
product.sort = Sort nr
product.totalPrice = Total
product.unitName = Unit name
product.vat = VAT
product.vat = VAT-%
productFlag.CREATE_NEW_PLACE_WHEN_BOUGHT = Create new place bought
productFlag.PREPAID_CREDIT = Prepaid credit
......
......@@ -62,7 +62,7 @@ bill.addr4 = Osoite 4
bill.addr5 = Osoite 5
bill.address = Maksajan osoite
bill.allowStatistics = Tietoni saa julkaista tilastoissa
bill.billAmount = Laskun summa
bill.billAmount = Laskun summa (sis. alv)
bill.billIsPaid = Lasku on maksettu
bill.billLines = Tuotteet
bill.billMarkedPaidMail.message = Laskusi numero {0} on merkitty maksetuksi. Voit nyt siirty\u00E4 lippukauppaan varamaan haluamasi paikat. Tervetuloa tapahtumaan!
......@@ -96,6 +96,7 @@ bill.showPayButtons = N\u00E4yt\u00E4 maksunapit
bill.theirReference = Asiakkaan viite
bill.totalPrice = Summa
bill.totalprice = Yhteens\u00E4
bill.vat = ALV
billLine.eventuser = Asiakas
billLine.nick = Nimimerkki
......@@ -106,7 +107,7 @@ billLine.time = Tilausaika
billedit.billnotfound = Laskua ei l\u00F6ytynyt. Ole hyv\u00E4 ja valitse uudelleen.
billine.linePrice = Yhteens\u00E4
billine.linePrice = Yhteens\u00E4 (sis. alv)
billine.name = Tuote
billine.quantity = Lukum\u00E4\u00E4r\u00E4
billine.referencedProduct = Tuoteviittaus
......@@ -114,6 +115,7 @@ billine.save = Tallenna
billine.unitName = Yksikk\u00F6
billine.unitPrice = Yksikk\u00F6hinta
billine.vat = ALV
billine.vatp = alv-%
bills.noBills = Ei laskuja
......@@ -721,7 +723,7 @@ product.name = Tuotteen nimi
product.paid = Maksettu
product.prepaid = Prepaid
product.prepaidInstant = Luodaan kun prepaid maksetaan
product.price = Tuotteen hinta
product.price = Tuotteen hinta (sis. alv)
product.providedRole = Tuote tarjoaa roolin
product.returnProductEdit = Palaa tuotteeseen:
product.save = Tallenna
......@@ -730,7 +732,7 @@ product.shopInstant = Luo k\u00E4teismaksu tuotteille
product.sort = J\u00E4rjestys luku
product.totalPrice = Summa
product.unitName = Tuoteyksikk\u00F6
product.vat = ALV
product.vat = ALV-%
productFlag.CREATE_NEW_PLACE_WHEN_BOUGHT = Luo uusi paikka ostettaessa
productFlag.PREPAID_CREDIT = Prepaid credit
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!