Package: InMemoryInvoice
InMemoryInvoice
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
InMemoryInvoice(Invoice.Builder) |
|
|
|
|
|
||||||||||||||||||||
findJobEvents() |
|
|
|
|
|
||||||||||||||||||||
lambda$findJobEvents$0() |
|
|
|
|
|
||||||||||||||||||||
toBuilder() |
|
|
|
|
|
Coverage
1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * blueHour: open source accounting
5: * http://tidalwave.it/projects/bluehour
6: *
7: * Copyright (C) 2013 - 2024 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/bluehour-src
22: * git clone https://github.com/tidalwave-it/bluehour-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.accounting.model.impl;
27:
28: import javax.annotation.Nonnull;
29: import javax.annotation.concurrent.Immutable;
30: import java.time.LocalDate;
31: import java.util.List;
32: import java.util.concurrent.CopyOnWriteArrayList;
33: import it.tidalwave.accounting.model.JobEvent;
34: import it.tidalwave.accounting.model.Project;
35: import it.tidalwave.accounting.model.spi.InvoiceSpi;
36: import it.tidalwave.accounting.model.types.Money;
37: import it.tidalwave.util.As;
38: import it.tidalwave.util.Finder;
39: import it.tidalwave.util.Id;
40: import lombok.EqualsAndHashCode;
41: import lombok.Getter;
42: import lombok.ToString;
43: import lombok.experimental.Delegate;
44:
45: /***************************************************************************************************************************************************************
46: *
47: * @author Fabrizio Giudici
48: *
49: **************************************************************************************************************************************************************/
50: @Immutable @EqualsAndHashCode @ToString(exclude = "as")
51: public class InMemoryInvoice implements InvoiceSpi
52: {
53: private static final long serialVersionUID = 1L;
54:
55: @Delegate
56: private final As as = As.forObject(this);
57:
58: @Getter @Nonnull
59: private final Id id;
60:
61: @Getter
62: private final String number;
63:
64: @Getter @Nonnull
65: private final Project project;
66:
67: @Nonnull
68: private final List<InMemoryJobEvent> jobEvents; // FIXME: immutablelist
69:
70: @Nonnull
71: private final LocalDate date;
72:
73: @Nonnull
74: private final LocalDate dueDate;
75:
76: @Getter @Nonnull
77: private final Money earnings;
78:
79: @Getter @Nonnull
80: private final Money tax;
81:
82: /***********************************************************************************************************************************************************
83: *
84: **********************************************************************************************************************************************************/
85: public /* FIXME private */ InMemoryInvoice (@Nonnull final Builder builder)
86: {
87: this.id = builder.getId();
88: this.number = builder.getNumber();
89: this.project = builder.getProject();
90: this.jobEvents = (List<InMemoryJobEvent>)builder.getJobEvents();
91: this.date = builder.getDate();
92: this.dueDate = builder.getDueDate(); // FIXME: round to the end of the month?
93: this.earnings = builder.getEarnings();
94: this.tax = builder.getTax();
95: }
96:
97: /***********************************************************************************************************************************************************
98: * {@inheritDoc}
99: **********************************************************************************************************************************************************/
100: @Override @Nonnull
101: public Finder<JobEvent> findJobEvents()
102: {
103: return Finder.ofSupplier(() -> new CopyOnWriteArrayList<>(jobEvents));
104: }
105:
106: /***********************************************************************************************************************************************************
107: * {@inheritDoc}
108: **********************************************************************************************************************************************************/
109: @Override @Nonnull
110: public Builder toBuilder()
111: {
112: return new Builder(id, number, project, jobEvents, date, dueDate, earnings, tax, Builder.Callback.DEFAULT);
113: }
114: }