Пример #1
0
def update_transaction(transaction: Transaction, old_amount: int) -> Transaction:
    transaction = db_update_one(transaction)
    account_amount = -old_amount + transaction.amount
    increase = transaction.type == TransactionType.INCOME.value
    account = _update_related_account_balance(transaction.account_id, account_amount, increase=increase)
    transaction.account = account
    return transaction
Пример #2
0
def update_employer(employer: Employer) -> Employer:
    return db_update_one(employer)
Пример #3
0
def delete_employer(employer: Employer) -> Employer:
    employer.is_deleted = True
    return db_update_one(employer)
Пример #4
0
def update_finance_category(
        finance_category: FinanceCategory) -> FinanceCategory:
    return db_update_one(finance_category)
Пример #5
0
def delete_finance_category(
        finance_category: FinanceCategory) -> FinanceCategory:
    finance_category.is_deleted = True
    return db_update_one(finance_category)