Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
added eslint prettier and fixed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Camel Aissani committed May 18, 2021
1 parent 015c861 commit cd1c51e
Show file tree
Hide file tree
Showing 144 changed files with 14,189 additions and 11,674 deletions.
23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"semi": "error",
"quotes": ["error", "single", { "avoidEscape": true }],
"no-unused-vars": [
"error",
{
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": true
}
]
},
"env": {
"node": true,
"browser": true,
"jquery": true,
"es2021": true
},
"extends": ["eslint:recommended"]
}
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bkp
dist
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": true,
"tabWidth": 2,
"singleQuote": true
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ before_install:
# - sudo apt-get install -y nasm

node_js:
- "8.12.0"
- '8.12.0'

before_script:
- npm install coveralls
Expand All @@ -15,4 +15,4 @@ script:
- npm run coverage

after_script:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Loca
====
# Loca

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/microrealestate)
![Docker](https://github.com/camelaissani/loca/workflows/Docker/badge.svg)
Expand All @@ -12,21 +11,21 @@ Loca
This nodejs project is a tentative of web application that offers a toolkit for owners of buildings, flats, offices, meeting rooms, car parks, letter boxes...

The idea is to make easy the management of properties and occupants by proposing many services:
- Gather all information of your properties and occupants in one place
- Create rent contract from templates available in the system
- Follow the rent payments month by month
- Template letters for recovery of not paid rents

![Loca](http://www.nuageprive.fr/images/loca-sample.png "Open source real estate management")
- Gather all information of your properties and occupants in one place
- Create rent contract from templates available in the system
- Follow the rent payments month by month
- Template letters for recovery of not paid rents

![Loca](http://www.nuageprive.fr/images/loca-sample.png 'Open source real estate management')

[Check out the live demo.](http://demo.nuageprive.fr/)

## Getting started

Follow instructions from [here](https://github.com/microrealestate/microrealestate#getting-started)

Technical Stack
---------------
## Technical Stack

Back-end:

Expand All @@ -38,10 +37,8 @@ JQuery, Bootstrap, Handlebars, and [frontexpress](https://github.com/camelaissan

Build system based on RollupJS

## Why I created this application?

Why I created this application?
-------------------------------
Simply to help my best friend and I to manage properties that we rent.

Above all, to have a good reason to play with node and javascript :-)

127 changes: 63 additions & 64 deletions backend/businesslogic/FR/computeRent/index.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,67 @@
const fs = require('fs');
const path = require('path');


module.exports = function(contract, rentDate, previousRent, settlements) {
const rent = {
term: 0,
month: 0,
year: 0,
preTaxAmounts: [
// {
// description: '',
// amount: ''
// }
],
charges: [
// {
// description: '',
// amount: ''
// }
],
discounts: [
// {
// origin: '', // 'contract', 'settlement'
// description: '',
// amount: ''
// }
],
debts: [
// {
// description: '',
// amount: ''
// }
],
vats: [
// {
// origin: '', // 'contract', 'settlement'
// description: '',
// rate: 0,
// amount: 0
// }
],
payments: [
// {
// date: '',
// amount: 0,
// type: '',
// reference: ''
// }
],
description: '',
total: {
balance: 0,
preTaxAmount: 0,
charges: 0,
discount: 0,
vat: 0,
grandTotal: 0,
payment: 0
}
};
const tasks_dir = path.join(__dirname, 'tasks');
const taskFiles = fs.readdirSync(tasks_dir);
return taskFiles.reduce((rent, taskFile) => {
const task = require(path.join(tasks_dir, taskFile));
return task(contract, rentDate, previousRent, settlements, rent);
}, rent);
module.exports = function (contract, rentDate, previousRent, settlements) {
const rent = {
term: 0,
month: 0,
year: 0,
preTaxAmounts: [
// {
// description: '',
// amount: ''
// }
],
charges: [
// {
// description: '',
// amount: ''
// }
],
discounts: [
// {
// origin: '', // 'contract', 'settlement'
// description: '',
// amount: ''
// }
],
debts: [
// {
// description: '',
// amount: ''
// }
],
vats: [
// {
// origin: '', // 'contract', 'settlement'
// description: '',
// rate: 0,
// amount: 0
// }
],
payments: [
// {
// date: '',
// amount: 0,
// type: '',
// reference: ''
// }
],
description: '',
total: {
balance: 0,
preTaxAmount: 0,
charges: 0,
discount: 0,
vat: 0,
grandTotal: 0,
payment: 0,
},
};
const tasks_dir = path.join(__dirname, 'tasks');
const taskFiles = fs.readdirSync(tasks_dir);
return taskFiles.reduce((rent, taskFile) => {
const task = require(path.join(tasks_dir, taskFile));
return task(contract, rentDate, previousRent, settlements, rent);
}, rent);
};
97 changes: 60 additions & 37 deletions backend/businesslogic/FR/computeRent/tasks/1_base.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,69 @@
const moment = require('moment');

module.exports = function(contract, rentDate, previousRent, settlements, rent) {
const currentMoment = moment(rentDate, 'DD/MM/YYYY HH:mm');
rent.term = Number(currentMoment.format('YYYYMMDDHH'));
if (contract.frequency === 'months') {
rent.term = Number(moment(currentMoment).startOf('month').format('YYYYMMDDHH'));
}
if (contract.frequency === 'days') {
rent.term = Number(moment(currentMoment).startOf('day').format('YYYYMMDDHH'));
}
if (contract.frequency === 'hours') {
rent.term = Number(moment(currentMoment).startOf('hour').format('YYYYMMDDHH'));
}
rent.month = currentMoment.month() + 1; // 0 based
rent.year = currentMoment.year();
module.exports = function (
contract,
rentDate,
previousRent,
settlements,
rent
) {
const currentMoment = moment(rentDate, 'DD/MM/YYYY HH:mm');
rent.term = Number(currentMoment.format('YYYYMMDDHH'));
if (contract.frequency === 'months') {
rent.term = Number(
moment(currentMoment).startOf('month').format('YYYYMMDDHH')
);
}
if (contract.frequency === 'days') {
rent.term = Number(
moment(currentMoment).startOf('day').format('YYYYMMDDHH')
);
}
if (contract.frequency === 'hours') {
rent.term = Number(
moment(currentMoment).startOf('hour').format('YYYYMMDDHH')
);
}
rent.month = currentMoment.month() + 1; // 0 based
rent.year = currentMoment.year();

contract.properties.filter((property) => {
const entryMoment = moment(property.entryDate, 'DD/MM/YYYY').startOf('day');
const exitMoment = moment(property.exitDate, 'DD/MM/YYYY').endOf('day');
contract.properties
.filter((property) => {
const entryMoment = moment(property.entryDate, 'DD/MM/YYYY').startOf(
'day'
);
const exitMoment = moment(property.exitDate, 'DD/MM/YYYY').endOf('day');

return currentMoment.isBetween(entryMoment, exitMoment, contract.frequency, '[]');
}).forEach(function (property) {
if (property.property) {
const name = property.property.name || '';
const preTaxAmount = property.rent || 0;
const expenses = property.expenses || [];
return currentMoment.isBetween(
entryMoment,
exitMoment,
contract.frequency,
'[]'
);
})
.forEach(function (property) {
if (property.property) {
const name = property.property.name || '';
const preTaxAmount = property.rent || 0;
const expenses = property.expenses || [];

rent.preTaxAmounts.push({
description: name,
amount: preTaxAmount
});
rent.preTaxAmounts.push({
description: name,
amount: preTaxAmount,
});

if (expenses.length) {
rent.charges.push(...expenses.map(({title, amount}) => ({
description: title,
amount
})));
}
if (expenses.length) {
rent.charges.push(
...expenses.map(({ title, amount }) => ({
description: title,
amount,
}))
);
}
}
});
if (settlements) {
rent.description = settlements.description || '';
}
return rent;
if (settlements) {
rent.description = settlements.description || '';
}
return rent;
};
26 changes: 16 additions & 10 deletions backend/businesslogic/FR/computeRent/tasks/2_debts.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
module.exports = function(contract, rentDate, previousRent, settlements, rent) {
if (settlements && settlements.debts) {
settlements.debts.forEach(debt => {
rent.debts.push({
description: debt.description,
amount: debt.amount
});
});
}
return rent;
module.exports = function (
contract,
rentDate,
previousRent,
settlements,
rent
) {
if (settlements && settlements.debts) {
settlements.debts.forEach((debt) => {
rent.debts.push({
description: debt.description,
amount: debt.amount,
});
});
}
return rent;
};

0 comments on commit cd1c51e

Please sign in to comment.