Init commit

This commit is contained in:
Marek Fraczyk
2021-02-16 16:24:22 +02:00
parent 056a817632
commit 79e9705b01
106 changed files with 18400 additions and 0 deletions

View File

@ -0,0 +1,35 @@
import storage from 'localforage';
class BankAccountService {
async getBankAccounts() {
const bankAccounts = await storage.getItem('bank_accounts');
return bankAccounts || [];
}
async getBankAccount(bankAccountId) {
const bankAccounts = await this.getBankAccounts();
return bankAccounts.find(bank_account => bank_account.id === bankAccountId);
}
async createBankAccount(bankAccount) {
const bankAccounts = await this.getBankAccounts();
delete bankAccount.$id;
delete bankAccount.$isNew;
delete bankAccount.$isDirty;
bankAccounts.push(bankAccount);
await storage.setItem('bank_accounts', bankAccounts);
return bankAccount;
}
async updateBankAccount(bankAccount) {
const bankAccounts = await this.getBankAccounts();
const index = bankAccounts.findIndex(item => item.id === bankAccount.id);
bankAccounts[index] = bankAccount;
return storage.setItem('bank_accounts', bankAccounts);
}
}
export default new BankAccountService();