Ignores transactions that already exist on import

This commit is contained in:
Josh Creek
2019-04-14 14:12:41 +01:00
parent 1129e30fc2
commit c88a5684ed
3 changed files with 14 additions and 5 deletions
+4 -2
View File
@@ -23,13 +23,15 @@ If you wish to contribute other bank statement csv formats or features then plea
1. ~~Set up adding statement lines and displaying them~~ 1. ~~Set up adding statement lines and displaying them~~
2. ~~Set up adding and saving statement lines with localstorage, and reloading from localstorage~~ 2. ~~Set up adding and saving statement lines with localstorage, and reloading from localstorage~~
3. Set up importing a csv file (bank statement) to the data structure, adding each line 3. ~~Set up importing a csv file (bank statement) to the data structure, adding each line ignoring different accounts~~
4. Modify that to ignore any entries that already exist upon import 4. ~~Modify that to ignore any entries that already exist upon import~~
5. Set up a system to enable selecting a tag from the preset tags for each line when importing 5. Set up a system to enable selecting a tag from the preset tags for each line when importing
6. Modify that to enable creating a new tag and saving that to localstorage 6. Modify that to enable creating a new tag and saving that to localstorage
### Things for later versions ### Things for later versions
- Sort transactions by date order
- Be able to handle separate accounts, and split transactions into these
- Be able to set rules to auto apply these, or manually set them for each item on a statement when adding it in - Be able to set rules to auto apply these, or manually set them for each item on a statement when adding it in
- Be able to summarise (with graphs) expenditure and savings for any selected time period - Be able to summarise (with graphs) expenditure and savings for any selected time period
- Be able to expand the above summaries for more detailed information - Be able to expand the above summaries for more detailed information
+1 -2
View File
@@ -2,7 +2,7 @@
<div> <div>
<form @submit="importCSV"> <form @submit="importCSV">
<textarea v-model="csv" name="csv" placeholder="Add statement csv..."></textarea> <textarea v-model="csv" name="csv" placeholder="Add statement csv..."></textarea>
<input type="submit" value="Submit" class="btn"> <input type="submit" value="Import CSV" class="btn">
</form> </form>
</div> </div>
</template> </template>
@@ -46,7 +46,6 @@ export default {
} }
result.forEach (function(transaction) { result.forEach (function(transaction) {
alert(JSON.stringify(transaction["Date"]));
const newTransaction = { const newTransaction = {
id: uuid.v4(), id: uuid.v4(),
date: transaction["Date"], date: transaction["Date"],
+9 -1
View File
@@ -63,8 +63,16 @@ export default {
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions)); localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
}, },
addTransaction(newTransaction) { addTransaction(newTransaction) {
this.transactions.push(newTransaction); // Determine whether this transaction already exists
const found = this.transactions.some(transaction => transaction.date === newTransaction.date && transaction.transactionTypeDescription === newTransaction.transactionTypeDescription && transaction.description === newTransaction.description && transaction.isExpenditure === newTransaction.isExpenditure && transaction.amount === newTransaction.amount && transaction.balance === newTransaction.balance);
if (found) {
alert('found duplicate transaction, not adding it - ' + newTransaction.date + ' :: ' + newTransaction.description);
}
else {
this.transactions.push(newTransaction);
this.saveTransactions(); this.saveTransactions();
}
}, },
saveTransactions() { saveTransactions() {
localStorage.setItem("lastname", "Smith"); localStorage.setItem("lastname", "Smith");