2019-10-12 19:03:50 +00:00
|
|
|
//
|
|
|
|
// TransactionRepository.swift
|
|
|
|
// Budget
|
|
|
|
//
|
|
|
|
// Created by Billy Brawner on 9/25/19.
|
|
|
|
// Copyright © 2019 William Brawner. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Combine
|
2022-01-03 17:56:43 +00:00
|
|
|
import TwigsCore
|
2019-10-12 19:03:50 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
2022-01-03 17:56:43 +00:00
|
|
|
class MockTransactionRepository: TransactionRepository {
|
2019-10-13 01:22:09 +00:00
|
|
|
static let transaction: Transaction = Transaction(
|
2021-09-10 04:47:57 +00:00
|
|
|
id: "2",
|
2019-10-13 01:22:09 +00:00
|
|
|
title: "Test Transaction",
|
|
|
|
description: "A mock transaction used for testing",
|
|
|
|
date: Date(),
|
|
|
|
amount: 10000,
|
2021-09-10 04:47:57 +00:00
|
|
|
categoryId: MockCategoryRepository.category.id,
|
2019-10-13 01:22:09 +00:00
|
|
|
expense: true,
|
2022-05-18 01:04:27 +00:00
|
|
|
createdBy: MockUserRepository.currentUser.id,
|
2021-09-10 04:47:57 +00:00
|
|
|
budgetId: MockBudgetRepository.budget.id
|
2019-10-13 01:22:09 +00:00
|
|
|
)
|
|
|
|
|
2022-01-03 17:56:43 +00:00
|
|
|
func getTransactions(budgetIds: [String], categoryIds: [String]?, from: Date?, to: Date?, count: Int?, page: Int?) async throws -> [Transaction] {
|
|
|
|
return [MockTransactionRepository.transaction]
|
2019-10-12 19:03:50 +00:00
|
|
|
}
|
|
|
|
|
2022-01-03 17:56:43 +00:00
|
|
|
func getTransaction(_ transactionId: String) async throws -> Transaction {
|
|
|
|
return MockTransactionRepository.transaction
|
2019-10-12 19:03:50 +00:00
|
|
|
}
|
|
|
|
|
2022-01-03 17:56:43 +00:00
|
|
|
func createTransaction(_ transaction: Transaction) async throws -> Transaction {
|
|
|
|
return MockTransactionRepository.transaction
|
2019-10-12 19:03:50 +00:00
|
|
|
}
|
2019-10-16 02:57:52 +00:00
|
|
|
|
2022-01-03 17:56:43 +00:00
|
|
|
func updateTransaction(_ transaction: Transaction) async throws -> Transaction {
|
|
|
|
return MockTransactionRepository.transaction
|
2019-10-16 02:57:52 +00:00
|
|
|
}
|
2019-10-17 02:26:35 +00:00
|
|
|
|
2022-01-03 17:56:43 +00:00
|
|
|
func deleteTransaction(_ transactionId: String) async throws {
|
|
|
|
// Do nothing
|
2019-10-17 02:26:35 +00:00
|
|
|
}
|
2021-09-21 01:59:13 +00:00
|
|
|
|
2022-01-03 17:56:43 +00:00
|
|
|
func sumTransactions(budgetId: String?, categoryId: String?, from: Date?, to: Date?) async throws -> BalanceResponse {
|
|
|
|
return BalanceResponse(balance: 1000)
|
2021-09-21 01:59:13 +00:00
|
|
|
}
|
2019-10-12 19:03:50 +00:00
|
|
|
}
|
|
|
|
#endif
|