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 ))
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)
def test_extract_fields_negative(self): row = ["2018/07/30", "自動販売機", "物品購入", "","","","","268","4881",""] eq_(self.parser.extract_fields(row), PartialTransactionInfo( self.date, "自動販売機, 物品購入", -268) )
def test_extract_fields_positive(self): row = ["2018/07/30", "Charge", "", "","","","","","4881","3000"] eq_(self.parser.extract_fields(row), PartialTransactionInfo( self.date, "Charge", 3000) )
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)
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)
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) )
def test_choose_given_account_card(self): info = PartialTransactionInfo( self.date, "Charge", 3000) eq_(self.parser.choose_credit_account(info), MyAccount.CARD)
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)
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)
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)
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)
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)
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)
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))
def test_choose_given_account_meals(self): info = PartialTransactionInfo( self.date, "Dining", -500) eq_(self.parser.choose_credit_account(info), MyAccount.MEALS)
def test_choose_given_account_trans(self): info = PartialTransactionInfo( self.date, "自動改札機", -200) eq_(self.parser.choose_credit_account(info), MyAccount.TRANSPORTATION)
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)
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)
def test_choose_given_account_unknown(self): info = PartialTransactionInfo( self.date, "Dining", -2000) eq_(self.parser.choose_credit_account(info), MyAccount.UNKNOWN)
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)
def test_choose_given_account_snack(self): info = PartialTransactionInfo( self.date, "Dining", -100) eq_(self.parser.choose_credit_account(info), MyAccount.SNACK)
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))