Skip to content

Commit

Permalink
Adding notes about exporting CSV; bumping up version; adding changelo…
Browse files Browse the repository at this point in the history
…g to header; removing some packages; iv now regenerated when importing data
  • Loading branch information
reZach committed May 18, 2019
1 parent 9923688 commit 5aae4e6
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Take control of your budget, download it today. It is free - forever.
- Completely offline - we are not saving any information of yours, it remains on your computer.
- Simple - only contains what you need to budget.
- Passphrase-protected - protect your data by providing a passphrase to encrypt your data (this is optional).
- Export your transaction data to CSV format.
- Limited* support to sync transactions with your bank. [See here](https://github.com/reZach/my-budget/wiki/Creating-a-new-connector) for more details.
- Built with [Electron](https://electronjs.org/) - supported on Linux, MacOS and Windows.

Expand Down
2 changes: 1 addition & 1 deletion app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>My Budget</title>
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
<!-- <script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script> -->
<script>
(function() {
if (!process.env.HOT) {
Expand Down
103 changes: 103 additions & 0 deletions app/components/Save/Save.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from "react";
import { bindActionCreators } from "redux";
import { connect } from "react-redux";
const {dialog} = require('electron').remote;
const createCsvWriter = require("csv-writer").createObjectCsvWriter;
import Fuse from "fuse.js";
import * as SaveActions from "../../actions/save";
import * as ModifyActions from "../../actions/modify";
Expand All @@ -17,6 +18,7 @@ import ImportBank from "../ImportBank/ImportBank";
const fs = require("fs");
import filehelper from "../../utils/filehelper";
import * as crypto from "../../crypto/code";
import { dateToMMDDYYYY } from "../../utils/readableDate";

class Save extends Component<Props>{
props: Props;
Expand Down Expand Up @@ -322,7 +324,108 @@ class Save extends Component<Props>{
}

exportCSV(){
var today = new Date();
var month = today.getMonth() + 1;
var day = today.getDate();
var year = today.getFullYear();

var callback = function(filename, bookmark){
if (typeof filename !== "undefined"){

try
{
let csvWriter = createCsvWriter({
path: filename,
header: [
{id: "date", title: "Date"},
{id: "category", title: "Category"},
{id: "subcategory", title: "Subcategory"},
{id: "amount", title: "Amount"},
{id: "note", title: "Note"}
]
});

let csvRecords = [];

for (var i = 0; i < this.props.transactions.length; i++){
var category = "";
var subcategory = "";

for (var j = 0; j < this.props.categories.length; j++){
if (this.props.transactions[i].dateId === this.props.categories[j].dateId &&
this.props.transactions[i].categoryId === this.props.categories[j].id){
category = this.props.categories[j].name;
break;
}
}
for (var j = 0; j < this.props.items.length; j++){
if (this.props.transactions[i].dateId === this.props.items[j].dateId &&
this.props.transactions[i].categoryId === this.props.items[j].categoryId &&
this.props.transactions[i].itemId === this.props.items[j].id){
subcategory = this.props.items[j].name;
break;
}
}

var split = this.props.transactions[i].dateId.split("-");

csvRecords.push({
date: dateToMMDDYYYY(split[0], this.props.transactions[i].day, split[1]),
category: category,
subcategory: subcategory,
amount: parseFloat(this.props.transactions[i].amount),
note: this.props.transactions[i].note
});
}

csvRecords.sort(function(a, b){

var split1 = a.date.split('/');
var split2 = b.date.split('/');
var m1 = split1[0];
var d1 = split1[1];
var y1 = split1[2];
var m2 = split2[0];
var d2 = split2[1];
var y2 = split2[2];

if (y1 > y2){
return 1;
} else if (y2 > y1) {
return -1;
} else if (m1 > m2) {
return 1;
} else if (m2 > m1) {
return -1;
} else if (d1 > d2) {
return 1;
} else if (d2 > d1) {
return -1;
}
return 0;
});

csvWriter.writeRecords(csvRecords)
.then(() => {
this.toggleExportModal();
alert("Exported data as CSV successfully.");
});
}
catch (exception){
this.toggleExportModal();
alert("Could not export CSV data.")
}
}
};
var boundCallback = callback.bind(this);

dialog.showSaveDialog(
{
title: "Export data as CSV",
defaultPath: `mybudgetcsv_${year}${month}${day}.csv`
},
boundCallback
);
}

changeUsername(event){
Expand Down
2 changes: 1 addition & 1 deletion app/crypto/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function cryptoAvailable() {
if (crypto === null) {
crypto = require("crypto");

if (readFromFile(ivpath) === "") {
if (fs.existsSync(ivpath) && readFromFile(ivpath) === "") {
writeNewIv();
}
}
Expand Down
26 changes: 22 additions & 4 deletions app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,19 @@ export default class MenuBuilder {
const subMenuView =
process.env.NODE_ENV === 'development' ? subMenuViewDev : subMenuViewProd;

return [subMenuAbout, subMenuEdit, subMenuView, subMenuWindow, subMenuHelp, {
label: `v${appVersion}`
}];
return [subMenuAbout, subMenuEdit, subMenuView, subMenuWindow, subMenuHelp,
{
label: `v${appVersion}`,
submenu: [
{
label: 'Changelog',
click() {
shell.openExternal('https://github.com/reZach/my-budget/releases');
}
}
]
}
];
}

buildDefaultTemplate() {
Expand Down Expand Up @@ -288,7 +298,15 @@ export default class MenuBuilder {
]
},
{
label: `v${appVersion}`
label: `v${appVersion}`,
submenu: [
{
label: 'Changelog',
click() {
shell.openExternal('https://github.com/reZach/my-budget/releases');
}
}
]
}
];

Expand Down
20 changes: 0 additions & 20 deletions app/store/initialStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@ var date: Date = (new Date());
var month: string = date.getMonth() + 1;
var year: string = date.getFullYear();

// var success = false;
// var fileContents;
// try
// {
// fileContents = fs.readFileSync("file.json", "utf-8");

// if (crypto.cryptoAvailable()){
// var decrypted = crypto.decrypt(fileContents);

// success = true;
// fileContents = JSON.parse(decrypted);
// } else {
// success = true;
// fileContents = JSON.parse(fileContents);
// }
// }
// catch (error)
// {
// console.error(error);
// }

export const initialStore = {
modified: /*success ? fileContents.modified :*/ false,
Expand Down
4 changes: 2 additions & 2 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ <h1>{{ site.title | default: site.github.repository_name }}</h1>
<div class="downloads">
<span>Downloads:</span>
<ul>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.0.1-beta/my-budget-3.0.1-beta.msi" class="button">Windows</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.0.1-beta/MyBudget-3.0.1-beta.dmg" class="button">Mac</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.1.0-beta/my-budget-3.1.0-beta.msi" class="button">Windows</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.1.0-beta/MyBudget-3.1.0-beta.dmg" class="button">Mac</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/latest" class="button">Linux</a></li>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Take control of your budget, download it today. It is free - forever.
- Completely offline - we are not saving any information of yours, it remains on your computer.
- Simple - only contains what you need to budget.
- Passphrase-protected - encrypt your data by providing a passphrase (optional).
- Export your transaction data to CSV format.
- Limited* support to sync transactions with your bank. [See here](https://github.com/reZach/my-budget/wiki/Creating-a-new-connector) for more details.
- Built with [Electron](https://electronjs.org/) - supported on Linux, MacOS and Windows.

Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "my-budget",
"productName": "MyBudget",
"version": "3.0.1-beta",
"version": "3.1.0-beta",
"description": "Free, open source offline cross-platform budgeting solution built with Electron.",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"main": "./app/main.prod.js",
"build": {
"productName": "MyBudget",
"productName": "My Budget",
"appId": "org.zachary.MyBudget",
"files": [
"app/dist/",
Expand Down Expand Up @@ -240,14 +240,14 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.5.0",
"banking": "^1.2.0",
"csv-writer": "^1.3.0",
"devtron": "^1.4.0",
"electron-debug": "^2.0.0",
"electron-log": "^2.2.17",
"electron-prompt": "^1.3.0",
"electron-updater": "^4.0.6",
"fuse.js": "^3.4.4",
"history": "^4.7.2",
"plaid": "^3.1.1",
"puppeteer": "^1.14.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
Expand Down

0 comments on commit 5aae4e6

Please sign in to comment.