View Javadoc
1   /*
2    * MoneyWise: Finance Application
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.moneywise.quicken.file;
18  
19  import io.github.tonywasher.joceanus.moneywise.quicken.definitions.MoneyWiseQEventLineType;
20  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFAccount.MoneyWiseQIFXferAccountLine;
21  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFEventCategory.MoneyWiseQIFCategoryLine;
22  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFMoneyLine;
23  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFRateLine;
24  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFStringLine;
25  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney;
26  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusRate;
27  
28  import java.util.List;
29  
30  /**
31   * Split Event Record.
32   */
33  public class MoneyWiseQIFSplitEvent
34          extends MoneyWiseQIFRecord<MoneyWiseQEventLineType> {
35      /**
36       * The Event Category.
37       */
38      private final MoneyWiseQIFEventCategory theCategory;
39  
40      /**
41       * The Transfer Account.
42       */
43      private final MoneyWiseQIFAccount theAccount;
44  
45      /**
46       * The Amount.
47       */
48      private OceanusMoney theAmount;
49  
50      /**
51       * The Percentage.
52       */
53      private OceanusRate thePercentage;
54  
55      /**
56       * The Comment.
57       */
58      private String theComment;
59  
60      /**
61       * Constructor.
62       *
63       * @param pCategory the category
64       */
65      protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFEventCategory pCategory) {
66          this(pCategory, null);
67      }
68  
69      /**
70       * Constructor.
71       *
72       * @param pCategory the category
73       * @param pClasses  the classes
74       */
75      protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFEventCategory pCategory,
76                                       final List<MoneyWiseQIFClass> pClasses) {
77          /* Call Super-constructor */
78          super(MoneyWiseQEventLineType.class);
79  
80          /* Set values */
81          theCategory = pCategory;
82          theAccount = null;
83          theAmount = null;
84          thePercentage = null;
85          theComment = null;
86  
87          /* Add the line */
88          addLine(new MoneyWiseQIFEventSplitCategoryLine(theCategory, pClasses));
89      }
90  
91      /**
92       * Constructor.
93       *
94       * @param pAccount the transfer account
95       */
96      protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFAccount pAccount) {
97          /* Call Super-constructor */
98          this(pAccount, null);
99      }
100 
101     /**
102      * Constructor.
103      *
104      * @param pAccount the transfer account
105      * @param pClasses the classes
106      */
107     protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFAccount pAccount,
108                                      final List<MoneyWiseQIFClass> pClasses) {
109         /* Call Super-constructor */
110         super(MoneyWiseQEventLineType.class);
111 
112         /* Set values */
113         theCategory = null;
114         theAccount = pAccount;
115         theAmount = null;
116         thePercentage = null;
117         theComment = null;
118 
119         /* Add the line */
120         addLine(new MoneyWiseQIFEventSplitAccountLine(pAccount, pClasses));
121     }
122 
123     /**
124      * Obtain the event category.
125      *
126      * @return the event category.
127      */
128     public MoneyWiseQIFEventCategory getCategory() {
129         return theCategory;
130     }
131 
132     /**
133      * Obtain the account.
134      *
135      * @return the account.
136      */
137     public MoneyWiseQIFAccount getAccount() {
138         return theAccount;
139     }
140 
141     /**
142      * Obtain the amount.
143      *
144      * @return the amount.
145      */
146     public OceanusMoney getAmount() {
147         return theAmount;
148     }
149 
150     /**
151      * Obtain the percentage.
152      *
153      * @return the percentage.
154      */
155     public OceanusRate getPercentage() {
156         return thePercentage;
157     }
158 
159     /**
160      * Obtain the comment.
161      *
162      * @return the comment.
163      */
164     public String getComment() {
165         return theComment;
166     }
167 
168     /**
169      * Set the split amount.
170      *
171      * @param pAmount the amount
172      */
173     protected void setSplitAmount(final OceanusMoney pAmount) {
174         /* Add the line */
175         addLine(new MoneyWiseQIFEventSplitAmountLine(pAmount));
176         theAmount = pAmount;
177     }
178 
179     /**
180      * Set the split percentage.
181      *
182      * @param pPercent the percentage
183      */
184     protected void setSplitPercentage(final OceanusRate pPercent) {
185         /* Add the line */
186         addLine(new MoneyWiseQIFEventSplitPercentLine(pPercent));
187         thePercentage = pPercent;
188     }
189 
190     /**
191      * Set the split comment.
192      *
193      * @param pComment the comment
194      */
195     protected void setSplitComment(final String pComment) {
196         /* Add the line */
197         addLine(new MoneyWiseQIFEventSplitCommentLine(pComment));
198         theComment = pComment;
199     }
200 
201     /**
202      * The Event Split Account line.
203      */
204     public static class MoneyWiseQIFEventSplitAccountLine
205             extends MoneyWiseQIFXferAccountLine<MoneyWiseQEventLineType> {
206         /**
207          * Constructor.
208          *
209          * @param pAccount the account
210          */
211         protected MoneyWiseQIFEventSplitAccountLine(final MoneyWiseQIFAccount pAccount) {
212             /* Call super-constructor */
213             super(pAccount);
214         }
215 
216         /**
217          * Constructor.
218          *
219          * @param pAccount the account
220          * @param pClasses the classes
221          */
222         protected MoneyWiseQIFEventSplitAccountLine(final MoneyWiseQIFAccount pAccount,
223                                                     final List<MoneyWiseQIFClass> pClasses) {
224             /* Call super-constructor */
225             super(pAccount, pClasses);
226         }
227 
228         @Override
229         public MoneyWiseQEventLineType getLineType() {
230             return MoneyWiseQEventLineType.SPLITCATEGORY;
231         }
232     }
233 
234     /**
235      * The Event Split Category line.
236      */
237     public static class MoneyWiseQIFEventSplitCategoryLine
238             extends MoneyWiseQIFCategoryLine<MoneyWiseQEventLineType> {
239         /**
240          * Constructor.
241          *
242          * @param pCategory the category
243          */
244         protected MoneyWiseQIFEventSplitCategoryLine(final MoneyWiseQIFEventCategory pCategory) {
245             /* Call super-constructor */
246             super(pCategory);
247         }
248 
249         /**
250          * Constructor.
251          *
252          * @param pCategory the category
253          * @param pClasses  the classes
254          */
255         protected MoneyWiseQIFEventSplitCategoryLine(final MoneyWiseQIFEventCategory pCategory,
256                                                      final List<MoneyWiseQIFClass> pClasses) {
257             /* Call super-constructor */
258             super(pCategory, pClasses);
259         }
260 
261         @Override
262         public MoneyWiseQEventLineType getLineType() {
263             return MoneyWiseQEventLineType.SPLITCATEGORY;
264         }
265     }
266 
267     /**
268      * The Event Split Amount line.
269      */
270     public static class MoneyWiseQIFEventSplitAmountLine
271             extends MoneyWiseQIFMoneyLine<MoneyWiseQEventLineType> {
272         /**
273          * Constructor.
274          *
275          * @param pAmount the amount
276          */
277         protected MoneyWiseQIFEventSplitAmountLine(final OceanusMoney pAmount) {
278             /* Call super-constructor */
279             super(pAmount);
280         }
281 
282         /**
283          * Obtain Amount.
284          *
285          * @return the amount
286          */
287         public OceanusMoney getAmount() {
288             return getMoney();
289         }
290 
291         @Override
292         public MoneyWiseQEventLineType getLineType() {
293             return MoneyWiseQEventLineType.SPLITAMOUNT;
294         }
295     }
296 
297     /**
298      * The Event Split Percent line.
299      */
300     public static class MoneyWiseQIFEventSplitPercentLine
301             extends MoneyWiseQIFRateLine<MoneyWiseQEventLineType> {
302         /**
303          * Constructor.
304          *
305          * @param pPercent the percentage
306          */
307         protected MoneyWiseQIFEventSplitPercentLine(final OceanusRate pPercent) {
308             /* Call super-constructor */
309             super(pPercent);
310         }
311 
312         /**
313          * Obtain Percentage.
314          *
315          * @return the percentage
316          */
317         public OceanusRate getPercentage() {
318             return getRate();
319         }
320 
321         @Override
322         public MoneyWiseQEventLineType getLineType() {
323             return MoneyWiseQEventLineType.SPLITPERCENT;
324         }
325     }
326 
327     /**
328      * The Event Split Comment line.
329      */
330     public static class MoneyWiseQIFEventSplitCommentLine
331             extends MoneyWiseQIFStringLine<MoneyWiseQEventLineType> {
332         /**
333          * Constructor.
334          *
335          * @param pComment the comment
336          */
337         protected MoneyWiseQIFEventSplitCommentLine(final String pComment) {
338             /* Call super-constructor */
339             super(pComment);
340         }
341 
342         @Override
343         public MoneyWiseQEventLineType getLineType() {
344             return MoneyWiseQEventLineType.SPLITCOMMENT;
345         }
346 
347         /**
348          * Obtain Comment.
349          *
350          * @return the comment
351          */
352         public String getComment() {
353             return getValue();
354         }
355     }
356 }