Develop and Download Open Source Software

Browse Subversion Repository

Contents of /branches/FeliCa2Money-1/Edy.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 204 - (show annotations) (download) (as text)
Sun May 18 04:21:26 2008 UTC (15 years, 10 months ago) by tmurakam
File MIME type: text/x-c++src
File size: 2925 byte(s)
Move older version (ver 1.x)

1 /*
2 * FeliCa2Money
3 *
4 * Copyright (C) 2001-2007 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 #include <vcl.h>
22 #pragma hdrstop
23 #include <stdio.h>
24 #include "Card.h"
25 #include "Transaction.h"
26 #include "SfcPeep.h"
27 #include "Edy.h"
28
29 //
30 // Edy
31 //
32
33 /// コンストラクタ
34 EdyCard::EdyCard(void)
35 {
36 Ident = "Edy";
37 CardName = "Edy";
38 }
39
40 int EdyCard::ReadCard(void)
41 {
42 // Edy
43 if (SfcPeep->Execute("-e") < 0) return -1;
44
45 // 一行目を確認
46 TStringList *lines = SfcPeep->Lines();
47 if (lines->Count < 1) {
48 // no data
49 return -1;
50 }
51 AnsiString head = lines->Strings[0];
52 lines->Delete(0);
53
54 if (head.SubString(1,4) != "EDY:") {
55 return -1;
56 }
57 CardId = head.SubString(5, head.Length() - 4);
58
59 // リスト解析
60 if (ParseLines(lines, true) < 0) {
61 return -1;
62 }
63 return 0;
64 }
65
66 //
67 // トランザクション解析
68 //
69 Transaction *EdyCard::GenerateTransaction(int nrows, AnsiString *rows, int *err)
70 {
71 Transaction *trans = new Transaction;
72
73 // 0:処理,1:日付時刻,2:今回取引額,3:チャージ残高, 4:取引連番
74 // ET00:チャージ 2007年03月14日23時08分16秒 24000 49428 59
75
76 AnsiString date = rows[1];
77 trans->date.year = date.SubString(1, 4).ToInt();
78 trans->date.month = date.SubString(7, 2).ToInt();
79 trans->date.date = date.SubString(11, 2).ToInt();
80
81 trans->date.hour = date.SubString(15,2).ToInt();
82 trans->date.minutes = date.SubString(19,2).ToInt();
83 trans->date.seconds = date.SubString(23,2).ToInt();
84
85 trans->id = rows[4].ToInt();
86
87 AnsiString desc = rows[0];
88 desc = desc.SubString(6, desc.Length() - 5);
89
90 if (desc == "----") {
91 delete trans;
92 return NULL; // empty
93 }
94
95 if (desc == "支払") {
96 trans->SetTransactionType(desc.c_str(), T_OUTGO);
97 trans->value = - rows[2].ToInt();
98
99 // 適用が "支払" だけだと、Money が過去の履歴から店舗名を
100 // 勝手に補完してしまう。これを避けるため、連番を追加しておく。
101 desc += " ";
102 desc += trans->id;
103 } else {
104 trans->SetTransactionType(desc.c_str(), T_INCOME);
105 trans->value = rows[2].ToInt();
106 }
107 trans->desc = sjis2utf8(desc);
108 trans->balance = rows[3].ToInt();
109
110 return trans;
111 }

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