Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/FeliCa2Money.net/Transaction.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 229 - (show annotations) (download)
Mon Oct 19 16:04:50 2009 UTC (14 years, 7 months ago) by tmurakam
File size: 4041 byte(s)
取引ID付与手順を変更
CVS の Order に "Sort" を追加
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 const int UnassignedId = -1;
45
46 public int id = UnassignedId; // ID
47 public DateTime date;
48 public TransType type; // トランザクションタイプ
49 public string desc = "";
50 public string memo = "";
51 public int value = 0; // 金額
52 public int balance = 0; // 残高
53
54 private bool valid = true;
55
56 private static Hashtable TransIncome;
57 private static Hashtable TransOutgo;
58 private static Hashtable TransStrings;
59
60 static Transaction()
61 {
62 // initialize
63 TransStrings = new Hashtable();
64 TransStrings[TransType.Int] = "INT";
65 TransStrings[TransType.Div] = "DIV";
66 TransStrings[TransType.DirectDep] = "DIRECTDEP";
67 TransStrings[TransType.Dep] = "DEP";
68 TransStrings[TransType.Payment] = "PAYMENT";
69 TransStrings[TransType.Cash] = "CASH";
70 TransStrings[TransType.ATM] = "ATM";
71 TransStrings[TransType.Check] = "CHECK";
72 TransStrings[TransType.Debit] = "DEBIT";
73
74 TransIncome = new Hashtable();
75 TransIncome["利息"] = TransType.Int;
76 TransIncome["振込"] = TransType.DirectDep;
77 TransIncome["チャージ"]= TransType.DirectDep; // Edy チャージ
78 TransIncome["入金"] = TransType.DirectDep; // Suica チャージ
79
80 TransOutgo = new Hashtable();
81 TransOutgo["ATM"] = TransType.ATM;
82 TransOutgo["ATM"] = TransType.ATM;
83 }
84
85 public string GetTransString()
86 {
87 return (string)TransStrings[type];
88 }
89
90 public void GuessTransType(bool isIncome)
91 {
92 Hashtable h = TransOutgo;
93
94 if (isIncome)
95 {
96 h = TransIncome;
97 }
98
99 foreach (string key in h.Keys)
100 {
101 if (desc != null && desc.Contains(key))
102 {
103 type = (TransType)h[key];
104 return;
105 }
106 }
107
108 // no match
109 if (isIncome)
110 {
111 type = TransType.Dep;
112 }
113 else
114 {
115 type = TransType.Debit;
116 }
117 }
118
119 public void Invalidate()
120 {
121 valid = false;
122 }
123
124 public static bool isInvalid(Transaction t)
125 {
126 return !t.valid;
127 }
128
129 public static bool isZeroTransaction(Transaction t)
130 {
131 return t.value == 0;
132 }
133 }
134 }

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