def create_lcfs_account(name, client): logger.info("Setting up LCFS account...") account = Account() account.Name = name account.AccountType = "Bank" account.AccountSubType = "Checking" return account.save(qb=client)
def create_purchase_account(client): logger.info("Creating purchase account") account = Account() account.Name = "LCFS Accounts Payable" account.AccountType = "Accounts Payable" account.AccountSubType = "Accounts Payable" return account.save(qb=client)
def test_create(self): credit_card_account = Account() credit_card_account.Name = "Credit Card Account {0}".format( self.account_number) credit_card_account.AccountType = "Credit Card" credit_card_account.AccountSubType = "CreditCard" credit_card_account.save(qb=self.qb_client) accounts = Account.where( "Classification = 'Asset' AND FullyQualifiedName != 'Accounts Receivable (A/R)'", max_results=1, qb=self.qb_client) from_account = accounts[0] to_account = credit_card_account credit_card_payment = CreditCardPayment() credit_card_payment.Amount = 100 credit_card_payment.BankAccountRef = from_account.to_ref() credit_card_payment.CreditCardAccountRef = to_account.to_ref() credit_card_payment.save(qb=self.qb_client) query_credit_card_payment = CreditCardPayment.get( credit_card_payment.Id, qb=self.qb_client) self.assertEquals(query_credit_card_payment.Id, credit_card_payment.Id) self.assertEquals(query_credit_card_payment.Amount, 100) self.assertEquals(query_credit_card_payment.BankAccountRef.value, from_account.Id) self.assertEquals(query_credit_card_payment.CreditCardAccountRef.value, to_account.Id) # reset transfer (so the from_account doesn't run out of cash) # I wonder if we can do a transfer from credit_card_account to a bank_account transfer = Transfer() transfer.Amount = 100 transfer.FromAccountRef = to_account.to_ref() transfer.ToAccountRef = from_account.to_ref() transfer.save(qb=self.qb_client)
def create_equity_account(name, client): logger.info("Creating equity account") account = Account.filter(Active=True, AccountType="Equity", AccountSubType="OpeningBalanceEquity", qb=client) if len(account) == 0: account = Account() account.Name = name account.AccountType = "Equity" account.AccountSubType = "OpeningBalanceEquity" try: account.save(qb=client) except QuickbooksException: account = Account.filter(AccountType="Equity", AccountSubType="OpeningBalanceEquity", qb=client) return account[0] return account.save(qb=client) else: return account[0]