From: Roland Häder Date: Sat, 28 Oct 2017 17:18:08 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a4b757657ce48a6f3e9c2b454613e9cb1d66418f;p=jbonuscard-core.git Continued: - renamed itemProductDiscount -> itemDiscountPercent as this is a percentage discount on the item - added fixed discount, like 1 EUR as some receipt items had this discount 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 ab81a12..b6dc9c2 100644 --- a/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java +++ b/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java @@ -100,18 +100,32 @@ public interface BillableReceiptItem extends Serializable { void setItemProduct (final Product itemProduct); /** - * Getter for product discount + * Getter for product discount as fixed value *

- * @return Product discount + * @return Product discount as fixed value */ - Float getItemProductDiscount (); + Float getItemDiscountFixed (); /** - * Setter for product discount + * Setter for product discount as fixed value *

- * @param productDiscount Product discount + * @param itemDiscountFixed Product discount as fixed value */ - void setItemProductDiscount (final Float productDiscount); + void setItemDiscountFixed (final Float itemDiscountFixed); + + /** + * Getter for product discount in percents + *

+ * @return Product discount in percents + */ + Float getItemDiscountPercent (); + + /** + * Setter for product discount in percents + *

+ * @param itemDiscountPercent Product discount in percents + */ + void setItemDiscountPercent (final Float itemDiscountPercent); /** * Getter for product quantity diff --git a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java index d3a9105..596c9a0 100644 --- a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java +++ b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java @@ -53,11 +53,11 @@ import org.mxchange.jproduct.model.product.Product; @Index (name = "item_receipt_product", columnList = "item_receipt_id,item_product_id", unique = true) } ) -@NamedQueries( +@NamedQueries ( { - @NamedQuery(name = "AllReceiptItems", query = "SELECT ri FROM receipt_items AS ri ORDER BY ri.itemId ASC"), - @NamedQuery(name = "SearchAssignedReceiptItems", query = "SELECT ri FROM receipt_items AS ri WHERE ri.itemReceipt = :itemReceipt ORDER BY ri.itemId ASC"), - @NamedQuery(name = "SearchAllUserReceiptItems", query = "SELECT ri FROM receipt_items AS ri JOIN receipts AS r ON ri.itemReceipt=r WHERE r.receiptUser = :receiptUser ORDER BY ri.itemId ASC") + @NamedQuery (name = "AllReceiptItems", query = "SELECT ri FROM receipt_items AS ri ORDER BY ri.itemId ASC"), + @NamedQuery (name = "SearchAssignedReceiptItems", query = "SELECT ri FROM receipt_items AS ri WHERE ri.itemReceipt = :itemReceipt ORDER BY ri.itemId ASC"), + @NamedQuery (name = "SearchAllUserReceiptItems", query = "SELECT ri FROM receipt_items AS ri JOIN receipts AS r ON ri.itemReceipt=r WHERE r.receiptUser = :receiptUser ORDER BY ri.itemId ASC") } ) @SuppressWarnings ("PersistenceUnitPresent") @@ -72,8 +72,8 @@ public class FinancialReceiptItem implements BillableReceiptItem { /** * 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) + @JoinColumn (name = "item_category_id", referencedColumnName = "category_id", updatable = false) + @OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.REFRESH, optional = false) private Category itemCategory; /** @@ -85,43 +85,43 @@ public class FinancialReceiptItem implements BillableReceiptItem { private Date itemCreated; /** - * Primary key + * Fixed discount on item */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "item_id", nullable = false, updatable = false) - private Long itemId; + @Column (name = "item_discount_fixed") + private Float itemDiscountFixed; /** - * Product being linked in this itemReceipt item + * Percentage discount on item */ - @JoinColumn (name = "item_product_id", referencedColumnName = "product_id", nullable = false, updatable = false) - @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.REFRESH, optional = false) - private Product itemProduct; + @Column (name = "item_discount_percent") + private Float itemDiscountPercent; /** - * Discount on item + * Gross price of item */ - @Column (name = "item_product_discount") - private Float itemProductDiscount; + @Column (name = "item_gross_price") + private Float itemGrossPrice; /** - * Net price of item + * Primary key */ - @Column (name = "item_net_price") - private Float itemNetPrice; + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "item_id", nullable = false, updatable = false) + private Long itemId; /** - * Gross price of item + * Net price of item */ - @Column (name = "item_gross_price") - private Float itemGrossPrice; + @Column (name = "item_net_price") + private Float itemNetPrice; /** - * Tax rate + * Product being linked in this itemReceipt item */ - @Column (name = "item_tax_rate") - private Float itemTaxRate; + @JoinColumn (name = "item_product_id", referencedColumnName = "product_id", nullable = false, updatable = false) + @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.REFRESH, optional = false) + private Product itemProduct; /** * Product quantity @@ -137,6 +137,12 @@ public class FinancialReceiptItem implements BillableReceiptItem { @OneToOne (targetEntity = FinancialReceipt.class, cascade = CascadeType.REFRESH, optional = false) private BillableReceipt itemReceipt; + /** + * Tax rate + */ + @Column (name = "item_tax_rate") + private Float itemTaxRate; + /** * Default constructor */ @@ -208,6 +214,26 @@ public class FinancialReceiptItem implements BillableReceiptItem { this.itemCreated = itemCreated; } + @Override + public Float getItemDiscountFixed () { + return this.itemDiscountFixed; + } + + @Override + public void setItemDiscountFixed (final Float itemDiscountFixed) { + this.itemDiscountFixed = itemDiscountFixed; + } + + @Override + public Float getItemDiscountPercent () { + return this.itemDiscountPercent; + } + + @Override + public void setItemDiscountPercent (final Float itemDiscountPercent) { + this.itemDiscountPercent = itemDiscountPercent; + } + @Override public Float getItemGrossPrice () { return this.itemGrossPrice; @@ -248,16 +274,6 @@ public class FinancialReceiptItem implements BillableReceiptItem { this.itemProduct = itemProduct; } - @Override - public Float getItemProductDiscount () { - return this.itemProductDiscount; - } - - @Override - public void setItemProductDiscount (final Float itemProductDiscount) { - this.itemProductDiscount = itemProductDiscount; - } - @Override public Short getItemProductQuantity () { return this.itemProductQuantity;