From: Roland Häder Date: Thu, 26 Oct 2017 19:17:50 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f4e784bd3be7e6c2d3a6113ce8df3128872f1109;p=jbonuscard-core.git Continued: - the item should store net and gross price and taxes on each item again - else, all receipt's item prices will be same when the product's price has been updated - this way, you can track tax rate and price changes Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java index a6cd297..ab81a12 100644 --- a/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java +++ b/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java @@ -19,6 +19,7 @@ package org.mxchange.jfinancials.model.receipt_item; import java.io.Serializable; import java.util.Date; import org.mxchange.jfinancials.model.receipt.BillableReceipt; +import org.mxchange.jproduct.model.category.Category; import org.mxchange.jproduct.model.product.Product; /** @@ -28,6 +29,20 @@ import org.mxchange.jproduct.model.product.Product; */ public interface BillableReceiptItem extends Serializable { + /** + * Getter for item's product category + *

+ * @return Item's product category + */ + Category getItemCategory (); + + /** + * Setter for item's product category + *

+ * @param itemCategory Item's product category + */ + void setItemCategory (final Category itemCategory); + /** * Getter when this receipt item has been created in database *

@@ -103,14 +118,56 @@ public interface BillableReceiptItem extends Serializable { *

* @return Product quantity */ - Long getItemProductQuantity (); + Short getItemProductQuantity (); /** * Setter for product quantity *

* @param itemProductQuantity Product quantity */ - void setItemProductQuantity (final Long itemProductQuantity); + void setItemProductQuantity (final Short itemProductQuantity); + + /** + * Getter for item's net price + *

+ * @return Item's net price + */ + Float getItemNetPrice (); + + /** + * Setter for item's net price + *

+ * @param itemNetPrice Item's net price + */ + void setItemNetPrice (final Float itemNetPrice); + + /** + * Getter for item's tax rate + *

+ * @return Item's tax rate + */ + Float getItemTaxRate (); + + /** + * Setter for item's tax rate + *

+ * @param itemTaxRate Item's tax rate + */ + void setItemTaxRate (final Float itemTaxRate); + + /** + * Getter for item's gross price + *

+ * @return Item's gross price + */ + Float getItemGrossPrice (); + + /** + * Setter for item's gross price + *

+ * @param itemGrossPrice Item's gross price + */ + void setItemGrossPrice (final Float itemGrossPrice); @Override boolean equals (final Object object); diff --git a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java index fa86c3f..d3a9105 100644 --- a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java +++ b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java @@ -36,6 +36,8 @@ import javax.persistence.TemporalType; import javax.persistence.Transient; import org.mxchange.jfinancials.model.receipt.BillableReceipt; import org.mxchange.jfinancials.model.receipt.FinancialReceipt; +import org.mxchange.jproduct.model.category.Category; +import org.mxchange.jproduct.model.category.ProductCategory; import org.mxchange.jproduct.model.product.GenericProduct; import org.mxchange.jproduct.model.product.Product; @@ -67,6 +69,13 @@ public class FinancialReceiptItem implements BillableReceiptItem { @Transient private static final long serialVersionUID = 126_498_698_378_571L; + /** + * Category being assigned to item's product + */ + @JoinColumn(name = "item_category_id", referencedColumnName = "category_id", updatable = false) + @OneToOne(targetEntity = ProductCategory.class, cascade = CascadeType.REFRESH, optional = false) + private Category itemCategory; + /** * When this item has been created in database */ @@ -96,12 +105,30 @@ public class FinancialReceiptItem implements BillableReceiptItem { @Column (name = "item_product_discount") private Float itemProductDiscount; + /** + * Net price of item + */ + @Column (name = "item_net_price") + private Float itemNetPrice; + + /** + * Gross price of item + */ + @Column (name = "item_gross_price") + private Float itemGrossPrice; + + /** + * Tax rate + */ + @Column (name = "item_tax_rate") + private Float itemTaxRate; + /** * Product quantity */ @Basic (optional = false) @Column (name = "item_product_quantity", nullable = false) - private Long itemProductQuantity; + private Short itemProductQuantity; /** * Connected itemReceipt item @@ -123,11 +150,12 @@ public class FinancialReceiptItem implements BillableReceiptItem { * @param itemProductQuantity Product quantity * @param itemReceipt FinancialReceipt instance */ - public FinancialReceiptItem (final Product itemProduct, final Long itemProductQuantity, final BillableReceipt itemReceipt) { + public FinancialReceiptItem (final Product itemProduct, final Short itemProductQuantity, final BillableReceipt itemReceipt) { // Call other constructor this(); // Set all values + this.itemCategory = itemProduct.getProductCategory(); this.itemProduct = itemProduct; this.itemProductQuantity = itemProductQuantity; this.itemReceipt = itemReceipt; @@ -158,6 +186,16 @@ public class FinancialReceiptItem implements BillableReceiptItem { return true; } + @Override + public Category getItemCategory () { + return this.itemCategory; + } + + @Override + public void setItemCategory (final Category itemCategory) { + this.itemCategory = itemCategory; + } + @Override @SuppressWarnings ("ReturnOfDateField") public Date getItemCreated () { @@ -170,6 +208,16 @@ public class FinancialReceiptItem implements BillableReceiptItem { this.itemCreated = itemCreated; } + @Override + public Float getItemGrossPrice () { + return this.itemGrossPrice; + } + + @Override + public void setItemGrossPrice (final Float itemGrossPrice) { + this.itemGrossPrice = itemGrossPrice; + } + @Override public Long getItemId () { return this.itemId; @@ -180,6 +228,16 @@ public class FinancialReceiptItem implements BillableReceiptItem { this.itemId = itemId; } + @Override + public Float getItemNetPrice () { + return this.itemNetPrice; + } + + @Override + public void setItemNetPrice (final Float itemNetPrice) { + this.itemNetPrice = itemNetPrice; + } + @Override public Product getItemProduct () { return this.itemProduct; @@ -201,12 +259,12 @@ public class FinancialReceiptItem implements BillableReceiptItem { } @Override - public Long getItemProductQuantity () { + public Short getItemProductQuantity () { return this.itemProductQuantity; } @Override - public void setItemProductQuantity (final Long itemProductQuantity) { + public void setItemProductQuantity (final Short itemProductQuantity) { this.itemProductQuantity = itemProductQuantity; } @@ -220,6 +278,16 @@ public class FinancialReceiptItem implements BillableReceiptItem { this.itemReceipt = itemReceipt; } + @Override + public Float getItemTaxRate () { + return this.itemTaxRate; + } + + @Override + public void setItemTaxRate (final Float itemTaxRate) { + this.itemTaxRate = itemTaxRate; + } + @Override public int hashCode () { int hash = 5;