Commit 5be509b8 by Tuomas Riihimäki

Merge branch 'devel' of codecrew.fi:bortal into devel

2 parents f8a3c834 a4e00182
package fi.insomnia.bortal.model;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
......@@ -13,7 +14,7 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
@Entity
@Table(name = "inventory_event")
@Table(name = "inventory_events")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class InventoryEvent extends GenericEntity {
private static final long serialVersionUID = 1L;
......@@ -41,22 +42,14 @@ public class InventoryEvent extends GenericEntity {
this.info = info;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
@JoinColumn(name = "product_id")
private Product product;
@Column(name = "info", nullable = true)
private String info;
@Column(name = "count", nullable=false)
private int count;
@Column(name = "quantity", nullable = false, precision = 24, scale = 4)
private BigDecimal quantity;
......@@ -76,5 +69,13 @@ public class InventoryEvent extends GenericEntity {
this.created = created;
}
public BigDecimal getQuantity() {
return quantity;
}
public void setQuantity(BigDecimal quantity) {
this.quantity = quantity;
}
}
......@@ -91,7 +91,7 @@ public class Product extends GenericEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<AccountEvent> accountEvents;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<InventoryEvent> inventoryEvents;
......@@ -171,6 +171,23 @@ public class Product extends GenericEntity {
return ret;
}
public BigDecimal getInventoryCount() {
BigDecimal ret = new BigDecimal(0);
if (accountEvents != null) {
for (AccountEvent ae : accountEvents) {
ret = ret.subtract(ae.getQuantity());
}
}
if (inventoryEvents != null) {
for (InventoryEvent ie : inventoryEvents) {
ret = ret.add(ie.getQuantity());
}
}
return ret;
}
public String getName() {
return name;
}
......
......@@ -48,6 +48,15 @@
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['product.inventoryQuantity']}" />
</f:facet>
<h:outputText value="#{product.inventoryCount}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</h:column>
</h:dataTable>
</h:form>
......
......@@ -65,6 +65,7 @@
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</h:column>
<h:column>
......
......@@ -5,15 +5,16 @@ acc_line.product = Product
acc_line.quantity = Quantity
acc_line.time = Transaction Date
accountEvent.commit = Save
accountEvent.delivered = Delivered
accountEvent.edit = Edit
accountEvent.eventTime = Time
accountEvent.productname = Product
accountEvent.quantity = Count
accountEvent.seller = Sold by
accountEvent.total = Total
accountEvent.unitPrice = Unit price
accountEvent.commit = Save
accountEvent.delivered = Delivered
accountEvent.edit = Edit
accountEvent.eventTime = Time
accountEvent.inventoryQuantity = Inventory Count
accountEvent.productname = Product
accountEvent.quantity = Count
accountEvent.seller = Sold by
accountEvent.total = Total
accountEvent.unitPrice = Unit price
actionlog.create.header = Create new actionmessage
actionlog.create.message = Message
......@@ -527,6 +528,7 @@ product.color = Color in UI
product.create = Create product
product.createDiscount = Add volumediscount
product.edit = edit
product.inventoryQuantity = Inventory count
product.name = Name of product
product.paid = Paid
product.prepaid = Prepaid
......
......@@ -5,15 +5,16 @@ acc_line.product = Tuote
acc_line.quantity = M\u00E4\u00E4r\u00E4
acc_line.time = Ostoaika
accountEvent.commit = Tallenna
accountEvent.delivered = Toimitettu
accountEvent.edit = Muokkaa
accountEvent.eventTime = Aika
accountEvent.productname = Tuote
accountEvent.quantity = Lkm
accountEvent.seller = Myyj\u00E4
accountEvent.total = Yhteens\u00E4
accountEvent.unitPrice = Yksikk\u00F6hinta
accountEvent.commit = Tallenna
accountEvent.delivered = Toimitettu
accountEvent.edit = Muokkaa
accountEvent.eventTime = Aika
accountEvent.inventoryQuantity = Varastossa
accountEvent.productname = Tuote
accountEvent.quantity = Lkm
accountEvent.seller = Myyj\u00E4
accountEvent.total = Yhteens\u00E4
accountEvent.unitPrice = Yksikk\u00F6hinta
actionlog.create.header = Luo uusi ActionMessage
actionlog.create.message = Viesti
......@@ -510,6 +511,7 @@ product.color = V\u00E4ri k\u00E4ytt\u00F6liittym\u00E4ss\u00E4
product.create = Luo tuote
product.createDiscount = Lis\u00E4\u00E4 m\u00E4\u00E4r\u00E4alennus
product.edit = Muokkaa
product.inventoryQuantity = Varastotilanne
product.name = Tuotteen nimi
product.paid = Maksettu
product.prepaid = Prepaid
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!