From: Roland Häder Date: Thu, 23 Apr 2020 07:51:20 +0000 (+0200) Subject: Initialized jbonuscard-core based on jfinancials-core X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e643ec647b1ffc4a8eebceafd1cd12bdd3c961f0;p=jbonuscard-core.git Initialized jbonuscard-core based on jfinancials-core Signed-off-by: Roland Häder --- diff --git a/build.xml b/build.xml index 32ac333..308070b 100644 --- a/build.xml +++ b/build.xml @@ -7,8 +7,8 @@ - - Builds, tests, and runs the project jfinancials-core. + + Builds, tests, and runs the project jbonuscard-core. - + @@ -474,7 +474,7 @@ is divided into following sections: - + @@ -625,7 +625,7 @@ is divided into following sections: - + @@ -917,7 +917,7 @@ is divided into following sections: - + @@ -1402,7 +1402,7 @@ is divided into following sections: - + diff --git a/nbproject/project.properties b/nbproject/project.properties index a6af727..bc3a194 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=true annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=jfinancials-core +application.title=jbonuscard-core application.vendor=Roland H\u00e4der auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml build.classes.dir=${build.dir}/classes @@ -26,34 +26,25 @@ debug.test.classpath=\ dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist -dist.jar=${dist.dir}/jfinancials-core.jar +dist.jar=${dist.dir}/jbonuscard-core.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar file.reference.jcontacts-core.jar=lib/jcontacts-core.jar file.reference.jcore-utils.jar=lib/jcore-utils.jar -file.reference.jcountry-core.jar=lib/jcountry-core.jar file.reference.jcustomer-core.jar=lib/jcustomer-core.jar -file.reference.jphone-core.jar=lib/jphone-core.jar -file.reference.jproduct-core.jar=lib/jproduct-core.jar -file.reference.juser-core.jar=lib/juser-core.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=false jar.index=${jnlp.enabled} javac.classpath=\ - ${file.reference.jcountry-core.jar}:\ - ${file.reference.jphone-core.jar}:\ - ${file.reference.juser-core.jar}:\ ${file.reference.jcontacts-core.jar}:\ ${file.reference.jcontacts-business-core.jar}:\ ${file.reference.jcustomer-core.jar}:\ - ${file.reference.jproduct-core.jar}:\ ${file.reference.jcore-utils.jar}:\ ${libs.commons-lang3.classpath}:\ - ${libs.jpa20-persistence.classpath}:\ - ${libs.javaee-api-7.0.classpath} + ${libs.jpa20-persistence.classpath} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.deprecation=true @@ -74,10 +65,14 @@ javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=true +javadoc.reference.jcontacts-business-core.jar=https://docs.mxchange.org/javadoc/jcontacts-business-core/ +javadoc.reference.jcontacts-core.jar=https://docs.mxchange.org/javadoc/jcontacts-core/ +javadoc.reference.jcore-utils.jar=https://docs.mxchange.org/javadoc/jcore-utils/ +javadoc.reference.jcustomer-core.jar=https://docs.mxchange.org/javadoc/jcustomer-core/ javadoc.splitindex=true javadoc.use=true javadoc.version=true -javadoc.windowtitle=JFinancials Core Library +javadoc.windowtitle=JBonusCard Core Library jnlp.codebase.type=no.codebase jnlp.descriptor=application jnlp.enabled=false @@ -113,10 +108,6 @@ source.encoding=UTF-8 source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/ source.reference.jcontacts-core.jar=../jcontacts-core/src/ source.reference.jcore-utils.jar=../jcore-utils/src/ -source.reference.jcountry-core.jar=../jcountry-core/src/ source.reference.jcustomer-core.jar=../jcustomer-core/src/ -source.reference.jphone-core.jar=../jphone-core/src/ -source.reference.jproduct-core.jar=../jproduct-core/src/ -source.reference.juser-core.jar=../juser-core/src/ src.dir=src test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index 88a8f82..a095a27 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -3,7 +3,7 @@ org.netbeans.modules.java.j2seproject - jfinancials-core + jbonuscard-core diff --git a/src/org/mxchange/jbonuscard/model/bonus_card/BonusCard.java b/src/org/mxchange/jbonuscard/model/bonus_card/BonusCard.java new file mode 100644 index 0000000..9a0cfee --- /dev/null +++ b/src/org/mxchange/jbonuscard/model/bonus_card/BonusCard.java @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jbonuscard.model.bonus_card; + +import java.io.Serializable; +import java.util.Date; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; +import org.mxchange.jcustomercore.model.customer.Customer; + +/** + * A POJI for bonus cards + *

+ * @author Roland Häder + */ +public interface BonusCard extends Comparable, Serializable { + + /** + * Getter for bonus card's bar code + *

+ * @return Bonus card's bar code + */ + String getBonusCardBarCode (); + + /** + * Setter for bonus card's bar code + *

+ * @param bonusCardBarCode Bonus card's bar code + */ + void setBonusCardBarCode (final String bonusCardBarCode); + + /** + * Getter for bonus card's contact data + *

+ * @return Bonus card's contact data + */ + Contact getBonusCardContact (); + + /** + * Setter for bonus card's contact data + *

+ * @param bonusCardContact Bonus card's contact data + */ + void setBonusCardContact (final Contact bonusCardContact); + + /** + * Getter for bonus card's creation timestamp + *

+ * @return Bonus card's creation timestamp + */ + Date getBonusCardCreated (); + + /** + * Setter for bonus card's creation timestamp + *

+ * @param bonusCardCreated Bonus card's creation timestamp + */ + void setBonusCardCreated (final Date bonusCardCreated); + + /** + * Getter for bonus card's customer data + *

+ * @return Bonus card's customer data + */ + Customer getBonusCardCustomer (); + + /** + * Setter for bonus card's customer data + *

+ * @param bonusCardCustomer Bonus card's customer data + */ + void setBonusCardCustomer (final Customer bonusCardCustomer); + + /** + * Getter for bonus card's primary key + *

+ * @return Bonus card's primary key + */ + Long getBonusCardId (); + + /** + * Setter for bonus card's primary key + *

+ * @param bonusCardId Bonus card's primary key + */ + void setBonusCardId (final Long bonusCardId); + + /** + * Getter for bonus card's issuing company + *

+ * @return Bonus card's issuing company + */ + BasicData getBonusCardIssuer (); + + /** + * Setter for bonus card's issuing company + *

+ * @param bonusCardIssuer Bonus card's issuing company + */ + void setBonusCardIssuer (final BasicData bonusCardIssuer); + + /** + * Getter for bonus card's number (other than customer/bar code) + *

+ * @return Bonus card's number + */ + String getBonusCardNumber (); + + /** + * Setter for bonus card's number (other than customer/bar code) + *

+ * @param bonusCardNumber Bonus card's number + */ + void setBonusCardNumber (final String bonusCardNumber); + + /** + * Getter for bonus card's partnering/branding company + *

+ * @return Bonus card's partnering/branding company + */ + BasicData getBonusCardPartner (); + + /** + * Setter for bonus card's partnering/branding company + *

+ * @param bonusCardPartner Bonus card's partnering/branding company + */ + void setBonusCardPartner (final BasicData bonusCardPartner); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); + +} diff --git a/src/org/mxchange/jbonuscard/model/bonus_card/RoyalityCard.java b/src/org/mxchange/jbonuscard/model/bonus_card/RoyalityCard.java new file mode 100644 index 0000000..ea9e6e0 --- /dev/null +++ b/src/org/mxchange/jbonuscard/model/bonus_card/RoyalityCard.java @@ -0,0 +1,326 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jbonuscard.model.bonus_card; + +import java.text.MessageFormat; +import java.util.Date; +import java.util.Objects; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import org.apache.commons.lang3.StringUtils; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontacts.model.contact.Contacts; +import org.mxchange.jcontacts.model.contact.UserContact; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicDataUtils; +import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; +import org.mxchange.jcoreutils.Comparables; +import org.mxchange.jcustomercore.model.customer.ContactCustomer; +import org.mxchange.jcustomercore.model.customer.Customer; +import org.mxchange.jcustomercore.model.customer.Customers; + +/** + * A POJO (entity) for bonus cards + *

+ * @author Roland Häder + */ +@Entity (name = "bonus_cards") +@Table ( + name = "bonus_cards" +) +@SuppressWarnings ("PersistenceUnitPresent") +public class RoyalityCard implements BonusCard { + + /** + * Serial number + */ + @Transient + private static final long serialVersionUID = 12_586_367_165_980L; + + /** + * Bar code on bonus card + */ + @Column (name = "bonus_card_bar_code") + private String bonusCardBarCode; + + /** + * The contact that this card is assigned to + */ + @JoinColumn (name = "bonus_card_contact_id", referencedColumnName = "contact_id", nullable = false) + @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH, optional = false) + private Contact bonusCardContact; + + /** + * When this entry has been created + */ + @Basic (optional = false) + @Column (name = "bonus_card_created", nullable = false) + @Temporal (TemporalType.TIMESTAMP) + private Date bonusCardCreated; + + /** + * Bonus card customer id + */ + @JoinColumn (name = "bonus_card_customer_id", referencedColumnName = "customer_id") + @OneToOne (targetEntity = ContactCustomer.class, cascade = CascadeType.REFRESH) + private Customer bonusCardCustomer; + + /** + * Id number + */ + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "bonus_card_id", nullable = false, updatable = false) + private Long bonusCardId; + + /** + * Issuing company of this card + */ + @JoinColumn (name = "bonus_card_issuer_id", referencedColumnName = "company_data_id", nullable = false) + @OneToOne (targetEntity = BusinessBasicData.class, cascade = CascadeType.REFRESH, optional = false) + private BasicData bonusCardIssuer; + + /** + * Bonus card number + */ + @Column (name = "bonus_card_number") + private String bonusCardNumber; + + /** + * Partnering/branding company of this card + */ + @JoinColumn (name = "bonus_card_partner_id", referencedColumnName = "company_data_id") + @OneToOne (targetEntity = BusinessBasicData.class, cascade = CascadeType.REFRESH) + private BasicData bonusCardPartner; + + /** + * Default constructor (required for JPA) + */ + public RoyalityCard () { + } + + /** + * Constructor with all required fields + *

+ * @param bonusCardContact Contact instance + * @param bonusCardIssuer Issuing company instance + */ + public RoyalityCard (final Contact bonusCardContact, final BasicData bonusCardIssuer) { + // Call other constructor first + this(); + + // Validate parameter + if (null == bonusCardContact) { + // Throw NPE + throw new NullPointerException("bonusCardContact is null"); //NOI18N + } else if (bonusCardContact.getContactId() == null) { + // Throw it again + throw new NullPointerException("bonusCardContact.contactId is null"); //NOI18N + } else if (bonusCardContact.getContactId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("bonusCardContact.contactId={0} is invalid", bonusCardContact.getContactId())); //NOI18N + } else if (null == bonusCardIssuer) { + // Throw NPE + throw new NullPointerException("bonusCardOwner is null"); //NOI18N + } else if (bonusCardIssuer.getBasicDataId() == null) { + // Throw it again + throw new NullPointerException("bonusCardOwner.baseDataId is null"); //NOI18N + } else if (bonusCardIssuer.getBasicDataId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("bonusCardOwner.baseDataId={0} is invalid", bonusCardIssuer.getBasicDataId())); //NOI18N + } + + // Set all + this.bonusCardContact = bonusCardContact; + this.bonusCardIssuer = bonusCardIssuer; + } + + @Override + public int compareTo (final BonusCard bonusCard) { + // Check parameter on null-reference and equality to this + if (null == bonusCard) { + // Should not happen + throw new NullPointerException("bonusCard is null"); //NOI18N + } else if (bonusCard.equals(this)) { + // Same object + return 0; + } + + // Init comparators + final int comparators[] = { + // First compare by number + StringUtils.compare(this.getBonusCardNumber(), bonusCard.getBonusCardNumber()), + // ... next by bar code + StringUtils.compare(this.getBonusCardBarCode(), bonusCard.getBonusCardBarCode()), + // ... customer data + Customers.compare(this.getBonusCardCustomer(), bonusCard.getBonusCardCustomer()), + // ... contact data (card holder) + Contacts.compare(this.getBonusCardContact(), bonusCard.getBonusCardContact()), + // ... issuing company data + this.getBonusCardIssuer().compareTo(bonusCard.getBonusCardIssuer()), + // ... partner company data + BasicDataUtils.compare(this.getBonusCardPartner(), bonusCard.getBonusCardPartner()) + }; + + // Check all values + final int comparison = Comparables.checkAll(comparators); + + // Return value + return comparison; + } + + @Override + public boolean equals (final Object object) { + if (this == object) { + return true; + } else if (null == object) { + return false; + } + if (this.getClass() != object.getClass()) { + return false; + } + + final BonusCard other = (BonusCard) object; + + if (!Objects.equals(this.getBonusCardBarCode(), other.getBonusCardBarCode())) { + return false; + } else if (!Objects.equals(this.getBonusCardContact(), other.getBonusCardContact())) { + return false; + } else if (!Objects.equals(this.getBonusCardCustomer(), other.getBonusCardCustomer())) { + return false; + } else if (!Objects.equals(this.getBonusCardId(), other.getBonusCardId())) { + return false; + } else if (!Objects.equals(this.getBonusCardIssuer(), other.getBonusCardIssuer())) { + return false; + } else if (!Objects.equals(this.getBonusCardNumber(), other.getBonusCardNumber())) { + return false; + } else if (!Objects.equals(this.getBonusCardPartner(), other.getBonusCardPartner())) { + return false; + } + + return true; + } + + @Override + public String getBonusCardBarCode () { + return this.bonusCardBarCode; + } + + @Override + public void setBonusCardBarCode (final String bonusCardBarCode) { + this.bonusCardBarCode = bonusCardBarCode; + } + + @Override + public Contact getBonusCardContact () { + return this.bonusCardContact; + } + + @Override + public void setBonusCardContact (final Contact bonusCardContact) { + this.bonusCardContact = bonusCardContact; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Date getBonusCardCreated () { + return this.bonusCardCreated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setBonusCardCreated (final Date bonusCardCreated) { + this.bonusCardCreated = bonusCardCreated; + } + + @Override + public Customer getBonusCardCustomer () { + return this.bonusCardCustomer; + } + + @Override + public void setBonusCardCustomer (final Customer bonusCardCustomer) { + this.bonusCardCustomer = bonusCardCustomer; + } + + @Override + public Long getBonusCardId () { + return this.bonusCardId; + } + + @Override + public void setBonusCardId (final Long bonusCardId) { + this.bonusCardId = bonusCardId; + } + + @Override + public BasicData getBonusCardIssuer () { + return this.bonusCardIssuer; + } + + @Override + public void setBonusCardIssuer (final BasicData bonusCardIssuer) { + this.bonusCardIssuer = bonusCardIssuer; + } + + @Override + public String getBonusCardNumber () { + return this.bonusCardNumber; + } + + @Override + public void setBonusCardNumber (final String bonusCardNumber) { + this.bonusCardNumber = bonusCardNumber; + } + + @Override + public BasicData getBonusCardPartner () { + return this.bonusCardPartner; + } + + @Override + public void setBonusCardPartner (final BasicData bonusCardPartner) { + this.bonusCardPartner = bonusCardPartner; + } + + @Override + public int hashCode () { + int hash = 5; + + hash = 13 * hash + Objects.hashCode(this.getBonusCardBarCode()); + hash = 13 * hash + Objects.hashCode(this.getBonusCardContact()); + hash = 13 * hash + Objects.hashCode(this.getBonusCardCustomer()); + hash = 13 * hash + Objects.hashCode(this.getBonusCardId()); + hash = 13 * hash + Objects.hashCode(this.getBonusCardIssuer()); + hash = 13 * hash + Objects.hashCode(this.getBonusCardNumber()); + hash = 13 * hash + Objects.hashCode(this.getBonusCardPartner()); + + return hash; + } + +} diff --git a/src/org/mxchange/jfinancials/events/receipt/added/ObservableReceiptAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt/added/ObservableReceiptAddedEvent.java deleted file mode 100644 index 4b4cbc3..0000000 --- a/src/org/mxchange/jfinancials/events/receipt/added/ObservableReceiptAddedEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.events.receipt.added; - -import java.io.Serializable; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; - -/** - * An interface for events being fired when a receipt instance has been added. - *

- * @author Roland Häder - */ -public interface ObservableReceiptAddedEvent extends Serializable { - - /** - * Getter for receipt instance - *

- * @return Receipt instance - */ - BillableReceipt getReceipt (); - -} diff --git a/src/org/mxchange/jfinancials/events/receipt/added/ReceiptAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt/added/ReceiptAddedEvent.java deleted file mode 100644 index 4b1131c..0000000 --- a/src/org/mxchange/jfinancials/events/receipt/added/ReceiptAddedEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.events.receipt.added; - -import java.text.MessageFormat; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; - -/** - * An event being fired when a new receipt has been added - *

- * @author Roland Haeder - */ -public class ReceiptAddedEvent implements ObservableReceiptAddedEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 157_582_667_163_547L; - - /** - * New receipt instance being added - */ - private final BillableReceipt receipt; - - /** - * Constructor with receipt instance - *

- * @param receipt Receipt instance - */ - public ReceiptAddedEvent (final BillableReceipt receipt) { - // Validate parameter - if (null == receipt) { - // Throw NPE - throw new NullPointerException("receipt is null"); - } else if (receipt.getReceiptId() == null) { - // Throw NPE again - throw new NullPointerException("receipt.receiptId is null"); - } else if (receipt.getReceiptId() < 1) { - // Throw NPE again - throw new NullPointerException(MessageFormat.format("receipt.receiptId={0} is not valid", receipt.getReceiptId())); - } - - // Set it here - this.receipt = receipt; - } - - @Override - public BillableReceipt getReceipt () { - return this.receipt; - } - -} diff --git a/src/org/mxchange/jfinancials/events/receipt/updated/ObservableReceiptUpdatedEvent.java b/src/org/mxchange/jfinancials/events/receipt/updated/ObservableReceiptUpdatedEvent.java deleted file mode 100644 index 26fd541..0000000 --- a/src/org/mxchange/jfinancials/events/receipt/updated/ObservableReceiptUpdatedEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.events.receipt.updated; - -import java.io.Serializable; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; - -/** - * An interface for events being fired when a receipt instance has been added. - *

- * @author Roland Häder - */ -public interface ObservableReceiptUpdatedEvent extends Serializable { - - /** - * Getter for receipt instance - *

- * @return Receipt instance - */ - BillableReceipt getReceipt (); - -} diff --git a/src/org/mxchange/jfinancials/events/receipt/updated/ReceiptUpdatedEvent.java b/src/org/mxchange/jfinancials/events/receipt/updated/ReceiptUpdatedEvent.java deleted file mode 100644 index 66f7f2c..0000000 --- a/src/org/mxchange/jfinancials/events/receipt/updated/ReceiptUpdatedEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.events.receipt.updated; - -import java.text.MessageFormat; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; - -/** - * An event being fired when a new receipt has been added - *

- * @author Roland Haeder - */ -public class ReceiptUpdatedEvent implements ObservableReceiptUpdatedEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 157_582_667_163_548L; - - /** - * New receipt instance being added - */ - private final BillableReceipt receipt; - - /** - * Constructor with receipt instance - *

- * @param receipt Receipt instance - */ - public ReceiptUpdatedEvent (final BillableReceipt receipt) { - // Validate parameter - if (null == receipt) { - // Throw NPE - throw new NullPointerException("receipt is null"); - } else if (receipt.getReceiptId() == null) { - // Throw NPE again - throw new NullPointerException("receipt.receiptId is null"); - } else if (receipt.getReceiptId() < 1) { - // Throw NPE again - throw new NullPointerException(MessageFormat.format("receipt.receiptId={0} is not valid", receipt.getReceiptId())); - } - - // Set it here - this.receipt = receipt; - } - - @Override - public BillableReceipt getReceipt () { - return this.receipt; - } - -} diff --git a/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java deleted file mode 100644 index 0379ff7..0000000 --- a/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.events.receipt_item.added; - -import java.io.Serializable; -import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem; - -/** - * An interface for events being fired when a receipt item instance has been - * added. - *

- * @author Roland Häder - */ -public interface ObservableReceiptItemAddedEvent extends Serializable { - - /** - * Getter for receipt item instance - *

- * @return Receipt item instance - */ - BillableReceiptItem getReceiptItem (); - -} diff --git a/src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java deleted file mode 100644 index 04ce960..0000000 --- a/src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.events.receipt_item.added; - -import java.text.MessageFormat; -import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem; - -/** - * An event being fired when a new receipt item has been added - *

- * @author Roland Haeder - */ -public class ReceiptItemAddedEvent implements ObservableReceiptItemAddedEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 157_582_667_163_548L; - - /** - * New receipt item instance being added - */ - private final BillableReceiptItem receiptItem; - - /** - * Constructor with receipt instance - *

- * @param receiptItem Receipt instance - */ - public ReceiptItemAddedEvent (final BillableReceiptItem receiptItem) { - // Validate parameter - if (null == receiptItem) { - // Throw NPE - throw new NullPointerException("receiptItem is null"); - } else if (receiptItem.getItemId() == null) { - // Throw NPE again - throw new NullPointerException("receiptItem.itemId is null"); - } else if (receiptItem.getItemId() < 1) { - // Throw NPE again - throw new NullPointerException(MessageFormat.format("receiptItem.itemId={0} is not valid", receiptItem.getItemId())); - } - - // Set it here - this.receiptItem = receiptItem; - } - - @Override - public BillableReceiptItem getReceiptItem () { - return this.receiptItem; - } - -} diff --git a/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptAlreadyAddedException.java b/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptAlreadyAddedException.java deleted file mode 100644 index 7f82c9c..0000000 --- a/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptAlreadyAddedException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.exceptions.receipt; - -import java.text.MessageFormat; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; - -/** - * This exception is thrown when a receipt was already added - *

- * @author Roland Häder - */ -public class ReceiptAlreadyAddedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 19_065_867_127_647_624L; - - /** - * Default constructor - */ - public ReceiptAlreadyAddedException () { - super(); - } - - /** - * Constructor with receipt instance - *

- * @param receipt Receipt instance - */ - public ReceiptAlreadyAddedException (final BillableReceipt receipt) { - // Call super constructor - super(MessageFormat.format("Receipt with id {0} and number {1} has already been added.", receipt.getReceiptId(), receipt.getReceiptNumber())); - } - -} diff --git a/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptNotFoundException.java b/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptNotFoundException.java deleted file mode 100644 index 3881c65..0000000 --- a/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptNotFoundException.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.exceptions.receipt; - -import java.text.MessageFormat; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; - -/** - * This exception is thrown when a receipt was not found. - *

- * @author Roland Häder - */ -public class ReceiptNotFoundException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 19_065_867_127_647_625L; - - /** - * Default constructor - */ - public ReceiptNotFoundException () { - super(); - } - - /** - * Constructor with receipt primary key - *

- * @param receiptId Receipt primary key - */ - public ReceiptNotFoundException (final Long receiptId) { - // Call super constructor - super(MessageFormat.format("Receipt with id {0} was not found.", receiptId)); - } - - /** - * Constructor with receipt instance - *

- * @param receipt Receipt instance - */ - public ReceiptNotFoundException (final BillableReceipt receipt) { - // Invoke other contructor - this(receipt.getReceiptId()); - } - -} diff --git a/src/org/mxchange/jfinancials/exceptions/receipt_item/ReceiptItemAlreadyAddedException.java b/src/org/mxchange/jfinancials/exceptions/receipt_item/ReceiptItemAlreadyAddedException.java deleted file mode 100644 index 924b468..0000000 --- a/src/org/mxchange/jfinancials/exceptions/receipt_item/ReceiptItemAlreadyAddedException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.exceptions.receipt_item; - -import java.text.MessageFormat; -import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem; - -/** - * This exception is thrown when a receipt item was already added - *

- * @author Roland Häder - */ -public class ReceiptItemAlreadyAddedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 19_065_867_127_647_625L; - - /** - * Default constructor - */ - public ReceiptItemAlreadyAddedException () { - super(); - } - - /** - * Constructor with receipt item instance - *

- * @param receiptItem Receipt item instance - */ - public ReceiptItemAlreadyAddedException (final BillableReceiptItem receiptItem) { - // Call super constructor - super(MessageFormat.format("Receipt item with id {0} has already been added.", receiptItem.getItemId())); - } - -} diff --git a/src/org/mxchange/jfinancials/model/bonus_card/BonusCard.java b/src/org/mxchange/jfinancials/model/bonus_card/BonusCard.java deleted file mode 100644 index 785bd24..0000000 --- a/src/org/mxchange/jfinancials/model/bonus_card/BonusCard.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.bonus_card; - -import java.io.Serializable; -import java.util.Date; -import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcustomercore.model.customer.Customer; - -/** - * A POJI for bonus cards - *

- * @author Roland Häder - */ -public interface BonusCard extends Comparable, Serializable { - - /** - * Getter for bonus card's bar code - *

- * @return Bonus card's bar code - */ - String getBonusCardBarCode (); - - /** - * Setter for bonus card's bar code - *

- * @param bonusCardBarCode Bonus card's bar code - */ - void setBonusCardBarCode (final String bonusCardBarCode); - - /** - * Getter for bonus card's contact data - *

- * @return Bonus card's contact data - */ - Contact getBonusCardContact (); - - /** - * Setter for bonus card's contact data - *

- * @param bonusCardContact Bonus card's contact data - */ - void setBonusCardContact (final Contact bonusCardContact); - - /** - * Getter for bonus card's creation timestamp - *

- * @return Bonus card's creation timestamp - */ - Date getBonusCardCreated (); - - /** - * Setter for bonus card's creation timestamp - *

- * @param bonusCardCreated Bonus card's creation timestamp - */ - void setBonusCardCreated (final Date bonusCardCreated); - - /** - * Getter for bonus card's customer data - *

- * @return Bonus card's customer data - */ - Customer getBonusCardCustomer (); - - /** - * Setter for bonus card's customer data - *

- * @param bonusCardCustomer Bonus card's customer data - */ - void setBonusCardCustomer (final Customer bonusCardCustomer); - - /** - * Getter for bonus card's primary key - *

- * @return Bonus card's primary key - */ - Long getBonusCardId (); - - /** - * Setter for bonus card's primary key - *

- * @param bonusCardId Bonus card's primary key - */ - void setBonusCardId (final Long bonusCardId); - - /** - * Getter for bonus card's issuing company - *

- * @return Bonus card's issuing company - */ - BasicData getBonusCardIssuer (); - - /** - * Setter for bonus card's issuing company - *

- * @param bonusCardIssuer Bonus card's issuing company - */ - void setBonusCardIssuer (final BasicData bonusCardIssuer); - - /** - * Getter for bonus card's number (other than customer/bar code) - *

- * @return Bonus card's number - */ - String getBonusCardNumber (); - - /** - * Setter for bonus card's number (other than customer/bar code) - *

- * @param bonusCardNumber Bonus card's number - */ - void setBonusCardNumber (final String bonusCardNumber); - - /** - * Getter for bonus card's partnering/branding company - *

- * @return Bonus card's partnering/branding company - */ - BasicData getBonusCardPartner (); - - /** - * Setter for bonus card's partnering/branding company - *

- * @param bonusCardPartner Bonus card's partnering/branding company - */ - void setBonusCardPartner (final BasicData bonusCardPartner); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jfinancials/model/bonus_card/FinancialBonusCard.java b/src/org/mxchange/jfinancials/model/bonus_card/FinancialBonusCard.java deleted file mode 100644 index a1b0a9f..0000000 --- a/src/org/mxchange/jfinancials/model/bonus_card/FinancialBonusCard.java +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.bonus_card; - -import java.text.MessageFormat; -import java.util.Date; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.apache.commons.lang3.StringUtils; -import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jcontacts.model.contact.Contacts; -import org.mxchange.jcontacts.model.contact.UserContact; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicDataUtils; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; -import org.mxchange.jcoreutils.Comparables; -import org.mxchange.jcustomercore.model.customer.ContactCustomer; -import org.mxchange.jcustomercore.model.customer.Customer; -import org.mxchange.jcustomercore.model.customer.Customers; - -/** - * A POJO (entity) for bonus cards - *

- * @author Roland Häder - */ -@Entity (name = "bonus_cards") -@Table ( - name = "bonus_cards" -) -@SuppressWarnings ("PersistenceUnitPresent") -public class FinancialBonusCard implements BonusCard { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 12_586_367_165_980L; - - /** - * Bar code on bonus card - */ - @Column (name = "bonus_card_bar_code") - private String bonusCardBarCode; - - /** - * The contact that this card is assigned to - */ - @JoinColumn (name = "bonus_card_contact_id", referencedColumnName = "contact_id", nullable = false) - @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH, optional = false) - private Contact bonusCardContact; - - /** - * When this entry has been created - */ - @Basic (optional = false) - @Column (name = "bonus_card_created", nullable = false) - @Temporal (TemporalType.TIMESTAMP) - private Date bonusCardCreated; - - /** - * Bonus card customer id - */ - @JoinColumn (name = "bonus_card_customer_id", referencedColumnName = "customer_id") - @OneToOne (targetEntity = ContactCustomer.class, cascade = CascadeType.REFRESH) - private Customer bonusCardCustomer; - - /** - * Id number - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "bonus_card_id", nullable = false, updatable = false) - private Long bonusCardId; - - /** - * Issuing company of this card - */ - @JoinColumn (name = "bonus_card_issuer_id", referencedColumnName = "company_data_id", nullable = false) - @OneToOne (targetEntity = BusinessBasicData.class, cascade = CascadeType.REFRESH, optional = false) - private BasicData bonusCardIssuer; - - /** - * Bonus card number - */ - @Column (name = "bonus_card_number") - private String bonusCardNumber; - - /** - * Partnering/branding company of this card - */ - @JoinColumn (name = "bonus_card_partner_id", referencedColumnName = "company_data_id") - @OneToOne (targetEntity = BusinessBasicData.class, cascade = CascadeType.REFRESH) - private BasicData bonusCardPartner; - - /** - * Default constructor (required for JPA) - */ - public FinancialBonusCard () { - } - - /** - * Constructor with all required fields - *

- * @param bonusCardContact Contact instance - * @param bonusCardIssuer Issuing company instance - */ - public FinancialBonusCard (final Contact bonusCardContact, final BasicData bonusCardIssuer) { - // Call other constructor first - this(); - - // Validate parameter - if (null == bonusCardContact) { - // Throw NPE - throw new NullPointerException("bonusCardContact is null"); //NOI18N - } else if (bonusCardContact.getContactId() == null) { - // Throw it again - throw new NullPointerException("bonusCardContact.contactId is null"); //NOI18N - } else if (bonusCardContact.getContactId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("bonusCardContact.contactId={0} is invalid", bonusCardContact.getContactId())); //NOI18N - } else if (null == bonusCardIssuer) { - // Throw NPE - throw new NullPointerException("bonusCardOwner is null"); //NOI18N - } else if (bonusCardIssuer.getBasicDataId() == null) { - // Throw it again - throw new NullPointerException("bonusCardOwner.baseDataId is null"); //NOI18N - } else if (bonusCardIssuer.getBasicDataId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("bonusCardOwner.baseDataId={0} is invalid", bonusCardIssuer.getBasicDataId())); //NOI18N - } - - // Set all - this.bonusCardContact = bonusCardContact; - this.bonusCardIssuer = bonusCardIssuer; - } - - @Override - public int compareTo (final BonusCard bonusCard) { - // Check parameter on null-reference and equality to this - if (null == bonusCard) { - // Should not happen - throw new NullPointerException("bonusCard is null"); //NOI18N - } else if (bonusCard.equals(this)) { - // Same object - return 0; - } - - // Init comparators - final int comparators[] = { - // First compare by number - StringUtils.compare(this.getBonusCardNumber(), bonusCard.getBonusCardNumber()), - // ... next by bar code - StringUtils.compare(this.getBonusCardBarCode(), bonusCard.getBonusCardBarCode()), - // ... customer data - Customers.compare(this.getBonusCardCustomer(), bonusCard.getBonusCardCustomer()), - // ... contact data (card holder) - Contacts.compare(this.getBonusCardContact(), bonusCard.getBonusCardContact()), - // ... issuing company data - this.getBonusCardIssuer().compareTo(bonusCard.getBonusCardIssuer()), - // ... partner company data - BasicDataUtils.compare(this.getBonusCardPartner(), bonusCard.getBonusCardPartner()) - }; - - // Check all values - final int comparison = Comparables.checkAll(comparators); - - // Return value - return comparison; - } - - @Override - public boolean equals (final Object object) { - if (this == object) { - return true; - } else if (null == object) { - return false; - } - if (this.getClass() != object.getClass()) { - return false; - } - - final BonusCard other = (BonusCard) object; - - if (!Objects.equals(this.getBonusCardBarCode(), other.getBonusCardBarCode())) { - return false; - } else if (!Objects.equals(this.getBonusCardContact(), other.getBonusCardContact())) { - return false; - } else if (!Objects.equals(this.getBonusCardCustomer(), other.getBonusCardCustomer())) { - return false; - } else if (!Objects.equals(this.getBonusCardId(), other.getBonusCardId())) { - return false; - } else if (!Objects.equals(this.getBonusCardIssuer(), other.getBonusCardIssuer())) { - return false; - } else if (!Objects.equals(this.getBonusCardNumber(), other.getBonusCardNumber())) { - return false; - } else if (!Objects.equals(this.getBonusCardPartner(), other.getBonusCardPartner())) { - return false; - } - - return true; - } - - @Override - public String getBonusCardBarCode () { - return this.bonusCardBarCode; - } - - @Override - public void setBonusCardBarCode (final String bonusCardBarCode) { - this.bonusCardBarCode = bonusCardBarCode; - } - - @Override - public Contact getBonusCardContact () { - return this.bonusCardContact; - } - - @Override - public void setBonusCardContact (final Contact bonusCardContact) { - this.bonusCardContact = bonusCardContact; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getBonusCardCreated () { - return this.bonusCardCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setBonusCardCreated (final Date bonusCardCreated) { - this.bonusCardCreated = bonusCardCreated; - } - - @Override - public Customer getBonusCardCustomer () { - return this.bonusCardCustomer; - } - - @Override - public void setBonusCardCustomer (final Customer bonusCardCustomer) { - this.bonusCardCustomer = bonusCardCustomer; - } - - @Override - public Long getBonusCardId () { - return this.bonusCardId; - } - - @Override - public void setBonusCardId (final Long bonusCardId) { - this.bonusCardId = bonusCardId; - } - - @Override - public BasicData getBonusCardIssuer () { - return this.bonusCardIssuer; - } - - @Override - public void setBonusCardIssuer (final BasicData bonusCardIssuer) { - this.bonusCardIssuer = bonusCardIssuer; - } - - @Override - public String getBonusCardNumber () { - return this.bonusCardNumber; - } - - @Override - public void setBonusCardNumber (final String bonusCardNumber) { - this.bonusCardNumber = bonusCardNumber; - } - - @Override - public BasicData getBonusCardPartner () { - return this.bonusCardPartner; - } - - @Override - public void setBonusCardPartner (final BasicData bonusCardPartner) { - this.bonusCardPartner = bonusCardPartner; - } - - @Override - public int hashCode () { - int hash = 5; - - hash = 13 * hash + Objects.hashCode(this.getBonusCardBarCode()); - hash = 13 * hash + Objects.hashCode(this.getBonusCardContact()); - hash = 13 * hash + Objects.hashCode(this.getBonusCardCustomer()); - hash = 13 * hash + Objects.hashCode(this.getBonusCardId()); - hash = 13 * hash + Objects.hashCode(this.getBonusCardIssuer()); - hash = 13 * hash + Objects.hashCode(this.getBonusCardNumber()); - hash = 13 * hash + Objects.hashCode(this.getBonusCardPartner()); - - return hash; - } - -} diff --git a/src/org/mxchange/jfinancials/model/income/BillableIncome.java b/src/org/mxchange/jfinancials/model/income/BillableIncome.java deleted file mode 100644 index 397bcbc..0000000 --- a/src/org/mxchange/jfinancials/model/income/BillableIncome.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.income; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; -import org.mxchange.jfinancials.model.income.interval.FinancialInterval; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for billable income - *

- * @author Roland Häder - */ -public interface BillableIncome extends Comparable, Serializable { - - /** - * Getter for income id (primary key) - *

- * @return Income id (primary key) - */ - Long getIncomeId (); - - /** - * Setter for income id (primary key) - *

- * @param incomeId Income id (primary key) - */ - void setIncomeId (final Long incomeId); - - /** - * Getter for income-created timestamp - *

- * @return Income-created timestamp - */ - Date getIncomeCreated (); - - /** - * Setter for income-created timestamp - *

- * @param incomeCreated Income-created timestamp - */ - void setIncomeCreated (final Date incomeCreated); - - /** - * Getter for whether income is enabled - *

- * @return Whether income is enabled - */ - Boolean getIncomeEnabled (); - - /** - * Setter for whether income is enabled - *

- * @param incomeEnabled Whether income is enabled - */ - void setIncomeEnabled (final Boolean incomeEnabled); - - /** - * Getter for income interval - *

- * @return Income interval - */ - FinancialInterval getIncomeInterval (); - - /** - * Setter for income interval - *

- * @param incomeInterval Income interval - */ - void setIncomeInterval (final FinancialInterval incomeInterval); - - /** - * Getter for income single amount - *

- * @return Income single amount - */ - BigDecimal getIncomeSingleAmount (); - - /** - * Setter for income single amount - *

- * @param incomeSingleAmount Income single amount - */ - void setIncomeSingleAmount (final BigDecimal incomeSingleAmount); - - /** - * Getter for income title - *

- * @return Income title - */ - String getIncomeTitle (); - - /** - * Setter for income title - *

- * @param incomeTitle Income title - */ - void setIncomeTitle (final String incomeTitle); - - /** - * Getter for income-updated timestamp - *

- * @return Income-updated timestamp - */ - Date getIncomeUpdated (); - - /** - * Setter for income-updated timestamp - *

- * @param incomeUpdated Income-updated timestamp - */ - void setIncomeUpdated (final Date incomeUpdated); - - /** - * Getter for connected user account - *

- * @return Connected user account - */ - User getIncomeUser (); - - /** - * Setter for connected user account - *

- * @param incomeUser Connected user account - */ - void setIncomeUser (final User incomeUser); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jfinancials/model/income/FinancialIncome.java b/src/org/mxchange/jfinancials/model/income/FinancialIncome.java deleted file mode 100644 index 08e6225..0000000 --- a/src/org/mxchange/jfinancials/model/income/FinancialIncome.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.income; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jcoreutils.Comparables; -import org.mxchange.jfinancials.model.income.interval.FinancialInterval; -import org.mxchange.jusercore.model.user.LoginUser; -import org.mxchange.jusercore.model.user.User; - -/** - * An entity for income data - *

- * @author Roland Häder - */ -@Entity (name = "income") -@Table (name = "income") -@SuppressWarnings ("PersistenceUnitPresent") -public class FinancialIncome implements BillableIncome { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 173_587_690_625_524L; - - /** - * Income created timestamp - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "income_created", nullable = false, updatable = false) - private Date incomeCreated; - - /** - * Income enabled (default) or disabled (no longer receiving income but need - * to keep it for statistics). - */ - @Basic (optional = false) - @Column (name = "income_enabled", nullable = false) - private Boolean incomeEnabled; - - /** - * Income id (primary key) - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "income_id", nullable = false, updatable = false) - private Long incomeId; - - /** - * Income interval - */ - @Basic (optional = false) - @Column (name = "income_interval", nullable = false) - @Enumerated (EnumType.STRING) - private FinancialInterval incomeInterval; - - /** - * Income single amount - */ - @Basic (optional = false) - @Column (name = "income_single_amount", nullable = false) - private BigDecimal incomeSingleAmount; - - /** - * Income title - */ - @Basic (optional = false) - @Column (name = "income_title", nullable = false) - private String incomeTitle; - - /** - * Income updated timestamp - */ - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "income_updated", insertable = false) - private Date incomeUpdated; - - /** - * Connected user account - */ - @JoinColumn (name = "income_user_id", referencedColumnName = "user_id", nullable = false, updatable = false) - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) - private User incomeUser; - - /** - * Default constructor - */ - public FinancialIncome () { - } - - /** - * Constructor with all fields, except timestamps. These have to be set at a - * proper place - *

- * @param incomeTitle Income (type) title - * @param incomeSingleAmount Single amount - * @param incomeInterval Interval - * @param incomeUser Connected user - */ - public FinancialIncome (final String incomeTitle, final BigDecimal incomeSingleAmount, final FinancialInterval incomeInterval, final User incomeUser) { - // Invoke default constructor - this(); - - // Set all fields - this.incomeTitle = incomeTitle; - this.incomeSingleAmount = incomeSingleAmount; - this.incomeInterval = incomeInterval; - this.incomeUser = incomeUser; - - // Enable this income by default - this.incomeEnabled = Boolean.TRUE; - } - - @Override - public int compareTo (final BillableIncome billableIncome) { - // Check parameter on null-reference and equality to this - if (null == billableIncome) { - // Should not happen - throw new NullPointerException("billableIncome is null"); //NOI18N - } else if (billableIncome.equals(this)) { - // Same object - return 0; - } - - // Init comparators - final int comparators[] = { - // First compare title - this.getIncomeTitle().compareToIgnoreCase(billableIncome.getIncomeTitle()), - // ... then compare interval - this.getIncomeInterval().compareTo(billableIncome.getIncomeInterval()), - // ... value - this.getIncomeSingleAmount().compareTo(billableIncome.getIncomeSingleAmount()), - // ... user instance - this.getIncomeUser().compareTo(billableIncome.getIncomeUser()) - }; - - // Check all values - final int comparison = Comparables.checkAll(comparators); - - // Return value - return comparison; - } - - @Override - public boolean equals (final Object object) { - if (this == object) { - return true; - } else if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final BillableIncome other = (BillableIncome) object; - - if (!Objects.equals(this.getIncomeTitle(), other.getIncomeTitle())) { - return false; - } else if (!Objects.equals(this.getIncomeId(), other.getIncomeId())) { - return false; - } else if (!Objects.equals(this.getIncomeUser(), other.getIncomeUser())) { - return false; - } - return true; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getIncomeCreated () { - return this.incomeCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setIncomeCreated (Date incomeCreated) { - this.incomeCreated = incomeCreated; - } - - @Override - public Boolean getIncomeEnabled () { - return this.incomeEnabled; - } - - @Override - public void setIncomeEnabled (Boolean incomeEnabled) { - this.incomeEnabled = incomeEnabled; - } - - @Override - public Long getIncomeId () { - return this.incomeId; - } - - @Override - public void setIncomeId (final Long incomeId) { - this.incomeId = incomeId; - } - - @Override - public FinancialInterval getIncomeInterval () { - return this.incomeInterval; - } - - @Override - public void setIncomeInterval (final FinancialInterval incomeInterval) { - this.incomeInterval = incomeInterval; - } - - @Override - public BigDecimal getIncomeSingleAmount () { - return this.incomeSingleAmount; - } - - @Override - public void setIncomeSingleAmount (final BigDecimal incomeSingleAmount) { - this.incomeSingleAmount = incomeSingleAmount; - } - - @Override - public String getIncomeTitle () { - return this.incomeTitle; - } - - @Override - public void setIncomeTitle (String incomeTitle) { - this.incomeTitle = incomeTitle; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getIncomeUpdated () { - return this.incomeUpdated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setIncomeUpdated (Date incomeUpdated) { - this.incomeUpdated = incomeUpdated; - } - - @Override - public User getIncomeUser () { - return this.incomeUser; - } - - @Override - public void setIncomeUser (User incomeUser) { - this.incomeUser = incomeUser; - } - - @Override - public int hashCode () { - int hash = 3; - - hash = 29 * hash + Objects.hashCode(this.getIncomeId()); - hash = 29 * hash + Objects.hashCode(this.getIncomeTitle()); - hash = 29 * hash + Objects.hashCode(this.getIncomeUser()); - - return hash; - } - -} diff --git a/src/org/mxchange/jfinancials/model/income/IncomeUtils.java b/src/org/mxchange/jfinancials/model/income/IncomeUtils.java deleted file mode 100644 index 3b88278..0000000 --- a/src/org/mxchange/jfinancials/model/income/IncomeUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.income; - -import java.io.Serializable; - -/** - * An utilities class for incomes - *

- * @author Roland Häder - */ -public class IncomeUtils implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 145_986_981_751L; - - /** - * Utility classes should not have instances - */ - private IncomeUtils () { - // Private constructor - } - -} diff --git a/src/org/mxchange/jfinancials/model/income/interval/FinancialInterval.java b/src/org/mxchange/jfinancials/model/income/interval/FinancialInterval.java deleted file mode 100644 index 8ea6b18..0000000 --- a/src/org/mxchange/jfinancials/model/income/interval/FinancialInterval.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.income.interval; - -import java.io.Serializable; - -/** - * An enumeration for income/expenses intervals - *

- * @author Roland Häder - */ -public enum FinancialInterval implements Serializable { - - /** - * Daily - */ - DAILY("FINANCIAL_INTERVAL_DAILY", "financial_interval_daily"), //NOI18N - - /** - * Weekly - */ - WEEKLY("FINANCIAL_INTERVAL_WEEKLY", "financial_interval_weekly"), //NOI18N - - /** - * Monthly - */ - MONTHLY("FINANCIAL_INTERVAL_MONTHLY", "financial_interval_monthly"), //NOI18N - - /** - * Yearly - */ - YEARLY("FINANCIAL_INTERVAL_YEARLY", "financial_interval_yearly"); //NOI18N - - /** - * Message key - */ - private final String messageKey; - - /** - * CSS style class - */ - private final String styleClass; - - /** - * Constructor with i18n translation key and CSS style class - *

- * @param messageKey Message key (i18n) - * @param styleClass CSS style class - */ - private FinancialInterval (final String messageKey, final String styleClass) { - // Validate parameter - if (null == messageKey) { - // Throw NPE - throw new NullPointerException("messageKey is null"); //NOI18N - } else if (messageKey.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("messageKey is empty"); //NOI18N - } else if (null == styleClass) { - // Throw NPE - throw new NullPointerException("styleClass is null"); //NOI18N - } else if (styleClass.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("styleClass is empty"); //NOI18N - } - - // Set it here - this.messageKey = messageKey; - this.styleClass = styleClass; - } - - /** - * Getter for message key - *

- * @return Message key (i18n) - */ - public String getMessageKey () { - return this.messageKey; - } - - /** - * Getter for CSS style class - *

- * @return CSS style class - */ - public String getStyleClass () { - return this.styleClass; - } - -} diff --git a/src/org/mxchange/jfinancials/model/receipt/BillableReceipt.java b/src/org/mxchange/jfinancials/model/receipt/BillableReceipt.java deleted file mode 100644 index 61a10f3..0000000 --- a/src/org/mxchange/jfinancials/model/receipt/BillableReceipt.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.receipt; - -import java.io.Serializable; -import java.util.Date; -import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jfinancials.model.bonus_card.BonusCard; -import org.mxchange.jproduct.model.payment.PaymentType; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for receipts - *

- * @author Roland Häder - */ -public interface BillableReceipt extends Comparable, Serializable { - - /** - * Getter for receipt bar-code number - *

- * @return Receipt bar-code number - */ - String getReceiptBarCodeNumber (); - - /** - * Setter for receipt bar-code number - *

- * @param receiptBarCodeNumber Receipt bar-code number - */ - void setReceiptBarCodeNumber (final String receiptBarCodeNumber); - - /** - * Getter for receipt's assigned bonus card - *

- * @return Receipt's assigned bonus card - */ - BonusCard getReceiptBonusCard (); - - /** - * Setter for receipt's assigned bonus card - *

- * @param receiptBonusCard Receipt's assigned bonus card - */ - void setReceiptBonusCard (final BonusCard receiptBonusCard); - - /** - * Getter for when this receipt has been created in database - *

- * @return Receipt creation timestamp - */ - Date getReceiptCreated (); - - /** - * Setter for when this receipt has been created in database - *

- * @param receiptUpdated Receipt updated timestamp - */ - void setReceiptUpdated (final Date receiptUpdated); - - /** - * Getter for when this receipt has been updated in database - *

- * @return Receipt updated timestamp - */ - Date getReceiptUpdated (); - - /** - * Setter for when this receipt has been updated in database - *

- * @param receiptCreated Receipt creation timestamp - */ - void setReceiptCreated (final Date receiptCreated); - - /** - * Getter for when this receipt has been issued (as written on it) - *

- * @return Receipt issue timestamp - */ - Date getReceiptIssued (); - - /** - * Setter for when this receipt has been issued (as written on it) - *

- * @param receiptIssued Receipt issue timestamp - */ - void setReceiptIssued (final Date receiptIssued); - - /** - * Getter for primary key - *

- * @return Primary key - */ - Long getReceiptId (); - - /** - * Setter for primary key - *

- * @param receiptId Primary key - */ - void setReceiptId (final Long receiptId); - - /** - * Getter for seller (employee) - *

- * @return Seller (employee) - */ - Employable getReceiptSellerEmployee (); - - /** - * Setter for seller (employee) - *

- * @param receiptSellerEmployee Seller (employee) - */ - void setReceiptSellerEmployee (final Employable receiptSellerEmployee); - - /** - * Getter for receipt number - *

- * @return Receipt number - */ - String getReceiptNumber (); - - /** - * Setter for receipt number - *

- * @param receiptNumber Receipt number - */ - void setReceiptNumber (final String receiptNumber); - - /** - * Getter for receipt register's number (cash register's number) - *

- * @return Receipt register's number - */ - Long getReceiptRegisterNumber (); - - /** - * Setter for receipt register's number (cash register's number) - *

- * @param receiptRegisterNumber Receipt register's number - */ - void setReceiptRegisterNumber (final Long receiptRegisterNumber); - - /** - * Getter for receipt's user - *

- * @return Receipt's user - */ - User getReceiptUser (); - - /** - * Setter for receipt's user - *

- * @param receiptUser Receipt's user - */ - void setReceiptUser (final User receiptUser); - - /** - * Getter for branch office instance - *

- * @return Branch office instance - */ - BranchOffice getReceiptBranchOffice (); - - /** - * Setter for branch office instance - *

- * @param receiptBranch Branch office instance - */ - void setReceiptBranchOffice (final BranchOffice receiptBranch); - - /** - * Getter for payment type - *

- * @return Payment type - */ - PaymentType getReceiptPaymentType (); - - /** - * Setter for payment type - *

- * @param receiptPaymentType Payment type - */ - void setReceiptPaymentType (final PaymentType receiptPaymentType); - - /** - * Getter for receipt sequence number - *

- * @return Receipt sequence number - */ - Long getReceiptSequenceNumber (); - - /** - * Setter for receipt sequence number - *

- * @param receiptSequenceNumber Receipt sequence number - */ - void setReceiptSequenceNumber (final Long receiptSequenceNumber); - - /** - * Getter for receipt transaction number - *

- * @return Receipt transaction number - */ - Long getReceiptTransactionNumber (); - - /** - * Setter for receipt transaction number - *

- * @param receiptTransactionNumber Receipt transaction number - */ - void setReceiptTransactionNumber (final Long receiptTransactionNumber); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jfinancials/model/receipt/FinancialReceipt.java b/src/org/mxchange/jfinancials/model/receipt/FinancialReceipt.java deleted file mode 100644 index 02a93af..0000000 --- a/src/org/mxchange/jfinancials/model/receipt/FinancialReceipt.java +++ /dev/null @@ -1,495 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.receipt; - -import java.text.MessageFormat; -import java.util.Date; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.apache.commons.lang3.StringUtils; -import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; -import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices; -import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; -import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.employee.Employees; -import org.mxchange.jcoreutils.Comparables; -import org.mxchange.jcoreutils.SafeNumberUtils; -import org.mxchange.jfinancials.model.bonus_card.BonusCard; -import org.mxchange.jfinancials.model.bonus_card.FinancialBonusCard; -import org.mxchange.jproduct.model.payment.PaymentType; -import org.mxchange.jusercore.model.user.LoginUser; -import org.mxchange.jusercore.model.user.User; -import org.mxchange.jusercore.model.user.Users; - -/** - * Receipt POJO - *

- * @author Roland Häder - */ -@Entity (name = "receipts") -@Table ( - name = "receipts" -) -@NamedQueries ( - { - @NamedQuery (name = "AllReceipts", query = "SELECT r FROM receipts AS r ORDER BY r.receiptId ASC"), - @NamedQuery (name = "SearchAllUserReceipts", query = "SELECT r FROM receipts AS r WHERE r.receiptUser = :receiptUser ORDER BY r.receiptId ASC") - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class FinancialReceipt implements BillableReceipt { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 185_867_217_461L; - - /** - * Receipt bar-code number - */ - @Column (name = "receipt_barcode_number") - private String receiptBarCodeNumber; - - /** - * Assigned bonus card - */ - @JoinColumn (name = "receipt_bonus_card_id", referencedColumnName = "bonus_card_id") - @OneToOne (targetEntity = FinancialBonusCard.class, cascade = CascadeType.REFRESH) - private BonusCard receiptBonusCard; - - /** - * Seller instance - */ - @JoinColumn (name = "receipt_branch_id", referencedColumnName = "branch_id", nullable = false, updatable = false) - @OneToOne (targetEntity = BusinessBranchOffice.class, cascade = CascadeType.REFRESH, optional = false) - private BranchOffice receiptBranchOffice; - - /** - * When this receipt entry has been created - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "receipt_created", nullable = false) - private Date receiptCreated; - - /** - * Primary key - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "receipt_id", nullable = false, updatable = false) - private Long receiptId; - - /** - * When this receipt has been issued - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "receipt_issued", nullable = false) - private Date receiptIssued; - - /** - * Receipt number - */ - @Column (name = "receipt_number") - private String receiptNumber; - - /** - * Payment type (cash, credit card, EC card ...) - */ - @Basic (optional = false) - @Column (name = "receipt_payment_type", nullable = false) - @Enumerated (EnumType.STRING) - private PaymentType receiptPaymentType; - - /** - * Receipt register number - */ - @Column (name = "receipt_register_number") - private Long receiptRegisterNumber; - - /** - * Selling employee instance - */ - @JoinColumn (name = "receipt_seller_id", referencedColumnName = "employee_id") - @OneToOne (targetEntity = BusinessEmployee.class, cascade = CascadeType.REFRESH) - private Employable receiptSellerEmployee; - - /** - * Receipt sequence number - */ - @Column (name = "receipt_sequence_number") - private Long receiptSequenceNumber; - - /** - * Receipt transaction number - */ - @Column (name = "receipt_transaction_number") - private Long receiptTransactionNumber; - - /** - * When this receipt entry has been updated - */ - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "receipt_updated") - private Date receiptUpdated; - - /** - * Which user this receipt belongs to - */ - @JoinColumn (name = "receipt_user_id", referencedColumnName = "user_id") - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) - private User receiptUser; - - /** - * Default constructor - */ - public FinancialReceipt () { - } - - /** - * Constructor with payment type, seller (branch office) and user - *

- * @param receiptPaymentType Payment type - * @param receiptBranchOffice Branch office instance - * @param receiptUser User instance - * @param receiptIssued When this receipt has been issued - *

- * @throws NullPointerException If user instance is not set - * @throws IllegalArgumentException If user instance's userId is invalid - */ - public FinancialReceipt (final PaymentType receiptPaymentType, final BranchOffice receiptBranchOffice, final User receiptUser, final Date receiptIssued) { - // Call other constructor first - this(receiptPaymentType, receiptBranchOffice, receiptIssued); - - // Validate parameter - if (null == receiptUser) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (receiptUser.getUserId() == null) { - // Throw it again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (receiptUser.getUserId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", receiptUser.getUserId())); //NOI18N - } - - // Set user instance - this.receiptUser = receiptUser; - } - - /** - * Constructor with payment type, branch office and when it has been issued - *

- * @param receiptPaymentType Payment type - * @param receiptBranchOffice Branch office instance - * @param receiptIssued When this receipt has been issued - *

- * @throws NullPointerException If user instance is not set - * @throws IllegalArgumentException If branchId is invalid - */ - public FinancialReceipt (final PaymentType receiptPaymentType, final BranchOffice receiptBranchOffice, final Date receiptIssued) { - // Call other constructor first - this(); - - // Validate all parameter - if (null == receiptPaymentType) { - // Throw NPE - throw new NullPointerException("receiptPaymentType is null"); //NOI18N - } else if (null == receiptBranchOffice) { - // Throw NPE - throw new NullPointerException("receiptBranchOffice is null"); //NOI18N - } else if (receiptBranchOffice.getBranchId() == null) { - // Throw NPE - throw new NullPointerException("receiptBranchOffice.branchId is null"); //NOI18N - } else if (receiptBranchOffice.getBranchId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptBranchOffice.branchId={0} is invalid", receiptBranchOffice.getBranchId())); //NOI18N - } else if (null == receiptIssued) { - // Throw NPE - throw new NullPointerException("receiptIssued is null"); //NOI18N - } - - // Set all values - this.receiptPaymentType = receiptPaymentType; - this.receiptBranchOffice = receiptBranchOffice; - this.receiptIssued = receiptIssued; - } - - @Override - public int compareTo (final BillableReceipt billableReceipt) { - // Check parameter on null-reference and equality to this - if (null == billableReceipt) { - // Should not happen - throw new NullPointerException("billableReceipt is null"); //NOI18N - } else if (billableReceipt.equals(this)) { - // Same object - return 0; - } - - // Init comparators - final int comparators[] = { - // First compare receipt number - StringUtils.compare(this.getReceiptNumber(), billableReceipt.getReceiptNumber()), - // ... next bar-code - StringUtils.compare(this.getReceiptBarCodeNumber(), billableReceipt.getReceiptBarCodeNumber()), - // ... sequence number - SafeNumberUtils.compare(this.getReceiptSequenceNumber(), billableReceipt.getReceiptSequenceNumber()), - // ... transaction number - SafeNumberUtils.compare(this.getReceiptTransactionNumber(), billableReceipt.getReceiptTransactionNumber()), - // ... payment type - this.getReceiptPaymentType().compareTo(billableReceipt.getReceiptPaymentType()), - // ... register number - SafeNumberUtils.compare(this.getReceiptRegisterNumber(), billableReceipt.getReceiptRegisterNumber()), - // ... issue date - this.getReceiptIssued().compareTo(billableReceipt.getReceiptIssued()), - // ... next is seller instance - Employees.compare(this.getReceiptSellerEmployee(), billableReceipt.getReceiptSellerEmployee()), - // .. branch office - BranchOffices.compare(this.getReceiptBranchOffice(), billableReceipt.getReceiptBranchOffice()), - // ... and user instance - Users.compare(this.getReceiptUser(), billableReceipt.getReceiptUser()) - }; - - // Check all values - final int comparison = Comparables.checkAll(comparators); - - // Return value - return comparison; - } - - @Override - public boolean equals (final Object object) { - if (this == object) { - return true; - } else if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - // Cast securely - final BillableReceipt receipt = (BillableReceipt) object; - - // Now check some distincting class fields - if (!Objects.equals(this.getReceiptId(), receipt.getReceiptId())) { - return false; - } else if (!Objects.equals(this.getReceiptNumber(), receipt.getReceiptNumber())) { - return false; - } else if (!Objects.equals(this.getReceiptRegisterNumber(), receipt.getReceiptRegisterNumber())) { - return false; - } else if (!Objects.equals(this.getReceiptSequenceNumber(), receipt.getReceiptSequenceNumber())) { - return false; - } else if (!Objects.equals(this.getReceiptTransactionNumber(), receipt.getReceiptTransactionNumber())) { - return false; - } else if (this.getReceiptPaymentType() != receipt.getReceiptPaymentType()) { - return false; - } else if (!Objects.equals(this.getReceiptBranchOffice(), receipt.getReceiptBranchOffice())) { - return false; - } else if (!Objects.equals(this.getReceiptUser(), receipt.getReceiptUser())) { - return false; - } else if (!Objects.equals(this.getReceiptIssued(), receipt.getReceiptIssued())) { - return false; - } else if (!Objects.equals(this.getReceiptSellerEmployee(), receipt.getReceiptSellerEmployee())) { - return false; - } - - return true; - } - - @Override - public String getReceiptBarCodeNumber () { - return this.receiptBarCodeNumber; - } - - @Override - public void setReceiptBarCodeNumber (final String receiptBarCodeNumber) { - this.receiptBarCodeNumber = receiptBarCodeNumber; - } - - @Override - public BonusCard getReceiptBonusCard () { - return this.receiptBonusCard; - } - - @Override - public void setReceiptBonusCard (final BonusCard receiptBonusCard) { - this.receiptBonusCard = receiptBonusCard; - } - - @Override - public BranchOffice getReceiptBranchOffice () { - return this.receiptBranchOffice; - } - - @Override - public void setReceiptBranchOffice (final BranchOffice receiptBranchOffice) { - this.receiptBranchOffice = receiptBranchOffice; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getReceiptCreated () { - return this.receiptCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setReceiptCreated (final Date receiptCreated) { - this.receiptCreated = receiptCreated; - } - - @Override - public Long getReceiptId () { - return this.receiptId; - } - - @Override - public void setReceiptId (final Long receiptId) { - this.receiptId = receiptId; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getReceiptIssued () { - return this.receiptIssued; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setReceiptIssued (final Date receiptIssued) { - this.receiptIssued = receiptIssued; - } - - @Override - public String getReceiptNumber () { - return this.receiptNumber; - } - - @Override - public void setReceiptNumber (final String receiptNumber) { - this.receiptNumber = receiptNumber; - } - - @Override - public PaymentType getReceiptPaymentType () { - return this.receiptPaymentType; - } - - @Override - public void setReceiptPaymentType (final PaymentType receiptPaymentType) { - this.receiptPaymentType = receiptPaymentType; - } - - @Override - public Long getReceiptRegisterNumber () { - return this.receiptRegisterNumber; - } - - @Override - public void setReceiptRegisterNumber (final Long receiptRegisterNumber) { - this.receiptRegisterNumber = receiptRegisterNumber; - } - - @Override - public Employable getReceiptSellerEmployee () { - return this.receiptSellerEmployee; - } - - @Override - public void setReceiptSellerEmployee (final Employable receiptSellerEmployee) { - this.receiptSellerEmployee = receiptSellerEmployee; - } - - @Override - public Long getReceiptSequenceNumber () { - return this.receiptSequenceNumber; - } - - @Override - public void setReceiptSequenceNumber (final Long receiptSequenceNumber) { - this.receiptSequenceNumber = receiptSequenceNumber; - } - - @Override - public Long getReceiptTransactionNumber () { - return this.receiptTransactionNumber; - } - - @Override - public void setReceiptTransactionNumber (final Long receiptTransactionNumber) { - this.receiptTransactionNumber = receiptTransactionNumber; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getReceiptUpdated () { - return this.receiptUpdated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setReceiptUpdated (final Date receiptUpdated) { - this.receiptUpdated = receiptUpdated; - } - - @Override - public User getReceiptUser () { - return this.receiptUser; - } - - @Override - public void setReceiptUser (final User receiptUser) { - this.receiptUser = receiptUser; - } - - @Override - public int hashCode () { - int hash = 5; - - hash = 89 * hash + Objects.hashCode(this.getReceiptId()); - hash = 89 * hash + Objects.hashCode(this.getReceiptNumber()); - hash = 89 * hash + Objects.hashCode(this.getReceiptRegisterNumber()); - hash = 89 * hash + Objects.hashCode(this.getReceiptSequenceNumber()); - hash = 89 * hash + Objects.hashCode(this.getReceiptTransactionNumber()); - hash = 89 * hash + Objects.hashCode(this.getReceiptPaymentType()); - hash = 89 * hash + Objects.hashCode(this.getReceiptBranchOffice()); - hash = 89 * hash + Objects.hashCode(this.getReceiptUser()); - hash = 89 * hash + Objects.hashCode(this.getReceiptSellerEmployee()); - - return hash; - } - -} diff --git a/src/org/mxchange/jfinancials/model/receipt/Receipts.java b/src/org/mxchange/jfinancials/model/receipt/Receipts.java deleted file mode 100644 index 32b1c86..0000000 --- a/src/org/mxchange/jfinancials/model/receipt/Receipts.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.receipt; - -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.Objects; - -/** - * A utilities class for receipts - * - * @author Roland Häder - */ -public class Receipts implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 2_867_938_676_165_401L; - - /** - * Compares both receipt instances. This method returns -1 if second - * instance is null. - *

- * @param receipt1 BillableReceipt instance 1 - * @param receipt2 BillableReceipt instance 2 - *

- * @return Comparison value - */ - public static int compare (final BillableReceipt receipt1, final BillableReceipt receipt2) { - // Check euqality, then at least first must be given - if (Objects.equals(receipt1, receipt2)) { - // Both are same - return 0; - } else if (null == receipt1) { - // First is null - return -1; - } else if (null == receipt2) { - // Second is null - return 1; - } - - // Invoke compareTo() method - return receipt1.compareTo(receipt2); - } - - /** - * Copies all fields from source receipt to target receipt. - *

- * @param sourceReceipt Source receipt instance - * @param targetReceipt Target Receipt instance - */ - public static void copyReceiptData (final BillableReceipt sourceReceipt, final BillableReceipt targetReceipt) { - // Both should not be null - if (null == sourceReceipt) { - // Throw NPE - throw new NullPointerException("sourceReceipt is null"); //NOI18N - } else if (null == targetReceipt) { - // Throw NPE - throw new NullPointerException("targetReceipt is null"); //NOI18N - } else if (Objects.equals(sourceReceipt, targetReceipt)) { - // Is exactly the same! - throw new IllegalArgumentException("sourcerReceipt and targetReceipt are the same."); //NOI18N - } - - // Copy all fields - targetReceipt.setReceiptBarCodeNumber(sourceReceipt.getReceiptBarCodeNumber()); - targetReceipt.setReceiptBonusCard(sourceReceipt.getReceiptBonusCard()); - targetReceipt.setReceiptBranchOffice(sourceReceipt.getReceiptBranchOffice()); - targetReceipt.setReceiptCreated(sourceReceipt.getReceiptCreated()); - targetReceipt.setReceiptId(sourceReceipt.getReceiptId()); - targetReceipt.setReceiptIssued(sourceReceipt.getReceiptIssued()); - targetReceipt.setReceiptNumber(sourceReceipt.getReceiptNumber()); - targetReceipt.setReceiptPaymentType(sourceReceipt.getReceiptPaymentType()); - targetReceipt.setReceiptRegisterNumber(sourceReceipt.getReceiptRegisterNumber()); - targetReceipt.setReceiptSellerEmployee(sourceReceipt.getReceiptSellerEmployee()); - targetReceipt.setReceiptSequenceNumber(sourceReceipt.getReceiptSequenceNumber()); - targetReceipt.setReceiptTransactionNumber(sourceReceipt.getReceiptTransactionNumber()); - targetReceipt.setReceiptUpdated(sourceReceipt.getReceiptUpdated()); - targetReceipt.setReceiptUser(sourceReceipt.getReceiptUser()); - } - - /** - * Checks whether both receipts are the same, means not true entity equality - * but if the receipt in general terms does already exist. A pre-check on - * entity equality is however performed to avoid below much longer code. - *

- * @param receipt1 BillableReceipt instance 1 - * @param receipt2 BillableReceipt instance 2 - *

- * @return Whether both receipts are the same (not instances) - */ - public static boolean isSameReceipt (final BillableReceipt receipt1, final BillableReceipt receipt2) { - // Pre-compare both as entities (same id) - if (Objects.equals(receipt1, receipt2)) { - // Same entity (with id number) - return true; - } - - // Validate parameter - if (null == receipt1) { - // Throw NPE - throw new NullPointerException("receipt1 is null"); //NOI18N - } else if ((receipt1.getReceiptId() instanceof Long) && (receipt1.getReceiptId() < 1)) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receipt1.receiptId={0} is not valid.", receipt1.getReceiptId())); //NOI18N - } else if (receipt1.getReceiptBranchOffice() == null) { - // Throw NPE - throw new NullPointerException("receipt1.receiptBranchOffice is null"); //NOI18N - } else if (receipt1.getReceiptBranchOffice().getBranchId() == null) { - // Throw NPE - throw new NullPointerException("receipt1.receiptBranchOffice.branchId is null"); //NOI18N - } else if (receipt1.getReceiptBranchOffice().getBranchId() < 1) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("receipt1.receiptBranchOffice.branchId={0} is not valid", receipt1.getReceiptBranchOffice().getBranchId())); //NOI18N - } else if ((receipt1.getReceiptNumber() != null) && (receipt1.getReceiptNumber().isEmpty())) { - // Throw IAE - throw new IllegalArgumentException("receipt1.receiptNumber is empty."); //NOI18N - } else if (receipt1.getReceiptPaymentType() == null) { - // Throw NPE - throw new NullPointerException("receipt1.receiptPaymentType is null"); //NOI18N - } else if (null == receipt2) { - // Throw NPE - throw new NullPointerException("receipt2 is null"); //NOI18N - } else if ((receipt2.getReceiptId() instanceof Long) && (receipt2.getReceiptId() < 1)) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receipt2.receiptId={0} is not valid.", receipt2.getReceiptId())); //NOI18N - } else if (receipt2.getReceiptBranchOffice() == null) { - // Throw NPE - throw new NullPointerException("receipt2.receiptBranchOffice is null"); //NOI18N - } else if (receipt2.getReceiptBranchOffice().getBranchId() == null) { - // Throw NPE - throw new NullPointerException("receipt2.receiptBranchOffice.branchId is null"); //NOI18N - } else if (receipt2.getReceiptBranchOffice().getBranchId() < 1) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("receipt2.receiptBranchOffice.branchId={0} is not valid", receipt2.getReceiptBranchOffice().getBranchId())); //NOI18N - } else if ((receipt2.getReceiptNumber() != null) && (receipt2.getReceiptNumber().isEmpty())) { - // Throw IAE - throw new IllegalArgumentException("receipt2.receiptNumber is empty."); //NOI18N - } else if (receipt2.getReceiptPaymentType() == null) { - // Throw NPE - throw new NullPointerException("receipt2.receiptPaymentType is null"); //NOI18N - } - - // Now check all individually - if (!Objects.equals(receipt1.getReceiptBranchOffice(), receipt2.getReceiptBranchOffice())) { - // Other branch offices - return false; - } else if (!Objects.equals(receipt1.getReceiptNumber(), receipt2.getReceiptNumber())) { - // Other receipt number - return false; - } else if (!Objects.equals(receipt1.getReceiptIssued(), receipt2.getReceiptIssued())) { - // Other issue date - return false; - } else if (!Objects.equals(receipt1.getReceiptUser(), receipt2.getReceiptUser())) { - // Other user (unlikely to happen - return false; - } - - // Maybe same receipt! - return true; - } - - /** - * Private default constructor - */ - private Receipts () { - // Utilities don't have instances - } - -} diff --git a/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java deleted file mode 100644 index 4425e0e..0000000 --- a/src/org/mxchange/jfinancials/model/receipt_item/BillableReceiptItem.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.receipt_item; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; -import org.mxchange.jproduct.model.product.Product; - -/** - * An interface for receipt items - *

- * @author Roland Häder - */ -public interface BillableReceiptItem extends Comparable, Serializable { - - /** - * Getter when this receipt item has been created in database - *

- * @return When this item has been created - */ - Date getItemCreated (); - - /** - * Setter when this receipt item has been created in database - *

- * @param itemCreated When this item has been created - */ - void setItemCreated (final Date itemCreated); - - /** - * Getter for primary key - *

- * @return Primary key - */ - Long getItemId (); - - /** - * Setter for primary key - *

- * @param itemId Primary key - */ - void setItemId (final Long itemId); - - /** - * Getter for whether the item is a discount on whole receipt - *

- * @return Whether the item is a discount on whole receipt - */ - Boolean getItemIsDiscount (); - - /** - * Setter for whether the item is a discount on whole receipt or item - *

- * @param itemIsDiscount Whether the item is a discount on whole receipt or - * item - */ - void setItemIsDiscount (final Boolean itemIsDiscount); - - /** - * Getter for whether the item is a refund - *

- * @return Whether the item is a refund - */ - Boolean getItemIsRefund (); - - /** - * Setter for whether the item is a refund - *

- * @param itemIsRefund Whether the item is a refund - */ - void setItemIsRefund (final Boolean itemIsRefund); - - /** - * Getter for receipt instance - *

- * @return Receipt instance - */ - BillableReceipt getItemReceipt (); - - /** - * Setter for receipt instance - *

- * @param itemReceipt Receipt instance - */ - void setItemReceipt (final BillableReceipt itemReceipt); - - /** - * Getter for linked product - *

- * @return Product - */ - Product getItemProduct (); - - /** - * Setter for linked product - *

- * @param itemProduct Product - */ - void setItemProduct (final Product itemProduct); - - /** - * Getter for product quantity - *

- * @return Product quantity - */ - BigDecimal getItemProductQuantity (); - - /** - * Setter for product quantity - *

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

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

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

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

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

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

- * @param itemGrossPrice Item's gross price - */ - void setItemGrossPrice (final BigDecimal itemGrossPrice); - - /** - * Getter for manufacturer/producer of this item - *

- * @return Manufacturer/producer of this item - */ - BasicData getItemManufacturer (); - - /** - * Setter for manufacturer/producer of this item - *

- * @param itemManufacturer Manufacturer/producer of this item - */ - void setItemManufacturer (final BasicData itemManufacturer); - - /** - * Getter for item brand name - *

- * @return Item brand name - */ - String getItemBrandName (); - - /** - * Setter for item brand name - *

- * @param itemBrandName Item brand name - */ - void setItemBrandName (final String itemBrandName); - - /** - * Getter for item number - *

- * @return Item number - */ - Long getItemNumber (); - - /** - * Setter for item number - *

- * @param itemNumber Item number - */ - void setItemNumber (final Long itemNumber); - - /** - * Getter for item's coupon number - *

- * @return Item's coupon number - */ - String getItemCouponNumber (); - - /** - * Setter for item's coupon number - *

- * @param itemCouponNumber Item's coupon number - */ - void setItemCouponNumber (final String itemCouponNumber); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java deleted file mode 100644 index f7eb6f9..0000000 --- a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.receipt_item; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.apache.commons.lang3.StringUtils; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; -import org.mxchange.jcoreutils.Comparables; -import org.mxchange.jcoreutils.SafeNumberUtils; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; -import org.mxchange.jfinancials.model.receipt.FinancialReceipt; -import org.mxchange.jfinancials.model.receipt.Receipts; -import org.mxchange.jproduct.model.product.GenericProduct; -import org.mxchange.jproduct.model.product.Product; -import org.mxchange.jproduct.model.product.Products; - -/** - * A POJO for receipt items - *

- * @author Roland Häder - */ -@Entity (name = "receipt_items") -@Table ( - name = "receipt_items" -) -@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") - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class FinancialReceiptItem implements BillableReceiptItem { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 126_498_698_378_571L; - - /** - * Item branding - */ - @Column (name = "item_brand_name") - private String itemBrandName; - - /** - * Item 's coupon number - */ - @Column (name = "item_coupon_number") - private String itemCouponNumber; - - /** - * When this item has been created in database - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "item_created", nullable = false) - private Date itemCreated; - - /** - * Gross price of item - */ - @Basic (optional = false) - @Column (name = "item_gross_price", nullable = false, precision = 10, scale = 2) - private BigDecimal itemGrossPrice; - - /** - * Primary key - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "item_id", nullable = false, updatable = false) - private Long itemId; - - /** - * Whether the item is a discount on whole receipt or single item - */ - @Basic (optional = false) - @Column (name = "item_is_discount", nullable = false) - private Boolean itemIsDiscount; - - /** - * Whether the item is a refund - */ - @Basic (optional = false) - @Column (name = "item_is_refund", nullable = false) - private Boolean itemIsRefund; - - /** - * Manufacturer/producer of this item - */ - @JoinColumn (name = "item_manufacturer_id", referencedColumnName = "company_data_id") - @OneToOne (targetEntity = BusinessBasicData.class, cascade = CascadeType.REFRESH) - private BasicData itemManufacturer; - - /** - * Net price of item - */ - @Column (name = "item_net_price", precision = 10, scale = 2) - private BigDecimal itemNetPrice; - - /** - * Item's number - */ - @Column (name = "item_number") - private Long itemNumber; - - /** - * Product being linked in this itemReceipt 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; - - /** - * Product quantity - */ - @Basic (optional = false) - @Column (name = "item_product_quantity", nullable = false, precision = 3) - private BigDecimal itemProductQuantity; - - /** - * Connected itemReceipt item - */ - @JoinColumn (name = "item_receipt_id", referencedColumnName = "receipt_id", nullable = false, updatable = false) - @OneToOne (targetEntity = FinancialReceipt.class, cascade = CascadeType.REFRESH, optional = false) - private BillableReceipt itemReceipt; - - /** - * Tax rate - */ - @Column (name = "item_tax_rate", precision = 2) - private BigDecimal itemTaxRate; - - /** - * Default constructor - */ - public FinancialReceiptItem () { - } - - /** - * Constructor with product, price, quantity and receipt instance - *

- * @param itemProduct Product instance - * @param itemProductQuantity Product quantity - * @param itemReceipt FinancialReceipt instance - */ - public FinancialReceiptItem (final Product itemProduct, final BigDecimal itemProductQuantity, final BillableReceipt itemReceipt) { - // Call other constructor - this(); - - // Set all values - this.itemProduct = itemProduct; - this.itemProductQuantity = itemProductQuantity; - this.itemReceipt = itemReceipt; - } - - @Override - public int compareTo (final BillableReceiptItem billableReceiptItem) { - // Check parameter on null-reference and equality to this - if (null == billableReceiptItem) { - // Should not happen - throw new NullPointerException("billableReceiptItem is null"); //NOI18N - } else if (billableReceiptItem.equals(this)) { - // Same object - return 0; - } - - // Init comparators - final int comparators[] = { - // First check brand name ... - StringUtils.compare(this.getItemBrandName(), billableReceiptItem.getItemBrandName()), - // ... item number - SafeNumberUtils.compare(this.getItemNumber(), billableReceiptItem.getItemNumber()), - // ... coupon number - StringUtils.compare(this.getItemCouponNumber(), billableReceiptItem.getItemCouponNumber()), - // ... gross price - SafeNumberUtils.compare(this.getItemGrossPrice(), billableReceiptItem.getItemGrossPrice()), - // ... net price - SafeNumberUtils.compare(this.getItemNetPrice(), billableReceiptItem.getItemNetPrice()), - // ... tax rate - SafeNumberUtils.compare(this.getItemTaxRate(), billableReceiptItem.getItemTaxRate()), - // ... product quanity - this.getItemProductQuantity().compareTo(billableReceiptItem.getItemProductQuantity()), - // ... product instance - Products.compare(this.getItemProduct(), billableReceiptItem.getItemProduct()), - // and finally receipt instance - Receipts.compare(this.getItemReceipt(), billableReceiptItem.getItemReceipt()) - }; - - // Check all values - final int comparison = Comparables.checkAll(comparators); - - // Return value - return comparison; - } - - @Override - public boolean equals (final Object object) { - if (this == object) { - return true; - } else if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final BillableReceiptItem receiptItem = (BillableReceiptItem) object; - - if (!Objects.equals(this.getItemId(), receiptItem.getItemId())) { - return false; - } else if (!Objects.equals(this.getItemNumber(), receiptItem.getItemNumber())) { - return false; - } else if (!Objects.equals(this.getItemProduct(), receiptItem.getItemProduct())) { - return false; - } else if (!Objects.equals(this.getItemProductQuantity(), receiptItem.getItemProductQuantity())) { - return false; - } else if (!Objects.equals(this.getItemReceipt(), receiptItem.getItemReceipt())) { - return false; - } else if (!Objects.equals(this.getItemCouponNumber(), receiptItem.getItemCouponNumber())) { - return false; - } - - return true; - } - - @Override - public String getItemBrandName () { - return this.itemBrandName; - } - - @Override - public void setItemBrandName (final String itemBrandName) { - this.itemBrandName = itemBrandName; - } - - @Override - public String getItemCouponNumber () { - return this.itemCouponNumber; - } - - @Override - public void setItemCouponNumber (final String itemCouponNumber) { - this.itemCouponNumber = itemCouponNumber; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getItemCreated () { - return this.itemCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setItemCreated (final Date itemCreated) { - this.itemCreated = itemCreated; - } - - @Override - public BigDecimal getItemGrossPrice () { - return this.itemGrossPrice; - } - - @Override - public void setItemGrossPrice (final BigDecimal itemGrossPrice) { - this.itemGrossPrice = itemGrossPrice; - } - - @Override - public Long getItemId () { - return this.itemId; - } - - @Override - public void setItemId (final Long itemId) { - this.itemId = itemId; - } - - @Override - public Boolean getItemIsDiscount () { - return this.itemIsDiscount; - } - - @Override - public void setItemIsDiscount (final Boolean itemIsDiscount) { - this.itemIsDiscount = itemIsDiscount; - } - - @Override - public Boolean getItemIsRefund () { - return this.itemIsRefund; - } - - @Override - public void setItemIsRefund (final Boolean itemIsRefund) { - this.itemIsRefund = itemIsRefund; - } - - @Override - public BasicData getItemManufacturer () { - return this.itemManufacturer; - } - - @Override - public void setItemManufacturer (final BasicData itemManufacturer) { - this.itemManufacturer = itemManufacturer; - } - - @Override - public BigDecimal getItemNetPrice () { - return this.itemNetPrice; - } - - @Override - public void setItemNetPrice (final BigDecimal itemNetPrice) { - this.itemNetPrice = itemNetPrice; - } - - @Override - public Long getItemNumber () { - return this.itemNumber; - } - - @Override - public void setItemNumber (final Long itemNumber) { - this.itemNumber = itemNumber; - } - - @Override - public Product getItemProduct () { - return this.itemProduct; - } - - @Override - public void setItemProduct (final Product itemProduct) { - this.itemProduct = itemProduct; - } - - @Override - public BigDecimal getItemProductQuantity () { - return this.itemProductQuantity; - } - - @Override - public void setItemProductQuantity (final BigDecimal itemProductQuantity) { - this.itemProductQuantity = itemProductQuantity; - } - - @Override - public BillableReceipt getItemReceipt () { - return this.itemReceipt; - } - - @Override - public void setItemReceipt (final BillableReceipt itemReceipt) { - this.itemReceipt = itemReceipt; - } - - @Override - public BigDecimal getItemTaxRate () { - return this.itemTaxRate; - } - - @Override - public void setItemTaxRate (final BigDecimal itemTaxRate) { - this.itemTaxRate = itemTaxRate; - } - - @Override - public int hashCode () { - int hash = 5; - - hash = 53 * hash + Objects.hashCode(this.getItemId()); - hash = 53 * hash + Objects.hashCode(this.getItemNumber()); - hash = 53 * hash + Objects.hashCode(this.getItemProduct()); - hash = 53 * hash + Objects.hashCode(this.getItemProductQuantity()); - hash = 53 * hash + Objects.hashCode(this.getItemReceipt()); - hash = 53 * hash + Objects.hashCode(this.getItemCouponNumber()); - - return hash; - } - -} diff --git a/src/org/mxchange/jfinancials/model/receipt_item/ReceiptItems.java b/src/org/mxchange/jfinancials/model/receipt_item/ReceiptItems.java deleted file mode 100644 index 3783c02..0000000 --- a/src/org/mxchange/jfinancials/model/receipt_item/ReceiptItems.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2017 - 2020 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.model.receipt_item; - -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.Objects; - -/** - * A utilities class for receipts - * - * @author Roland Häder - */ -public class ReceiptItems implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 2_867_938_676_165_402L; - - /** - * Checks if both receipt items are the same by assigned receipt, product - * and quantity. - *

- * @param receiptItem1 Receipt item 1 - * @param receiptItem2 Receipt item 2 - *

- * @return Whether both are equal - */ - public static boolean isSameReceiptItem (final BillableReceiptItem receiptItem1, final BillableReceiptItem receiptItem2) { - // Pre-compare both as entities (same id) - if (Objects.equals(receiptItem1, receiptItem2)) { - // Same entity (with id number) - return true; - } - - // Validate parameter - if (null == receiptItem1) { - // Throw NPE - throw new NullPointerException("receiptItem1 is null"); //NOI18N - } else if ((receiptItem1.getItemId() instanceof Long) && (receiptItem1.getItemId() < 1)) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemId={0} is not valid.", receiptItem1.getItemId())); //NOI18N - } else if (receiptItem1.getItemReceipt() == null) { - // Throw NPE - throw new NullPointerException("receiptItem1.itemReceipt is null"); //NOI18N - } else if (receiptItem1.getItemReceipt().getReceiptId() == null) { - // Throw NPE - throw new NullPointerException("receiptItem1.itemReceipt.receiptId is null"); //NOI18N - } else if (receiptItem1.getItemReceipt().getReceiptId() < 1) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("receiptItem1.itemReceipt.receiptId={0} is not valid", receiptItem1.getItemReceipt().getReceiptId())); //NOI18N - } else if (receiptItem1.getItemProduct() == null) { - // Throw NPE again - throw new NullPointerException("receiptItem1.itemProduct is null."); //NOI18N - } else if (receiptItem1.getItemProduct().getProductId() == null) { - // Throw NPE again - throw new NullPointerException("receiptItem1.itemProduct.productId is null."); //NOI18N - } else if (receiptItem1.getItemProduct().getProductId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemProduct.productId={0} is invalid.", receiptItem1.getItemProduct().getProductId())); //NOI18N - } else if (null == receiptItem2) { - // Throw NPE - throw new NullPointerException("receiptItem2 is null"); //NOI18N - } else if ((receiptItem2.getItemId() instanceof Long) && (receiptItem2.getItemId() < 1)) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemId={0} is not valid.", receiptItem2.getItemId())); //NOI18N - } else if (receiptItem2.getItemReceipt() == null) { - // Throw NPE - throw new NullPointerException("receiptItem2.itemReceipt is null"); //NOI18N - } else if (receiptItem2.getItemReceipt().getReceiptId() == null) { - // Throw NPE - throw new NullPointerException("receiptItem2.itemReceipt.receiptId is null"); //NOI18N - } else if (receiptItem2.getItemReceipt().getReceiptId() < 1) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("receiptItem2.itemReceipt.receiptId={0} is not valid", receiptItem2.getItemReceipt().getReceiptId())); //NOI18N - } else if (receiptItem2.getItemProduct() == null) { - // Throw NPE again - throw new NullPointerException("receiptItem2.itemProduct is null."); //NOI18N - } else if (receiptItem2.getItemProduct().getProductId() == null) { - // Throw NPE again - throw new NullPointerException("receiptItem2.itemProduct.productId is null."); //NOI18N - } else if (receiptItem2.getItemProduct().getProductId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemProduct.productId={0} is invalid.", receiptItem2.getItemProduct().getProductId())); //NOI18N - } else if (null == receiptItem2) { - // Throw NPE - throw new NullPointerException("receiptItem2 is null"); //NOI18N - } - - // Now check all individually - if (!Objects.equals(receiptItem1.getItemReceipt(), receiptItem2.getItemReceipt())) { - // Other item receipt - return false; - } else if (!Objects.equals(receiptItem1.getItemProduct(), receiptItem2.getItemProduct())) { - // Other item product - return false; - } else if (!Objects.equals(receiptItem1.getItemProductQuantity(), receiptItem2.getItemProductQuantity())) { - // Other item quantity - return false; - } else if (!Objects.equals(receiptItem1.getItemNumber(), receiptItem2.getItemNumber())) { - // Other item number - return false; - } - - // Maybe same receipt! - return true; - } - - /** - * Private default constructor - */ - private ReceiptItems () { - // Utilities don't have instances - } - -}