-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor monthly reporting and add invoice entity
- Loading branch information
Showing
19 changed files
with
666 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...ganization-fees/src/main/java/net/savantly/nexus/orgfees/dom/invoice/InvoiceLineItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package net.savantly.nexus.orgfees.dom.invoice; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Comparator; | ||
import java.util.UUID; | ||
|
||
import org.apache.causeway.applib.annotation.Bounding; | ||
import org.apache.causeway.applib.annotation.DomainObject; | ||
import org.apache.causeway.applib.annotation.DomainObjectLayout; | ||
import org.apache.causeway.applib.annotation.Editing; | ||
import org.apache.causeway.applib.annotation.Property; | ||
import org.apache.causeway.applib.annotation.PropertyLayout; | ||
import org.apache.causeway.applib.annotation.Publishing; | ||
import org.apache.causeway.applib.annotation.Where; | ||
import org.apache.causeway.applib.jaxb.PersistentEntityAdapter; | ||
import org.apache.causeway.persistence.jpa.applib.integration.CausewayEntityListener; | ||
|
||
import jakarta.inject.Named; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.xml.bind.annotation.XmlElement; | ||
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.val; | ||
import net.savantly.nexus.organizations.OrganizationsModule; | ||
|
||
@Named(OrganizationsModule.NAMESPACE + ".InvoiceLineItem") | ||
@jakarta.persistence.Entity | ||
@jakarta.persistence.Table(schema = OrganizationsModule.SCHEMA) | ||
@jakarta.persistence.EntityListeners(CausewayEntityListener.class) | ||
@DomainObject(entityChangePublishing = Publishing.ENABLED, editing = Editing.DISABLED, bounding = Bounding.BOUNDED) | ||
@DomainObjectLayout(cssClassFa = "file-lines", named = "Invoice Line Item") | ||
@NoArgsConstructor(access = AccessLevel.PUBLIC) | ||
@XmlJavaTypeAdapter(PersistentEntityAdapter.class) | ||
@ToString(onlyExplicitlyIncluded = true) | ||
public class InvoiceLineItem implements Comparable<InvoiceLineItem> { | ||
|
||
public static InvoiceLineItem withRequiredFields(String id, Invoice invoice) { | ||
val entity = new InvoiceLineItem(); | ||
entity.id = id; | ||
entity.invoice = invoice; | ||
|
||
return entity; | ||
} | ||
|
||
public static InvoiceLineItem withRequiredFields(Invoice invoice) { | ||
val id = UUID.randomUUID().toString(); | ||
return withRequiredFields(id, invoice); | ||
} | ||
|
||
// *** PROPERTIES *** | ||
|
||
@Id | ||
@Column(name = "id", nullable = false) | ||
@Getter | ||
private String id; | ||
|
||
@jakarta.persistence.Version | ||
@jakarta.persistence.Column(name = "version", nullable = false) | ||
@PropertyLayout(fieldSetId = "metadata", sequence = "999", hidden = Where.PARENTED_TABLES) | ||
@Getter | ||
@Setter | ||
private long version; | ||
|
||
@Getter | ||
@Property | ||
@PropertyLayout(fieldSetId = "identity") | ||
@ManyToOne | ||
private Invoice invoice; | ||
|
||
@Column(name = "purchase_date") | ||
@PropertyLayout(fieldSetId = "identity") | ||
@Getter | ||
@Setter | ||
private LocalDate purchaseDate; | ||
|
||
@Getter | ||
@Setter | ||
@Property | ||
@PropertyLayout(fieldSetId = "identity") | ||
private String productName; | ||
|
||
@Getter | ||
@Setter | ||
@Property | ||
@PropertyLayout(fieldSetId = "identity") | ||
private String productDescription; | ||
|
||
@Getter | ||
@Setter | ||
@Property | ||
@PropertyLayout(fieldSetId = "identity") | ||
private String productBillingInterval; | ||
|
||
@Getter | ||
@Setter | ||
@Property | ||
@PropertyLayout(fieldSetId = "identity") | ||
private double productBillingAmount; | ||
|
||
@Getter | ||
@Setter | ||
@Property | ||
@PropertyLayout(fieldSetId = "identity") | ||
private double productQuantity; | ||
|
||
|
||
private final static Comparator<InvoiceLineItem> comparator = Comparator.comparing(s -> s.purchaseDate); | ||
|
||
@Override | ||
public int compareTo(final InvoiceLineItem other) { | ||
return comparator.compare(this, other); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...nization-fees/src/main/java/net/savantly/nexus/orgfees/dom/invoice/InvoiceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package net.savantly.nexus.orgfees.dom.invoice; | ||
|
||
import java.util.Set; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface InvoiceRepository extends JpaRepository<Invoice, String>{ | ||
|
||
Set<Invoice> findByOrganizationId(String id); | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...rganization-fees/src/main/java/net/savantly/nexus/orgfees/dom/invoice/Invoice_delete.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package net.savantly.nexus.orgfees.dom.invoice; | ||
|
||
|
||
import org.apache.causeway.applib.annotation.Action; | ||
import org.apache.causeway.applib.annotation.ActionLayout; | ||
import org.apache.causeway.applib.annotation.PriorityPrecedence; | ||
import org.apache.causeway.applib.annotation.PromptStyle; | ||
import org.apache.causeway.applib.annotation.SemanticsOf; | ||
import org.apache.causeway.applib.services.message.MessageService; | ||
import org.apache.causeway.applib.services.repository.RepositoryService; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.persistence.Transient; | ||
import net.savantly.nexus.organizations.dom.organization.Organization; | ||
|
||
@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE) | ||
@jakarta.annotation.Priority(PriorityPrecedence.EARLY) | ||
@lombok.RequiredArgsConstructor(onConstructor_ = { @Inject }) | ||
public class Invoice_delete { | ||
|
||
final Invoice object; | ||
|
||
public static class ActionEvent | ||
extends | ||
org.apache.causeway.applib.CausewayModuleApplib.ActionDomainEvent<Invoice_delete> { | ||
} | ||
|
||
@Inject | ||
@Transient | ||
RepositoryService repositoryService; | ||
@Inject | ||
@Transient | ||
MessageService messageService; | ||
|
||
@ActionLayout(named = "Delete Invoice", promptStyle = PromptStyle.DIALOG) | ||
public Organization act() { | ||
var organization = object.getOrganization(); | ||
repositoryService.remove(object); | ||
messageService.informUser("Deleted " + object); | ||
return organization; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.