# Copyright (c) 2018, InfluxFramework LLC
# See license.txt

import unittest

import influxframework


class TestCashFlowMapping(unittest.TestCase):
	def setUp(self):
		if influxframework.db.exists("Cash Flow Mapping", "Test Mapping"):
			influxframework.delete_doc("Cash Flow Mappping", "Test Mapping")

	def tearDown(self):
		influxframework.delete_doc("Cash Flow Mapping", "Test Mapping")

	def test_multiple_selections_not_allowed(self):
		doc = influxframework.new_doc("Cash Flow Mapping")
		doc.mapping_name = "Test Mapping"
		doc.label = "Test label"
		doc.append("accounts", {"account": "Accounts Receivable - _TC"})
		doc.is_working_capital = 1
		doc.is_finance_cost = 1

		self.assertRaises(influxframework.ValidationError, doc.insert)

		doc.is_finance_cost = 0
		doc.insert()
