Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

EditTransactionForm.h

Go to the documentation of this file.
00001 /** $Revision: 1.29 $
00002     Last updated: $Date: 2002/12/19 22:52:47 $
00003     
00004     Copyright (C) 2000-2002 Vlad Mereuta <dizzy@users.sourceforge.net>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00019 
00020 #ifndef __EDIT_TRANSACTION_FORM__
00021 #define __EDIT_TRANSACTION_FORM__
00022 
00023 #include <PalmOS.h>
00024 
00025 #include "Form.h"
00026 #include "TransactionsDB.h"
00027 #include "EditScheduledTransForm.h"
00028 #include "NoteForm.h"
00029 #include "SplitsForm.h"
00030 #include "CalcForm.h"
00031 #include "EditRateForm.h"
00032 
00033 ///the form is used to create a new transaction or to modify an existing one, depending on the record_is_new member
00034 class EditTransactionForm : public Form
00035 {
00036 public:
00037     //    typedef enum {autocompletion=1,splits,calculator,note} updateCodes;
00038     
00039     ///constructor
00040     EditTransactionForm() FORM_SECTION2;
00041     ///destructor - disposes of allocated memory
00042     virtual ~EditTransactionForm() FORM_SECTION2;
00043     
00044     ///returns singleton reference to this object
00045     static EditTransactionForm* instance() FORM_SECTION2;
00046 
00047     ///@return value of member trans_id
00048     UInt16  getTransId() { return _trans_id; }
00049     ///sets value of memeber trans_id
00050     void setTransId(UInt16 i) { _trans_id=i; }
00051     ///sets value of trans_is_sched
00052     void setTransIsSched(Boolean b) { _trans_is_sched = b; }
00053     ///sets value of records_is_new
00054     void setRecordIsNew(Boolean b) { _record_is_new = b; }
00055     /// @return value of record_is_new
00056     bool getRecordIsNew() { return _record_is_new; }
00057 
00058 private:
00059     ///reference to this object
00060     static EditTransactionForm* _instance;
00061     /// this is set to true if we want to create a new account and to false if we want the 'details' functionality
00062     Boolean _record_is_new;
00063     /// set to true when creating/editing a scheduled transaction
00064     Boolean _trans_is_sched;
00065     /// true if the current transaction is a debit
00066     Boolean _is_debit;
00067     ///id of the transaction being manipulated
00068     UInt16 _trans_id;
00069     ///structure used to hold data entered by user
00070     transactionStructure t;
00071     //the peer account for this transaction
00072     UInt32 _peer_acc;
00073     ///name of the account chosen as peer
00074     Char _acc_name[60];
00075     ///date text
00076     Char _date_txt[dateStringLength];
00077     ///label for debit button
00078     Char _debit_label[32];
00079     ///label for credit button
00080     Char _credit_label[32];
00081     ///last matched payee; null if none
00082     char _matched_payee[32];
00083     ///last unmatched payee. used to avoid screen updates and db checks whenever possible
00084     char _last_unmatched_payee[32];
00085 
00086     /** transaction scheduling form is accessed through this object. As scheduling is only accessed from
00087         this form, the scheduling form is an object contained within this class */
00088     EditScheduledTransForm _edit_scheduled_trans_form;
00089     /// classify current split configuration 
00090     UInt8 _trans_class;
00091     /// index of the split that affects the current account
00092     UInt8 _this_split;
00093     /// index of the split that affects the peer account, if applicable
00094     UInt8 _peer_split;
00095     /// remember which account was selected when form was opened
00096     UInt32 _prev_acc_uid;
00097 
00098     ///form to handle notes
00099     NoteForm* _note_form;
00100     ///form handlind split management
00101     SplitsForm* _splits_form;
00102     ///generic calculator
00103     CalculatorForm* _calculator_form;
00104     ///form to handle currency conversion rates
00105     EditRateForm* _edit_rate_form;
00106 
00107     /** handle possiblity of currency exchange; Show the button accessing the currency form iff there are only
00108        two accounts involved and they use different currencies */
00109     bool _show_rate;
00110 
00111     /// pre-save data check, returns true if data is good, false otherwise.
00112     Boolean checkData() FORM_SECTION2;
00113     ///saves the transaction data and updates all the accounts involved
00114     void save() FORM_SECTION2;
00115     ///set the values for some of the fields in the form (from the transaction record)
00116     void setDefaults() FORM_SECTION2;
00117     /// reflect peer account and transaction amount in underlying splits array
00118     void saveToSplits() FORM_SECTION2;
00119     /// update amount and peer account according to the underlying splits array
00120     void readFromSplits() FORM_SECTION2;
00121     ///displays the name for the given account
00122     void setPeerAccount(UInt32 account) FORM_SECTION2;
00123     /** handle keystrokes and optionally autocomplete.
00124            Autocompletion follows the following steps:
00125            * intercept all keystrokes except virtual ones (from handleKeyDownEvent)
00126            Cache the following cases:
00127              - previously matched the input against a longer payee. If keystrokes continue to fit the previous match, do not re-check DB or update screen
00128              - previously could not find any payee starting with the text in the input. Any other input starting with that text is considered un-matchable
00129 
00130            * attempt to find a transaction from the current account matching the payee
00131            * if one is found, copy splits, full text and method
00132            * otherwise just try to match a transaction with the same payee and fill in the payee and method 
00133            @return true if something updated, false otherwise*/
00134     bool handleAutocompletion() FORM_SECTION2;
00135 
00136     ///draws form and table
00137     Boolean handleOpenEvent() FORM_SECTION2;
00138     /// form close
00139     Boolean handleCloseEvent() FORM_SECTION2;
00140     ///autocompletion hook
00141     Boolean handleKeyDownEvent (WChar key_id, UInt16 modifiers) FORM_SECTION2;
00142     ///handles form controls
00143     Boolean handleCtlSelectEvent (UInt16 control_id) FORM_SECTION2;
00144     ///handles update events
00145     Boolean handleUpdateEvent (UInt16 update_code) FORM_SECTION2;
00146 };
00147 #endif

Generated on Thu Jan 16 23:11:12 2003 for FreeCoins by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002