Develop and Download Open Source Software

Browse Subversion Repository

Contents of /tags/FeliCa2Money-2.6/Transaction.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 189 - (show annotations) (download)
Tue Apr 8 13:03:07 2008 UTC (16 years ago) by tmurakam
File size: 3968 byte(s)
2.6 tag

1 /*
2 * FeliCa2Money
3 *
4 * Copyright (C) 2001-2008 Takuya Murakami
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 using System;
22 using System.Collections.Generic;
23 using System.Text;
24 using System.Collections;
25
26 namespace FeliCa2Money
27 {
28 public enum TransType
29 {
30 Int, // 利息
31 Div, // 配当
32 DirectDep, // 振り込み入金、取り立て入金、自動引き落とし戻し入金
33 Dep, // その他入金
34
35 Payment,
36 Cash,
37 ATM,
38 Check,
39 Debit // その他出金
40 }
41
42 public class Transaction
43 {
44 public int id = -1; // ID
45 public DateTime date;
46 public TransType type; // トランザクションタイプ
47 public string desc = "";
48 public string memo = "";
49 public int value = 0; // 金額
50 public int balance = 0; // 残高
51
52 private bool valid = true;
53
54 private static Hashtable TransIncome;
55 private static Hashtable TransOutgo;
56 private static Hashtable TransStrings;
57
58 static Transaction()
59 {
60 // initialize
61 TransStrings = new Hashtable();
62 TransStrings[TransType.Int] = "INT";
63 TransStrings[TransType.Div] = "DIV";
64 TransStrings[TransType.DirectDep] = "DIRECTDEP";
65 TransStrings[TransType.Dep] = "DEP";
66 TransStrings[TransType.Payment] = "PAYMENT";
67 TransStrings[TransType.Cash] = "CASH";
68 TransStrings[TransType.ATM] = "ATM";
69 TransStrings[TransType.Check] = "CHECK";
70 TransStrings[TransType.Debit] = "DEBIT";
71
72 TransIncome = new Hashtable();
73 TransIncome["利息"] = TransType.Int;
74 TransIncome["振込"] = TransType.DirectDep;
75 TransIncome["チャージ"]= TransType.DirectDep; // Edy チャージ
76 TransIncome["入金"] = TransType.DirectDep; // Suica チャージ
77
78 TransOutgo = new Hashtable();
79 TransOutgo["ATM"] = TransType.ATM;
80 TransOutgo["ATM"] = TransType.ATM;
81 }
82
83 public string GetTransString()
84 {
85 return (string)TransStrings[type];
86 }
87
88 public void GuessTransType(bool isIncome)
89 {
90 Hashtable h = TransOutgo;
91
92 if (isIncome)
93 {
94 h = TransIncome;
95 }
96
97 foreach (string key in h.Keys)
98 {
99 if (desc.Contains(key))
100 {
101 type = (TransType)h[key];
102 return;
103 }
104 }
105
106 // no match
107 if (isIncome)
108 {
109 type = TransType.Dep;
110 }
111 else
112 {
113 type = TransType.Debit;
114 }
115 }
116
117 public void Invalidate()
118 {
119 valid = false;
120 }
121
122 public static bool isInvalid(Transaction t)
123 {
124 return !t.valid;
125 }
126
127 public static bool isZeroTransaction(Transaction t)
128 {
129 return t.value == 0;
130 }
131 }
132 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26