Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
fivaz authored Apr 23, 2019
1 parent b50f108 commit c9878a4
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 3 deletions.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
# money
# Money

## About
This app is a app for managing your finances, you can control many accounts and transfer money between them, so it can be used for domestical purposes but also for a big institution.

## Design Patterns
In this app I use several design patterns as:
```
-MVC
-Publisher/Subscriber
-Router
-Proxy
-ORM
```

## No Frameworks
I created this app to prove to myself I could created a whole app without using any framework, this app contains my own implementation of important features of some frameworks like JQuery and Laravel.

### List of features:

####JQuery
- $("<tag">) and $("css selector") of JQuery
- node.show() and .hide();
- $.post sending JSON
- etc.

####Laravel
- Router with path params
- MVC
- Eloquent ORM
- database config file
- middleware of authetification for some routes

####Node.js
- EventEmitter

####Moment.js
- now
- formatDate in European/South American format or English format
- etc.

*But I do use Bootstrap and FontAwesome*

#### Important
I have a .htaccess file in this page but I can't upload it on github. Anyway, the code is right below.

RewriteEngine on
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteRule (.*) routes.php [QSA,L]
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
//this index.php is necessary to show that this is a php app to Heroku
//but my .htaccess uses routes.php as the target file of all requests
Binary file added modeling/money.mwb
Binary file not shown.
Binary file added modeling/money.mwb.bak
Binary file not shown.
131 changes: 131 additions & 0 deletions modeling/script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema money
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema heroku_5dcc28ee8717c6d
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Table `user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `user` ;

CREATE TABLE IF NOT EXISTS `user` (
`id` INT NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(200) NOT NULL,
`last_name` VARCHAR(200) NOT NULL,
`email` VARCHAR(200) NOT NULL,
`password` VARCHAR(200) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `email_UNIQUE` (`email` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `account`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `account` ;

CREATE TABLE IF NOT EXISTS `account` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NULL DEFAULT 'new account',
`isArchived` INT(11) NOT NULL DEFAULT 0,
`user_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_account_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_account_user`
FOREIGN KEY (`user_id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `category`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `category` ;

CREATE TABLE IF NOT EXISTS `category` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(200) NOT NULL,
`isArchived` INT(11) NOT NULL DEFAULT 0,
`user_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_category_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_category_user`
FOREIGN KEY (`user_id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `transaction`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `transaction` ;

CREATE TABLE IF NOT EXISTS `transaction` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`type` VARCHAR(45) NULL DEFAULT 'spending',
`description` VARCHAR(200) NULL DEFAULT NULL,
`value` DECIMAL(10,2) NULL DEFAULT '0.00',
`date` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`account_origin_id` INT(11) NOT NULL,
`account_destiny_id` INT(11) NULL DEFAULT NULL,
`category_id` INT(11) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_transactions_account_origin` (`account_origin_id` ASC),
INDEX `fk_transactions_account_destiny` (`account_destiny_id` ASC),
INDEX `fk_transaction_category_id` (`category_id` ASC),
CONSTRAINT `fk_transaction_category`
FOREIGN KEY (`category_id`)
REFERENCES `category` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_transactions_account_destiny`
FOREIGN KEY (`account_destiny_id`)
REFERENCES `account` (`id`),
CONSTRAINT `fk_transactions_account_origin`
FOREIGN KEY (`account_origin_id`)
REFERENCES `account` (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- View `view_account`
-- -----------------------------------------------------
DROP VIEW IF EXISTS `view_account` ;
CREATE OR REPLACE VIEW `view_account` AS
SELECT
`id`, `name`, `user_id`
FROM
`account`
WHERE
`isArchived` = 0;

-- -----------------------------------------------------
-- View `view_category`
-- -----------------------------------------------------
DROP VIEW IF EXISTS `view_category` ;
CREATE OR REPLACE VIEW `view_category` AS
SELECT
`id`, `name`, `user_id`
FROM
`category`
WHERE
`isArchived` = 0;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
1 change: 0 additions & 1 deletion site/db-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
define("DB_CHARSET", "utf8");
//DIR cotains the name of the source directory with a slash like this: source/
define("DIR", substr($_SERVER['SCRIPT_NAME'], 0, strlen($_SERVER['SCRIPT_NAME']) - strlen("routes.php")));
//define("DIR", "/");

//LOCAL
define("DB_HOST", "localhost");
Expand Down
45 changes: 45 additions & 0 deletions site/js/helpers/myMoment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function digit2(number) {
return ("0" + number).slice(-2);
}

function now() {
const date = new Date();
return formatDateEN(date)
}

function formatDateEN(date) {
return date.getFullYear() + "-" + digit2(date.getMonth() + 1) + "-" + digit2(date.getDate());
}

function formatDateFR(date) {
return digit2(date.getDate()) + "/" + digit2(date.getMonth() + 1) + "/" + date.getFullYear();
}

//TODO try to use this later
/*
function buildDate(date) {
let date10 = date.substring(0, 10);
let arrayDate = date10.split('-');
let arrayFixed = arrayDate.map((item, index) => item - index % 2);
return new Date(...arrayFixed);
}
*/

function thisMonth() {
return new Date().getMonth();
}

function thisYear() {
return new Date().getFullYear();
}

function getLastDate(year, month) {
return new Date(year, month + 1, 0);
}

function getFirstDate(year, month) {
return new Date(year, month, 1);
}



2 changes: 1 addition & 1 deletion site/php/views/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script src="site/js/builders/AccountPageBuilder.js"></script>
<script src="site/js/builders/CategoriesPageBuilder.js"></script>

<script src="site/js/helpers/dateHelper.js"></script>
<script src="site/js/helpers/myMoment.js"></script>
<script src="site/js/helpers/myJQuery.js"></script>
<script src="site/js/services/DataSync.js"></script>
<script src="site/js/services/EventEmitter.js"></script>
Expand Down

0 comments on commit c9878a4

Please sign in to comment.