<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
-<project name="jfinancials-core" default="default" basedir=".">
- <description>Builds, tests, and runs the project jfinancials-core.</description>
+<project name="jbonuscard-core" default="default" basedir=".">
+ <description>Builds, tests, and runs the project jbonuscard-core.</description>
<import file="nbproject/build-impl.xml"/>
<!--
An example of overriding the target for project execution could look like this:
- <target name="run" depends="jfinancials-core-impl.jar">
+ <target name="run" depends="jbonuscard-core-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
- cleanup
-->
-<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="jfinancials-core-impl">
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="jbonuscard-core-impl">
<fail message="Please build using Ant 1.8.0 or higher.">
<condition>
<not>
</fileset>
</union>
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
- <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="jfinancials-core" testname="TestNG tests" workingDir="${work.dir}">
+ <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="jbonuscard-core" testname="TestNG tests" workingDir="${work.dir}">
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
<propertyset>
<propertyref prefix="test-sys-prop."/>
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
<isset property="test.method"/>
</condition>
- <condition else="-suitename jfinancials-core -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+ <condition else="-suitename jbonuscard-core -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
<matches pattern=".*\.xml" string="@{testClass}"/>
</condition>
<delete dir="${build.test.results.dir}" quiet="true"/>
<delete file="${built-jar.properties}" quiet="true"/>
</target>
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
- <echo level="warn" message="Cycle detected: jfinancials-core was already built"/>
+ <echo level="warn" message="Cycle detected: jbonuscard-core was already built"/>
</target>
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
<mkdir dir="${build.dir}"/>
<delete file="${built-clean.properties}" quiet="true"/>
</target>
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
- <echo level="warn" message="Cycle detected: jfinancials-core was already built"/>
+ <echo level="warn" message="Cycle detected: jbonuscard-core was already built"/>
</target>
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
<mkdir dir="${build.dir}"/>
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
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
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
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
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
- <name>jfinancials-core</name>
+ <name>jbonuscard-core</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface BonusCard extends Comparable<BonusCard>, Serializable {
+
+ /**
+ * Getter for bonus card's bar code
+ * <p>
+ * @return Bonus card's bar code
+ */
+ String getBonusCardBarCode ();
+
+ /**
+ * Setter for bonus card's bar code
+ * <p>
+ * @param bonusCardBarCode Bonus card's bar code
+ */
+ void setBonusCardBarCode (final String bonusCardBarCode);
+
+ /**
+ * Getter for bonus card's contact data
+ * <p>
+ * @return Bonus card's contact data
+ */
+ Contact getBonusCardContact ();
+
+ /**
+ * Setter for bonus card's contact data
+ * <p>
+ * @param bonusCardContact Bonus card's contact data
+ */
+ void setBonusCardContact (final Contact bonusCardContact);
+
+ /**
+ * Getter for bonus card's creation timestamp
+ * <p>
+ * @return Bonus card's creation timestamp
+ */
+ Date getBonusCardCreated ();
+
+ /**
+ * Setter for bonus card's creation timestamp
+ * <p>
+ * @param bonusCardCreated Bonus card's creation timestamp
+ */
+ void setBonusCardCreated (final Date bonusCardCreated);
+
+ /**
+ * Getter for bonus card's customer data
+ * <p>
+ * @return Bonus card's customer data
+ */
+ Customer getBonusCardCustomer ();
+
+ /**
+ * Setter for bonus card's customer data
+ * <p>
+ * @param bonusCardCustomer Bonus card's customer data
+ */
+ void setBonusCardCustomer (final Customer bonusCardCustomer);
+
+ /**
+ * Getter for bonus card's primary key
+ * <p>
+ * @return Bonus card's primary key
+ */
+ Long getBonusCardId ();
+
+ /**
+ * Setter for bonus card's primary key
+ * <p>
+ * @param bonusCardId Bonus card's primary key
+ */
+ void setBonusCardId (final Long bonusCardId);
+
+ /**
+ * Getter for bonus card's issuing company
+ * <p>
+ * @return Bonus card's issuing company
+ */
+ BasicData getBonusCardIssuer ();
+
+ /**
+ * Setter for bonus card's issuing company
+ * <p>
+ * @param bonusCardIssuer Bonus card's issuing company
+ */
+ void setBonusCardIssuer (final BasicData bonusCardIssuer);
+
+ /**
+ * Getter for bonus card's number (other than customer/bar code)
+ * <p>
+ * @return Bonus card's number
+ */
+ String getBonusCardNumber ();
+
+ /**
+ * Setter for bonus card's number (other than customer/bar code)
+ * <p>
+ * @param bonusCardNumber Bonus card's number
+ */
+ void setBonusCardNumber (final String bonusCardNumber);
+
+ /**
+ * Getter for bonus card's partnering/branding company
+ * <p>
+ * @return Bonus card's partnering/branding company
+ */
+ BasicData getBonusCardPartner ();
+
+ /**
+ * Setter for bonus card's partnering/branding company
+ * <p>
+ * @param bonusCardPartner Bonus card's partnering/branding company
+ */
+ void setBonusCardPartner (final BasicData bonusCardPartner);
+
+ @Override
+ boolean equals (final Object object);
+
+ @Override
+ int hashCode ();
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@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
+ * <p>
+ * @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;
+ }
+
+}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableReceiptAddedEvent extends Serializable {
-
- /**
- * Getter for receipt instance
- * <p>
- * @return Receipt instance
- */
- BillableReceipt getReceipt ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableReceiptUpdatedEvent extends Serializable {
-
- /**
- * Getter for receipt instance
- * <p>
- * @return Receipt instance
- */
- BillableReceipt getReceipt ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableReceiptItemAddedEvent extends Serializable {
-
- /**
- * Getter for receipt item instance
- * <p>
- * @return Receipt item instance
- */
- BillableReceiptItem getReceiptItem ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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()));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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
- * <p>
- * @param receipt Receipt instance
- */
- public ReceiptNotFoundException (final BillableReceipt receipt) {
- // Invoke other contructor
- this(receipt.getReceiptId());
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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()));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface BonusCard extends Comparable<BonusCard>, Serializable {
-
- /**
- * Getter for bonus card's bar code
- * <p>
- * @return Bonus card's bar code
- */
- String getBonusCardBarCode ();
-
- /**
- * Setter for bonus card's bar code
- * <p>
- * @param bonusCardBarCode Bonus card's bar code
- */
- void setBonusCardBarCode (final String bonusCardBarCode);
-
- /**
- * Getter for bonus card's contact data
- * <p>
- * @return Bonus card's contact data
- */
- Contact getBonusCardContact ();
-
- /**
- * Setter for bonus card's contact data
- * <p>
- * @param bonusCardContact Bonus card's contact data
- */
- void setBonusCardContact (final Contact bonusCardContact);
-
- /**
- * Getter for bonus card's creation timestamp
- * <p>
- * @return Bonus card's creation timestamp
- */
- Date getBonusCardCreated ();
-
- /**
- * Setter for bonus card's creation timestamp
- * <p>
- * @param bonusCardCreated Bonus card's creation timestamp
- */
- void setBonusCardCreated (final Date bonusCardCreated);
-
- /**
- * Getter for bonus card's customer data
- * <p>
- * @return Bonus card's customer data
- */
- Customer getBonusCardCustomer ();
-
- /**
- * Setter for bonus card's customer data
- * <p>
- * @param bonusCardCustomer Bonus card's customer data
- */
- void setBonusCardCustomer (final Customer bonusCardCustomer);
-
- /**
- * Getter for bonus card's primary key
- * <p>
- * @return Bonus card's primary key
- */
- Long getBonusCardId ();
-
- /**
- * Setter for bonus card's primary key
- * <p>
- * @param bonusCardId Bonus card's primary key
- */
- void setBonusCardId (final Long bonusCardId);
-
- /**
- * Getter for bonus card's issuing company
- * <p>
- * @return Bonus card's issuing company
- */
- BasicData getBonusCardIssuer ();
-
- /**
- * Setter for bonus card's issuing company
- * <p>
- * @param bonusCardIssuer Bonus card's issuing company
- */
- void setBonusCardIssuer (final BasicData bonusCardIssuer);
-
- /**
- * Getter for bonus card's number (other than customer/bar code)
- * <p>
- * @return Bonus card's number
- */
- String getBonusCardNumber ();
-
- /**
- * Setter for bonus card's number (other than customer/bar code)
- * <p>
- * @param bonusCardNumber Bonus card's number
- */
- void setBonusCardNumber (final String bonusCardNumber);
-
- /**
- * Getter for bonus card's partnering/branding company
- * <p>
- * @return Bonus card's partnering/branding company
- */
- BasicData getBonusCardPartner ();
-
- /**
- * Setter for bonus card's partnering/branding company
- * <p>
- * @param bonusCardPartner Bonus card's partnering/branding company
- */
- void setBonusCardPartner (final BasicData bonusCardPartner);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface BillableIncome extends Comparable<BillableIncome>, Serializable {
-
- /**
- * Getter for income id (primary key)
- * <p>
- * @return Income id (primary key)
- */
- Long getIncomeId ();
-
- /**
- * Setter for income id (primary key)
- * <p>
- * @param incomeId Income id (primary key)
- */
- void setIncomeId (final Long incomeId);
-
- /**
- * Getter for income-created timestamp
- * <p>
- * @return Income-created timestamp
- */
- Date getIncomeCreated ();
-
- /**
- * Setter for income-created timestamp
- * <p>
- * @param incomeCreated Income-created timestamp
- */
- void setIncomeCreated (final Date incomeCreated);
-
- /**
- * Getter for whether income is enabled
- * <p>
- * @return Whether income is enabled
- */
- Boolean getIncomeEnabled ();
-
- /**
- * Setter for whether income is enabled
- * <p>
- * @param incomeEnabled Whether income is enabled
- */
- void setIncomeEnabled (final Boolean incomeEnabled);
-
- /**
- * Getter for income interval
- * <p>
- * @return Income interval
- */
- FinancialInterval getIncomeInterval ();
-
- /**
- * Setter for income interval
- * <p>
- * @param incomeInterval Income interval
- */
- void setIncomeInterval (final FinancialInterval incomeInterval);
-
- /**
- * Getter for income single amount
- * <p>
- * @return Income single amount
- */
- BigDecimal getIncomeSingleAmount ();
-
- /**
- * Setter for income single amount
- * <p>
- * @param incomeSingleAmount Income single amount
- */
- void setIncomeSingleAmount (final BigDecimal incomeSingleAmount);
-
- /**
- * Getter for income title
- * <p>
- * @return Income title
- */
- String getIncomeTitle ();
-
- /**
- * Setter for income title
- * <p>
- * @param incomeTitle Income title
- */
- void setIncomeTitle (final String incomeTitle);
-
- /**
- * Getter for income-updated timestamp
- * <p>
- * @return Income-updated timestamp
- */
- Date getIncomeUpdated ();
-
- /**
- * Setter for income-updated timestamp
- * <p>
- * @param incomeUpdated Income-updated timestamp
- */
- void setIncomeUpdated (final Date incomeUpdated);
-
- /**
- * Getter for connected user account
- * <p>
- * @return Connected user account
- */
- User getIncomeUser ();
-
- /**
- * Setter for connected user account
- * <p>
- * @param incomeUser Connected user account
- */
- void setIncomeUser (final User incomeUser);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.model.income;
-
-import java.io.Serializable;
-
-/**
- * An utilities class for incomes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.model.income.interval;
-
-import java.io.Serializable;
-
-/**
- * An enumeration for income/expenses intervals
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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
- * <p>
- * @return Message key (i18n)
- */
- public String getMessageKey () {
- return this.messageKey;
- }
-
- /**
- * Getter for CSS style class
- * <p>
- * @return CSS style class
- */
- public String getStyleClass () {
- return this.styleClass;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface BillableReceipt extends Comparable<BillableReceipt>, Serializable {
-
- /**
- * Getter for receipt bar-code number
- * <p>
- * @return Receipt bar-code number
- */
- String getReceiptBarCodeNumber ();
-
- /**
- * Setter for receipt bar-code number
- * <p>
- * @param receiptBarCodeNumber Receipt bar-code number
- */
- void setReceiptBarCodeNumber (final String receiptBarCodeNumber);
-
- /**
- * Getter for receipt's assigned bonus card
- * <p>
- * @return Receipt's assigned bonus card
- */
- BonusCard getReceiptBonusCard ();
-
- /**
- * Setter for receipt's assigned bonus card
- * <p>
- * @param receiptBonusCard Receipt's assigned bonus card
- */
- void setReceiptBonusCard (final BonusCard receiptBonusCard);
-
- /**
- * Getter for when this receipt has been created in database
- * <p>
- * @return Receipt creation timestamp
- */
- Date getReceiptCreated ();
-
- /**
- * Setter for when this receipt has been created in database
- * <p>
- * @param receiptUpdated Receipt updated timestamp
- */
- void setReceiptUpdated (final Date receiptUpdated);
-
- /**
- * Getter for when this receipt has been updated in database
- * <p>
- * @return Receipt updated timestamp
- */
- Date getReceiptUpdated ();
-
- /**
- * Setter for when this receipt has been updated in database
- * <p>
- * @param receiptCreated Receipt creation timestamp
- */
- void setReceiptCreated (final Date receiptCreated);
-
- /**
- * Getter for when this receipt has been issued (as written on it)
- * <p>
- * @return Receipt issue timestamp
- */
- Date getReceiptIssued ();
-
- /**
- * Setter for when this receipt has been issued (as written on it)
- * <p>
- * @param receiptIssued Receipt issue timestamp
- */
- void setReceiptIssued (final Date receiptIssued);
-
- /**
- * Getter for primary key
- * <p>
- * @return Primary key
- */
- Long getReceiptId ();
-
- /**
- * Setter for primary key
- * <p>
- * @param receiptId Primary key
- */
- void setReceiptId (final Long receiptId);
-
- /**
- * Getter for seller (employee)
- * <p>
- * @return Seller (employee)
- */
- Employable getReceiptSellerEmployee ();
-
- /**
- * Setter for seller (employee)
- * <p>
- * @param receiptSellerEmployee Seller (employee)
- */
- void setReceiptSellerEmployee (final Employable receiptSellerEmployee);
-
- /**
- * Getter for receipt number
- * <p>
- * @return Receipt number
- */
- String getReceiptNumber ();
-
- /**
- * Setter for receipt number
- * <p>
- * @param receiptNumber Receipt number
- */
- void setReceiptNumber (final String receiptNumber);
-
- /**
- * Getter for receipt register's number (cash register's number)
- * <p>
- * @return Receipt register's number
- */
- Long getReceiptRegisterNumber ();
-
- /**
- * Setter for receipt register's number (cash register's number)
- * <p>
- * @param receiptRegisterNumber Receipt register's number
- */
- void setReceiptRegisterNumber (final Long receiptRegisterNumber);
-
- /**
- * Getter for receipt's user
- * <p>
- * @return Receipt's user
- */
- User getReceiptUser ();
-
- /**
- * Setter for receipt's user
- * <p>
- * @param receiptUser Receipt's user
- */
- void setReceiptUser (final User receiptUser);
-
- /**
- * Getter for branch office instance
- * <p>
- * @return Branch office instance
- */
- BranchOffice getReceiptBranchOffice ();
-
- /**
- * Setter for branch office instance
- * <p>
- * @param receiptBranch Branch office instance
- */
- void setReceiptBranchOffice (final BranchOffice receiptBranch);
-
- /**
- * Getter for payment type
- * <p>
- * @return Payment type
- */
- PaymentType getReceiptPaymentType ();
-
- /**
- * Setter for payment type
- * <p>
- * @param receiptPaymentType Payment type
- */
- void setReceiptPaymentType (final PaymentType receiptPaymentType);
-
- /**
- * Getter for receipt sequence number
- * <p>
- * @return Receipt sequence number
- */
- Long getReceiptSequenceNumber ();
-
- /**
- * Setter for receipt sequence number
- * <p>
- * @param receiptSequenceNumber Receipt sequence number
- */
- void setReceiptSequenceNumber (final Long receiptSequenceNumber);
-
- /**
- * Getter for receipt transaction number
- * <p>
- * @return Receipt transaction number
- */
- Long getReceiptTransactionNumber ();
-
- /**
- * Setter for receipt transaction number
- * <p>
- * @param receiptTransactionNumber Receipt transaction number
- */
- void setReceiptTransactionNumber (final Long receiptTransactionNumber);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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
- * <p>
- * @param receiptPaymentType Payment type
- * @param receiptBranchOffice Branch office instance
- * @param receiptUser User instance
- * @param receiptIssued When this receipt has been issued
- * <p>
- * @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
- * <p>
- * @param receiptPaymentType Payment type
- * @param receiptBranchOffice Branch office instance
- * @param receiptIssued When this receipt has been issued
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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<roland@mxchange.org>
- */
-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.
- * <p>
- * @param receipt1 BillableReceipt instance 1
- * @param receipt2 BillableReceipt instance 2
- * <p>
- * @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.
- * <p>
- * @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.
- * <p>
- * @param receipt1 BillableReceipt instance 1
- * @param receipt2 BillableReceipt instance 2
- * <p>
- * @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
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface BillableReceiptItem extends Comparable<BillableReceiptItem>, Serializable {
-
- /**
- * Getter when this receipt item has been created in database
- * <p>
- * @return When this item has been created
- */
- Date getItemCreated ();
-
- /**
- * Setter when this receipt item has been created in database
- * <p>
- * @param itemCreated When this item has been created
- */
- void setItemCreated (final Date itemCreated);
-
- /**
- * Getter for primary key
- * <p>
- * @return Primary key
- */
- Long getItemId ();
-
- /**
- * Setter for primary key
- * <p>
- * @param itemId Primary key
- */
- void setItemId (final Long itemId);
-
- /**
- * Getter for whether the item is a discount on whole receipt
- * <p>
- * @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
- * <p>
- * @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
- * <p>
- * @return Whether the item is a refund
- */
- Boolean getItemIsRefund ();
-
- /**
- * Setter for whether the item is a refund
- * <p>
- * @param itemIsRefund Whether the item is a refund
- */
- void setItemIsRefund (final Boolean itemIsRefund);
-
- /**
- * Getter for receipt instance
- * <p>
- * @return Receipt instance
- */
- BillableReceipt getItemReceipt ();
-
- /**
- * Setter for receipt instance
- * <p>
- * @param itemReceipt Receipt instance
- */
- void setItemReceipt (final BillableReceipt itemReceipt);
-
- /**
- * Getter for linked product
- * <p>
- * @return Product
- */
- Product getItemProduct ();
-
- /**
- * Setter for linked product
- * <p>
- * @param itemProduct Product
- */
- void setItemProduct (final Product itemProduct);
-
- /**
- * Getter for product quantity
- * <p>
- * @return Product quantity
- */
- BigDecimal getItemProductQuantity ();
-
- /**
- * Setter for product quantity
- * <p>
- * @param itemProductQuantity Product quantity
- */
- void setItemProductQuantity (final BigDecimal itemProductQuantity);
-
- /**
- * Getter for item's net price
- * <p>
- * @return Item's net price
- */
- BigDecimal getItemNetPrice ();
-
- /**
- * Setter for item's net price
- * <p>
- * @param itemNetPrice Item's net price
- */
- void setItemNetPrice (final BigDecimal itemNetPrice);
-
- /**
- * Getter for item's tax rate
- * <p>
- * @return Item's tax rate
- */
- BigDecimal getItemTaxRate ();
-
- /**
- * Setter for item's tax rate
- * <p>
- * @param itemTaxRate Item's tax rate
- */
- void setItemTaxRate (final BigDecimal itemTaxRate);
-
- /**
- * Getter for item's gross price
- * <p>
- * @return Item's gross price
- */
- BigDecimal getItemGrossPrice ();
-
- /**
- * Setter for item's gross price
- * <p>
- * @param itemGrossPrice Item's gross price
- */
- void setItemGrossPrice (final BigDecimal itemGrossPrice);
-
- /**
- * Getter for manufacturer/producer of this item
- * <p>
- * @return Manufacturer/producer of this item
- */
- BasicData getItemManufacturer ();
-
- /**
- * Setter for manufacturer/producer of this item
- * <p>
- * @param itemManufacturer Manufacturer/producer of this item
- */
- void setItemManufacturer (final BasicData itemManufacturer);
-
- /**
- * Getter for item brand name
- * <p>
- * @return Item brand name
- */
- String getItemBrandName ();
-
- /**
- * Setter for item brand name
- * <p>
- * @param itemBrandName Item brand name
- */
- void setItemBrandName (final String itemBrandName);
-
- /**
- * Getter for item number
- * <p>
- * @return Item number
- */
- Long getItemNumber ();
-
- /**
- * Setter for item number
- * <p>
- * @param itemNumber Item number
- */
- void setItemNumber (final Long itemNumber);
-
- /**
- * Getter for item's coupon number
- * <p>
- * @return Item's coupon number
- */
- String getItemCouponNumber ();
-
- /**
- * Setter for item's coupon number
- * <p>
- * @param itemCouponNumber Item's coupon number
- */
- void setItemCouponNumber (final String itemCouponNumber);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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<roland@mxchange.org>
- */
-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.
- * <p>
- * @param receiptItem1 Receipt item 1
- * @param receiptItem2 Receipt item 2
- * <p>
- * @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
- }
-
-}