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.oceanus.decimal.OceanusMoney;
20  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusRate;
21  import io.github.tonywasher.joceanus.moneywise.quicken.definitions.MoneyWiseQEventLineType;
22  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFCategoryLine;
23  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFMoneyLine;
24  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFRateLine;
25  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFStringLine;
26  import io.github.tonywasher.joceanus.moneywise.quicken.file.MoneyWiseQIFLine.MoneyWiseQIFXferAccountLine;
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 pFile     the QIF File
64       * @param pCategory the category
65       */
66      protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFFile pFile,
67                                       final MoneyWiseQIFEventCategory pCategory) {
68          this(pFile, pCategory, null);
69      }
70  
71      /**
72       * Constructor.
73       *
74       * @param pFile     the QIF File
75       * @param pCategory the category
76       * @param pClasses  the classes
77       */
78      protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFFile pFile,
79                                       final MoneyWiseQIFEventCategory pCategory,
80                                       final List<MoneyWiseQIFClass> pClasses) {
81          /* Call Super-constructor */
82          super(pFile, MoneyWiseQEventLineType.class);
83  
84          /* Set values */
85          theCategory = pCategory;
86          theAccount = null;
87          theAmount = null;
88          thePercentage = null;
89          theComment = null;
90  
91          /* Add the line */
92          addLine(new MoneyWiseQIFEventSplitCategoryLine(theCategory, pClasses));
93      }
94  
95      /**
96       * Constructor.
97       *
98       * @param pFile    the QIF File
99       * @param pAccount the transfer account
100      */
101     protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFFile pFile,
102                                      final MoneyWiseQIFAccount pAccount) {
103         /* Call Super-constructor */
104         this(pFile, pAccount, null);
105     }
106 
107     /**
108      * Constructor.
109      *
110      * @param pFile    the QIF File
111      * @param pAccount the transfer account
112      * @param pClasses the classes
113      */
114     protected MoneyWiseQIFSplitEvent(final MoneyWiseQIFFile pFile,
115                                      final MoneyWiseQIFAccount pAccount,
116                                      final List<MoneyWiseQIFClass> pClasses) {
117         /* Call Super-constructor */
118         super(pFile, MoneyWiseQEventLineType.class);
119 
120         /* Set values */
121         theCategory = null;
122         theAccount = pAccount;
123         theAmount = null;
124         thePercentage = null;
125         theComment = null;
126 
127         /* Add the line */
128         addLine(new MoneyWiseQIFEventSplitAccountLine(pAccount, pClasses));
129     }
130 
131     /**
132      * Obtain the event category.
133      *
134      * @return the event category.
135      */
136     public MoneyWiseQIFEventCategory getCategory() {
137         return theCategory;
138     }
139 
140     /**
141      * Obtain the account.
142      *
143      * @return the account.
144      */
145     public MoneyWiseQIFAccount getAccount() {
146         return theAccount;
147     }
148 
149     /**
150      * Obtain the amount.
151      *
152      * @return the amount.
153      */
154     public OceanusMoney getAmount() {
155         return theAmount;
156     }
157 
158     /**
159      * Obtain the percentage.
160      *
161      * @return the percentage.
162      */
163     public OceanusRate getPercentage() {
164         return thePercentage;
165     }
166 
167     /**
168      * Obtain the comment.
169      *
170      * @return the comment.
171      */
172     public String getComment() {
173         return theComment;
174     }
175 
176     /**
177      * Set the split amount.
178      *
179      * @param pAmount the amount
180      */
181     protected void setSplitAmount(final OceanusMoney pAmount) {
182         /* Add the line */
183         addLine(new MoneyWiseQIFEventSplitAmountLine(pAmount));
184         theAmount = pAmount;
185     }
186 
187     /**
188      * Set the split percentage.
189      *
190      * @param pPercent the percentage
191      */
192     protected void setSplitPercentage(final OceanusRate pPercent) {
193         /* Add the line */
194         addLine(new MoneyWiseQIFEventSplitPercentLine(pPercent));
195         thePercentage = pPercent;
196     }
197 
198     /**
199      * Set the split comment.
200      *
201      * @param pComment the comment
202      */
203     protected void setSplitComment(final String pComment) {
204         /* Add the line */
205         addLine(new MoneyWiseQIFEventSplitCommentLine(pComment));
206         theComment = pComment;
207     }
208 
209     /**
210      * The Event Split Account line.
211      */
212     public class MoneyWiseQIFEventSplitAccountLine
213             extends MoneyWiseQIFXferAccountLine<MoneyWiseQEventLineType> {
214         /**
215          * Constructor.
216          *
217          * @param pAccount the account
218          */
219         protected MoneyWiseQIFEventSplitAccountLine(final MoneyWiseQIFAccount pAccount) {
220             /* Call super-constructor */
221             super(pAccount);
222         }
223 
224         /**
225          * Constructor.
226          *
227          * @param pAccount the account
228          * @param pClasses the classes
229          */
230         protected MoneyWiseQIFEventSplitAccountLine(final MoneyWiseQIFAccount pAccount,
231                                                     final List<MoneyWiseQIFClass> pClasses) {
232             /* Call super-constructor */
233             super(pAccount, pClasses);
234         }
235 
236         @Override
237         public MoneyWiseQEventLineType getLineType() {
238             return MoneyWiseQEventLineType.SPLITCATEGORY;
239         }
240     }
241 
242     /**
243      * The Event Split Category line.
244      */
245     public class MoneyWiseQIFEventSplitCategoryLine
246             extends MoneyWiseQIFCategoryLine<MoneyWiseQEventLineType> {
247         /**
248          * Constructor.
249          *
250          * @param pCategory the category
251          */
252         protected MoneyWiseQIFEventSplitCategoryLine(final MoneyWiseQIFEventCategory pCategory) {
253             /* Call super-constructor */
254             super(pCategory);
255         }
256 
257         /**
258          * Constructor.
259          *
260          * @param pCategory the category
261          * @param pClasses  the classes
262          */
263         protected MoneyWiseQIFEventSplitCategoryLine(final MoneyWiseQIFEventCategory pCategory,
264                                                      final List<MoneyWiseQIFClass> pClasses) {
265             /* Call super-constructor */
266             super(pCategory, pClasses);
267         }
268 
269         @Override
270         public MoneyWiseQEventLineType getLineType() {
271             return MoneyWiseQEventLineType.SPLITCATEGORY;
272         }
273     }
274 
275     /**
276      * The Event Split Amount line.
277      */
278     public class MoneyWiseQIFEventSplitAmountLine
279             extends MoneyWiseQIFMoneyLine<MoneyWiseQEventLineType> {
280         /**
281          * Constructor.
282          *
283          * @param pAmount the amount
284          */
285         protected MoneyWiseQIFEventSplitAmountLine(final OceanusMoney pAmount) {
286             /* Call super-constructor */
287             super(pAmount);
288         }
289 
290         /**
291          * Obtain Amount.
292          *
293          * @return the amount
294          */
295         public OceanusMoney getAmount() {
296             return getMoney();
297         }
298 
299         @Override
300         public MoneyWiseQEventLineType getLineType() {
301             return MoneyWiseQEventLineType.SPLITAMOUNT;
302         }
303     }
304 
305     /**
306      * The Event Split Percent line.
307      */
308     public class MoneyWiseQIFEventSplitPercentLine
309             extends MoneyWiseQIFRateLine<MoneyWiseQEventLineType> {
310         /**
311          * Constructor.
312          *
313          * @param pPercent the percentage
314          */
315         protected MoneyWiseQIFEventSplitPercentLine(final OceanusRate pPercent) {
316             /* Call super-constructor */
317             super(pPercent);
318         }
319 
320         /**
321          * Obtain Percentage.
322          *
323          * @return the percentage
324          */
325         public OceanusRate getPercentage() {
326             return getRate();
327         }
328 
329         @Override
330         public MoneyWiseQEventLineType getLineType() {
331             return MoneyWiseQEventLineType.SPLITPERCENT;
332         }
333     }
334 
335     /**
336      * The Event Split Comment line.
337      */
338     public class MoneyWiseQIFEventSplitCommentLine
339             extends MoneyWiseQIFStringLine<MoneyWiseQEventLineType> {
340         /**
341          * Constructor.
342          *
343          * @param pComment the comment
344          */
345         protected MoneyWiseQIFEventSplitCommentLine(final String pComment) {
346             /* Call super-constructor */
347             super(pComment);
348         }
349 
350         @Override
351         public MoneyWiseQEventLineType getLineType() {
352             return MoneyWiseQEventLineType.SPLITCOMMENT;
353         }
354 
355         /**
356          * Obtain Comment.
357          *
358          * @return the comment
359          */
360         public String getComment() {
361             return getValue();
362         }
363     }
364 }