Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98 - (show annotations) (download)
Thu Mar 6 13:04:43 2008 UTC (16 years, 1 month ago) by tmurakam
File size: 3700 byte(s)
ver 2.1 tags

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 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 class Transaction
43 {
44 public int id; // ID
45 public DateTime date;
46 public TransType type; // トランザクションタイプ
47 public string desc;
48 public string memo;
49 public int value; // 金額
50 public int balance; // 残高
51
52 private static Hashtable TransIncome;
53 private static Hashtable TransOutgo;
54 private static Hashtable TransStrings;
55
56 static Transaction()
57 {
58 // initialize
59 TransStrings = new Hashtable();
60 TransStrings[TransType.Int] = "INT";
61 TransStrings[TransType.Div] = "DIV";
62 TransStrings[TransType.DirectDep] = "DIRECTDEP";
63 TransStrings[TransType.Dep] = "DEP";
64 TransStrings[TransType.Payment] = "PAYMENT";
65 TransStrings[TransType.Cash] = "CASH";
66 TransStrings[TransType.ATM] = "ATM";
67 TransStrings[TransType.Check] = "CHECK";
68 TransStrings[TransType.Debit] = "DEBIT";
69
70 TransIncome = new Hashtable();
71 TransIncome["利息"] = TransType.Int;
72 TransIncome["振込"] = TransType.DirectDep;
73 TransIncome["チャージ"]= TransType.DirectDep; // Edy チャージ
74 TransIncome["入金"] = TransType.DirectDep; // Suica チャージ
75
76 TransOutgo = new Hashtable();
77 TransOutgo["ATM"] = TransType.ATM;
78 TransOutgo["ATM"] = TransType.ATM;
79 }
80
81 public string GetTransString()
82 {
83 return (string)TransStrings[type];
84 }
85
86 public void GuessTransType(bool isIncome)
87 {
88 Hashtable h = TransOutgo;
89
90 if (isIncome)
91 {
92 h = TransIncome;
93 }
94
95 foreach (string key in h.Keys)
96 {
97 if (desc.Contains(key))
98 {
99 type = (TransType)h[key];
100 return;
101 }
102 }
103
104 // no match
105 if (isIncome)
106 {
107 type = TransType.Dep;
108 }
109 else
110 {
111 type = TransType.Debit;
112 }
113 }
114
115 public static bool isZeroTransaction(Transaction t)
116 {
117 return t.value == 0;
118 }
119 }
120 }

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