]> git.mxchange.org Git - jfinancials-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 26 Oct 2017 19:17:50 +0000 (21:17 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 26 Oct 2017 19:17:50 +0000 (21:17 +0200)
- 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 <roland@mxchange.org>
src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java
src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java

index a6cd297d975ae9a9771d41732c2c01b0da14e5bb..ab81a12108a170495f7e3f8d7c87f28872ff71fc 100644 (file)
@@ -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
+        * <p>
+        * @return Item's product category
+        */
+       Category getItemCategory ();
+
+       /**
+        * Setter for item's product category
+        * <p>
+        * @param itemCategory Item's product category
+        */
+       void setItemCategory (final Category itemCategory);
+
        /**
         * Getter when this receipt item has been created in database
         * <p>
@@ -103,14 +118,56 @@ public interface BillableReceiptItem extends Serializable {
         * <p>
         * @return Product quantity
         */
-       Long getItemProductQuantity ();
+       Short getItemProductQuantity ();
 
        /**
         * Setter for product quantity
         * <p>
         * @param itemProductQuantity Product quantity
         */
-       void setItemProductQuantity (final Long itemProductQuantity);
+       void setItemProductQuantity (final Short itemProductQuantity);
+
+       /**
+        * Getter for item's net price
+        * <p>
+        * @return Item's net price
+        */
+       Float getItemNetPrice ();
+
+       /**
+        * Setter for item's net price
+        * <p>
+        * @param itemNetPrice Item's net price
+        */
+       void setItemNetPrice (final Float itemNetPrice);
+
+       /**
+        * Getter for item's tax rate
+        * <p>
+        * @return Item's tax rate
+        */
+       Float getItemTaxRate ();
+
+       /**
+        * Setter for item's tax rate
+        * <p>
+        * @param itemTaxRate Item's tax rate
+        */
+       void setItemTaxRate (final Float itemTaxRate);
+
+       /**
+        * Getter for item's gross price
+        * <p>
+        * @return Item's gross price
+        */
+       Float getItemGrossPrice ();
+
+       /**
+        * Setter for item's gross price
+        * <p>
+        * @param itemGrossPrice Item's gross price
+        */
+       void setItemGrossPrice (final Float itemGrossPrice);
 
        @Override
        boolean equals (final Object object);
index fa86c3f9bb5eb0490b70d020bc01a2b55574f5ed..d3a91054b9baa49f4267584f37c84dd35e15d246 100644 (file)
@@ -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;