Commit 4ecaadf5 by Tuukka Kivilahti

vat is nice

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