Esempio n. 1
0
 def test_extract_fields(self):
     row = ['2018/8/8','Company', 'ご本人', '1回払い', '', "'18/09", '740', '740', '', '', '', '', '']
     eq_(self.parser.extract_fields(row),
     PartialTransactionInfo(
         date= self.date,
         description="Company",
         credit=-740
     ))
Esempio n. 2
0
    def test_choose_debt_account_amazon(self):
        info = PartialTransactionInfo(
            date= self.date,
            description="AMAZON.CO.JP",
            credit=-740
        )

        eq_(self.parser.choose_debt_account(info), MyAccount.SMBC_CARD_AMAZON)
Esempio n. 3
0
 def test_extract_fields_negative(self):
     row = ["2018/07/30", "自動販売機", "物品購入", "","","","","268","4881",""]
     eq_(self.parser.extract_fields(row),
         PartialTransactionInfo(
            self.date,               
             "自動販売機, 物品購入",
             -268)
     )
Esempio n. 4
0
 def test_extract_fields_positive(self):
     row = ["2018/07/30", "Charge", "", "","","","","","4881","3000"]
     eq_(self.parser.extract_fields(row),
         PartialTransactionInfo(
             self.date,
             "Charge",
             3000)
     )
Esempio n. 5
0
    def test_choose_debt_account_others(self):
        info = PartialTransactionInfo(
            date=self.date,
            description="steam",
            credit=-740
        )

        eq_(self.parser.choose_debt_account(info), MyAccount.SMBC_CARD_OTHERS)
Esempio n. 6
0
    def extract_fields(self, row: List[str]):
        month, day = [int(x) for x in row[0].split("/")]

        date = datetime.date(datetime.date.today().year, month, day)
        desc = " ".join(row[1:5]).rstrip()
        credit = 0
        if row[6] != "":
            credit = int(row[6].replace(',', ''))

        return PartialTransactionInfo(date, desc, credit)
Esempio n. 7
0
    def test_extract_transaction_info(self):
        row = ['2018/8/8','Company', 'ご本人', '1回払い', '', "'18/09", '740', '740', '', '', '', '', '']
        self.parser.extract_fields = MagicMock(return_value= PartialTransactionInfo(
            date=self.date,
            description="AMAZON.CO.JP",
            credit=-740
        ))
        self.parser.choose_debt_account = MagicMock(return_value=MyAccount.SMBC_CARD_AMAZON)
        self.parser.choose_credit_account = MagicMock(return_value=MyAccount.UNKNOWN)

        eq_(self.parser.extract_transaction_info(row),
            TransactionInfo(self.date,
            description="AMAZON.CO.JP",
            credit=-740,
            debt_account=MyAccount.SMBC_CARD_AMAZON,
            credit_account=MyAccount.UNKNOWN)
        )
Esempio n. 8
0
 def test_choose_given_account_card(self):
     info =  PartialTransactionInfo(
             self.date,
             "Charge",
             3000)
     eq_(self.parser.choose_credit_account(info), MyAccount.CARD)
Esempio n. 9
0
 def test_choose_given_account_trans(self):
     self.parser.accountMap[MyAccount.TRANSPORTATION] = self.the_other
     info = PartialTransactionInfo(self.date, "入 大船   出	鎌倉", -200)
     eq_(self.parser.choose_credit_account(info), self.the_other)
Esempio n. 10
0
 def test_choose_given_account_card(self):
     self.parser.accountMap[MyAccount.CARD] = self.the_other
     info = PartialTransactionInfo(self.date, "VIEW モバイル", 3000)
     eq_(self.parser.choose_credit_account(info), self.the_other)
Esempio n. 11
0
 def extract_fields(self, row: List[str]):
     date = datetime.datetime.strptime(row[0], '%Y/%m/%d').date()
     desc = ', '.join(filter(lambda x: x != '', row[1:6]))
     credit = -int(row[7]) if row[7] != '' else int(row[9])
     return PartialTransactionInfo(date, desc, credit)
Esempio n. 12
0
 def extract_fields(self, row: List[str]) -> PartialTransactionInfo:
     date = datetime.strptime(row[1], '%Y.%m.%d').date()
     desc = row[4]
     credit = int(row[3]) if len(row[2]) == 0 else - int(row[2])
     return PartialTransactionInfo(date, desc, credit)
Esempio n. 13
0
 def extract_fields(self, row: List[str]) -> PartialTransactionInfo:
     date = datetime.strptime(row[0], '%Y%m%d').date()
     desc = f"{row[4]}: {row[5]}"
     credit = - int(row[3]) if len(row[2]) == 0 else int(row[2])
     return PartialTransactionInfo(date, desc, credit)
Esempio n. 14
0
 def extract_fields(self, row: List[str]) -> PartialTransactionInfo:
     date = datetime.strptime(row[4].split(" ")[0], '%Y年%m月%d日').date()
     desc = row[1] + ("" if row[2] == "" else f",{row[2]}")
     credit = -int(row[5]) if row[3] == "支払い完了" else int(row[5])
     return PartialTransactionInfo(date, desc, credit)
Esempio n. 15
0
 def test_extract_fields_positive(self):
     row = "07/03	VIEW	モバイル	 		¥3,647	+3,000".split("\t")
     eq_(self.parser.extract_fields(row),
         PartialTransactionInfo(self.date, "VIEW モバイル", 3000))
Esempio n. 16
0
 def test_choose_given_account_meals(self):
     info =  PartialTransactionInfo(
     self.date,
     "Dining",
     -500)
     eq_(self.parser.choose_credit_account(info), MyAccount.MEALS)
Esempio n. 17
0
 def test_choose_given_account_trans(self):
     info =  PartialTransactionInfo(
         self.date,
         "自動改札機",
         -200)
     eq_(self.parser.choose_credit_account(info), MyAccount.TRANSPORTATION)
Esempio n. 18
0
 def test_choose_given_account_meals(self):
     self.parser.accountMap[MyAccount.MEALS] = self.the_other
     info = PartialTransactionInfo(self.date, "Dining", -500)
     eq_(self.parser.choose_credit_account(info), self.the_other)
Esempio n. 19
0
 def test_choose_given_account_snack(self):
     self.parser.accountMap[MyAccount.SNACK] = self.the_other
     info = PartialTransactionInfo(self.date, "Dining", -100)
     eq_(self.parser.choose_credit_account(info), self.the_other)
Esempio n. 20
0
 def test_choose_given_account_unknown(self):
     info =  PartialTransactionInfo(
         self.date,
         "Dining",
         -2000)
     eq_(self.parser.choose_credit_account(info), MyAccount.UNKNOWN)
Esempio n. 21
0
 def extract_fields(self, row: List[str]) -> PartialTransactionInfo:
     date = datetime.datetime.strptime(row[0], '%Y/%m/%d').date()
     desc = row[1]
     credit = -int(row[5])
     return PartialTransactionInfo(date, desc, credit)
Esempio n. 22
0
 def test_choose_given_account_snack(self):
     info =  PartialTransactionInfo(
     self.date,
     "Dining",
     -100)
     eq_(self.parser.choose_credit_account(info), MyAccount.SNACK)
Esempio n. 23
0
 def test_extract_fields_negative(self):
     row = "07/03	物販		 		¥10,837	-1,379".split("\t")
     eq_(self.parser.extract_fields(row),
         PartialTransactionInfo(self.date, "物販", -1379))