From: Roland Häder Date: Thu, 26 Oct 2017 18:25:10 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4b206bfb4e19a9e2ed5fc4ea1ce1329aa6d8be80;p=jproduct-core.git Continued: - added net/gross price and tax rate (0.00-1.00 again) - let's not over-centralize data: + you may have to repeat these 3 fields in your entity when you want to record changing prices in your e.g. receipt items like in jfinancials + you may have to wait until a product_price_history entity has been added to have a generic price history of all products Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jproduct/model/product/GenericProduct.java b/src/org/mxchange/jproduct/model/product/GenericProduct.java index 2cd7d5e..e9829b9 100644 --- a/src/org/mxchange/jproduct/model/product/GenericProduct.java +++ b/src/org/mxchange/jproduct/model/product/GenericProduct.java @@ -76,11 +76,18 @@ public class GenericProduct implements Product { /** * When this product has been created */ - @Basic(optional = false) - @Column(name = "product_created", nullable = false, updatable = false) - @Temporal(TemporalType.TIMESTAMP) + @Basic (optional = false) + @Column (name = "product_created", nullable = false, updatable = false) + @Temporal (TemporalType.TIMESTAMP) private Date productCreated; + /** + * Gross price of product + */ + @Basic (optional = false) + @Column (name = "product_gross_price", nullable = false) + private Float productGrossPrice; + /** * Id number of product */ @@ -90,11 +97,16 @@ public class GenericProduct implements Product { private Long productId; /** - * Price of product + * Net price of product */ - @Basic (optional = false) - @Column (name = "product_price", nullable = false) - private Float productPrice; + @Column (name = "product_net_price") + private Float productNetPrice; + + /** + * Tax rate (0-1, by 1=100%) + */ + @Column (name = "product_gross_price") + private Float productTaxRate; /** * Title of product @@ -113,14 +125,14 @@ public class GenericProduct implements Product { * Constructor will all required data *

* @param productTitle Name of product - * @param productPrice Price + * @param productGrossPrice Product's gross price * @param productCategory Category instance * @param productAvailability Availability (selectable by customer) */ - public GenericProduct (final String productTitle, final Float productPrice, final Category productCategory, final Boolean productAvailability) { + public GenericProduct (final String productTitle, final Float productGrossPrice, final Category productCategory, final Boolean productAvailability) { // Set all here this.productTitle = productTitle; - this.productPrice = productPrice; + this.productGrossPrice = productGrossPrice; this.productCategory = productCategory; this.productAvailability = productAvailability; } @@ -178,6 +190,16 @@ public class GenericProduct implements Product { this.productCreated = productCreated; } + @Override + public Float getProductGrossPrice () { + return this.productGrossPrice; + } + + @Override + public void setProductGrossPrice (final Float productGrossPrice) { + this.productGrossPrice = productGrossPrice; + } + @Override public Long getProductId () { return this.productId; @@ -189,13 +211,23 @@ public class GenericProduct implements Product { } @Override - public Float getProductPrice () { - return this.productPrice; + public Float getProductNetPrice () { + return this.productNetPrice; + } + + @Override + public void setProductNetPrice (final Float productNetPrice) { + this.productNetPrice = productNetPrice; + } + + @Override + public Float getProductTaxRate () { + return this.productTaxRate; } @Override - public void setProductPrice (final Float productPrice) { - this.productPrice = productPrice; + public void setProductTaxRate (final Float productTaxRate) { + this.productTaxRate = productTaxRate; } @Override diff --git a/src/org/mxchange/jproduct/model/product/Product.java b/src/org/mxchange/jproduct/model/product/Product.java index b07b2ad..50b9443 100644 --- a/src/org/mxchange/jproduct/model/product/Product.java +++ b/src/org/mxchange/jproduct/model/product/Product.java @@ -84,18 +84,46 @@ public interface Product extends Serializable { void setProductId (final Long productId); /** - * Getter for raw price. + * Getter for product's net price *

- * @return Single price of product + * @return Product's net price */ - Float getProductPrice (); + Float getProductNetPrice (); /** - * Price of product + * Setter for product's net price *

- * @param productPrice the price to set + * @param productNetPrice Product's net price */ - void setProductPrice (final Float productPrice); + void setProductNetPrice (final Float productNetPrice); + + /** + * Getter for product's tax rate + *

+ * @return Product's tax rate + */ + Float getProductTaxRate (); + + /** + * Setter for product's tax rate + *

+ * @param productTaxRate Product's tax rate + */ + void setProductTaxRate (final Float productTaxRate); + + /** + * Getter for product's gross price + *

+ * @return Product's gross price + */ + Float getProductGrossPrice (); + + /** + * Setter for product's gross price + *

+ * @param productGrossPrice Product's gross price + */ + void setProductGrossPrice (final Float productGrossPrice); /** * Getter for title.