eur, "transaction {}".format(i), ) Split(accounts[random.randrange(N)], value=v, transaction=tx) Split(accounts[random.randrange(N)], value=-v, transaction=tx) s.save() # select two accounts acc = accounts[0] tacc = accounts[1] # move all splits from account acc to account tacc for spl in list(acc.splits): spl.account = tacc s.save() # check no more splits in account acc assert len(acc.splits) == 0 # try to change a split account to an account that is a placeholder acc.placeholder = 1 with pytest.raises(ValueError): spl.account = acc # set an account to a placeholder tx = s.transactions[0] tx.splits[0].account.placeholder = 1 s.save() tx.description = "foo" with pytest.raises(GncValidationError): s.save()
# fdfdsfsd with open_book("trading_accounts.gnucash", readonly=False, open_if_lock=True, acquire_lock=True) as s: for tr in s.transactions: # .get(description="other transfer + expense") print("{}\t{}".format(tr.currency, tr.description)) # print tr.get_imbalances() for sp in tr.splits: print("\t[{}] {} / {} for {}".format(sp.account.commodity, sp.value, sp.quantity, sp.account)) # sp.memo = "foo" # tr.description = "foo" # s.session.flush() tr = s.transactions.get(description="cross CAD to USD transfer (initiated from USD account)") sp = s.transactions.get(description="cross CAD to USD transfer").splits[0] # sp.transaction = tr tr.description = "foo" # tr.currency = s.commodities[-1] # print "foooooooooooooooooooooooooooooooo" # print sp.transaction, s.transactions.get(description="cross CAD to USD transfer").splits[1].transaction acc = s.accounts[0] assert isinstance(acc, Account) acc.commodity_scu = 1 s.session.flush() Transaction(currency=s.commodities.get(mnemonic="EUR"), description="foo", splits=[ Split(value=Decimal("1.2345"), account=s.accounts[0]), Split(value=Decimal("1.2345"),