[#7] Stubbed out a bunch of basic mongo calls and configured app to use mongo instead of mocked object.
This commit is contained in:
parent
4b231538ed
commit
3eb52c78c3
@ -7,7 +7,7 @@ db.createCollection("budgetPeriods")
|
|||||||
|
|
||||||
users: [{
|
users: [{
|
||||||
_id: <id>
|
_id: <id>
|
||||||
username: “maximx1”
|
username: "jules"
|
||||||
}]
|
}]
|
||||||
|
|
||||||
accounts: [{
|
accounts: [{
|
||||||
@ -20,5 +20,38 @@ budgets: [{
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
budgetPeriods: [{
|
budgetPeriods: [{
|
||||||
|
user: ObjectId("63faac6823cd0682fe8c8ed6"),
|
||||||
}]
|
startDate: new Date("2023-03-03"),
|
||||||
|
endDate: new Date("2023-03-10"),
|
||||||
|
leftover: 23.22,
|
||||||
|
cashflows: [
|
||||||
|
{
|
||||||
|
account: ObjectId("63fab01a23cd0682fe8c8ed7"),
|
||||||
|
dueDate: new Date("2023-03-04"),
|
||||||
|
postingDate: new Date("2023-03-04"),
|
||||||
|
amount: 22.23,
|
||||||
|
isIncome: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
verified: true,
|
||||||
|
adhocPurchases: [
|
||||||
|
{
|
||||||
|
postingDate: new Date("2023-03-05"),
|
||||||
|
amount: 1.99,
|
||||||
|
description: "",
|
||||||
|
isIncome: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
|
||||||
|
$push operator for adding to arrays
|
||||||
|
|
||||||
|
2023-03-07
|
||||||
|
|
||||||
|
{
|
||||||
|
user: ObjectId("63faac6823cd0682fe8c8ed6"),
|
||||||
|
start: { $lte: "2023-03-07T05:00:00.000Z" },
|
||||||
|
end: { $gt: "2023-03-07T05:00:00.000Z" }
|
||||||
|
}
|
||||||
|
|
||||||
|
http://localhost:3001/jules/period/in/2023-03-01..2023-04-01
|
||||||
68
client/package-lock.json
generated
68
client/package-lock.json
generated
@ -11,6 +11,7 @@
|
|||||||
"@testing-library/jest-dom": "^5.16.1",
|
"@testing-library/jest-dom": "^5.16.1",
|
||||||
"@testing-library/react": "^12.1.2",
|
"@testing-library/react": "^12.1.2",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
|
"axios": "^1.3.4",
|
||||||
"bootstrap": "^5.1.3",
|
"bootstrap": "^5.1.3",
|
||||||
"gridjs": "^5.0.2",
|
"gridjs": "^5.0.2",
|
||||||
"gridjs-react": "^5.0.2",
|
"gridjs-react": "^5.0.2",
|
||||||
@ -4424,6 +4425,29 @@
|
|||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/axios": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"follow-redirects": "^1.15.0",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
|
"proxy-from-env": "^1.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/axios/node_modules/form-data": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||||
|
"dependencies": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/axobject-query": {
|
"node_modules/axobject-query": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
|
||||||
@ -7466,9 +7490,9 @@
|
|||||||
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg=="
|
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg=="
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.14.7",
|
"version": "1.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||||
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==",
|
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@ -12938,6 +12962,11 @@
|
|||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/proxy-from-env": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||||
|
},
|
||||||
"node_modules/psl": {
|
"node_modules/psl": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
|
||||||
@ -19283,6 +19312,28 @@
|
|||||||
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.0.tgz",
|
||||||
"integrity": "sha512-btWy2rze3NnxSSxb7LtNhPYYFrRoFBfjiGzmSc/5Hu47wApO2KNXjP/w7Nv2Uz/Fyr/pfEiwOkcXhDxu0jz5FA=="
|
"integrity": "sha512-btWy2rze3NnxSSxb7LtNhPYYFrRoFBfjiGzmSc/5Hu47wApO2KNXjP/w7Nv2Uz/Fyr/pfEiwOkcXhDxu0jz5FA=="
|
||||||
},
|
},
|
||||||
|
"axios": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
|
||||||
|
"requires": {
|
||||||
|
"follow-redirects": "^1.15.0",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
|
"proxy-from-env": "^1.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"form-data": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||||
|
"requires": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"axobject-query": {
|
"axobject-query": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
|
||||||
@ -21546,9 +21597,9 @@
|
|||||||
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg=="
|
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg=="
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
"follow-redirects": {
|
||||||
"version": "1.14.7",
|
"version": "1.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||||
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ=="
|
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
|
||||||
},
|
},
|
||||||
"fork-ts-checker-webpack-plugin": {
|
"fork-ts-checker-webpack-plugin": {
|
||||||
"version": "6.5.0",
|
"version": "6.5.0",
|
||||||
@ -25354,6 +25405,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"proxy-from-env": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||||
|
},
|
||||||
"psl": {
|
"psl": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
"@testing-library/jest-dom": "^5.16.1",
|
"@testing-library/jest-dom": "^5.16.1",
|
||||||
"@testing-library/react": "^12.1.2",
|
"@testing-library/react": "^12.1.2",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
|
"axios": "^1.3.4",
|
||||||
"bootstrap": "^5.1.3",
|
"bootstrap": "^5.1.3",
|
||||||
"gridjs": "^5.0.2",
|
"gridjs": "^5.0.2",
|
||||||
"gridjs-react": "^5.0.2",
|
"gridjs-react": "^5.0.2",
|
||||||
|
|||||||
@ -8,7 +8,7 @@ const AppImpl = () => {
|
|||||||
const context = useContext(BudgetContext);
|
const context = useContext(BudgetContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
context.api.loadData(mockedData.budgetPeriods);
|
context.api.getCurrentPeriod();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { useReducer, createContext } from 'react';
|
import { useReducer, createContext } from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
import BudgetReducer from './BudgetReducer';
|
import BudgetReducer from './BudgetReducer';
|
||||||
|
|
||||||
const BudgetContext = createContext();
|
const BudgetContext = createContext();
|
||||||
@ -9,8 +10,17 @@ const BudgetState = (props) => {
|
|||||||
},
|
},
|
||||||
[state, dispatch] = useReducer(BudgetReducer, initialState),
|
[state, dispatch] = useReducer(BudgetReducer, initialState),
|
||||||
api = {
|
api = {
|
||||||
loadData: (data) => {
|
getCurrentPeriod: () => {
|
||||||
dispatch({ type: 'budget/populate', data });
|
axios.get(`http://localhost:3001/jules/period/for/${(new Date()).toISOString()}`, {
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
'Access-Control-Allow-Methods': 'GET',
|
||||||
|
crossorigin: true
|
||||||
|
}
|
||||||
|
}).then(response => {
|
||||||
|
dispatch({ type: 'budget/populate', data: [{ ...response.data, id: response.data.id }] });
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
updateBillPaid: (periodId, billId) => {
|
updateBillPaid: (periodId, billId) => {
|
||||||
dispatch({ type: 'budget/period/bills/update', data: { periodId, billId }});
|
dispatch({ type: 'budget/period/bills/update', data: { periodId, billId }});
|
||||||
|
|||||||
@ -9,10 +9,10 @@ const BudgetPeriodCard = ({periodData, isActive}) => {
|
|||||||
const cardRef = useRef(),
|
const cardRef = useRef(),
|
||||||
context = useContext(BudgetContext),
|
context = useContext(BudgetContext),
|
||||||
[bankBalance, setBankBalance] = useState(0),
|
[bankBalance, setBankBalance] = useState(0),
|
||||||
[projectedLeftover, setProjectedLeftover] = useState(0),
|
[projectedLeftover, setProjectedLeftover] = useState(periodData),
|
||||||
paidBills = periodData.bills.filter((bill) => bill.paid),
|
paidBills = periodData.cashflows.filter((f) => !f.isIncome && f.postingDate != null),
|
||||||
unpaidBills = periodData.bills.filter((bill) => !bill.paid),
|
unpaidBills = periodData.cashflows.filter((f) => !f.isIncome && f.postingDate == null),
|
||||||
[incomes, setIncomes] = useState(periodData.income),
|
[incomes, setIncomes] = useState(periodData.cashflows.filter((f) => f.isIncome)),
|
||||||
[paidIncomes, setPaidIncomes] = useState([]),
|
[paidIncomes, setPaidIncomes] = useState([]),
|
||||||
[unpaidIncomes, setUnpaidIncomes] = useState([]),
|
[unpaidIncomes, setUnpaidIncomes] = useState([]),
|
||||||
moveTransItemAction = (row) => {
|
moveTransItemAction = (row) => {
|
||||||
@ -52,9 +52,9 @@ const BudgetPeriodCard = ({periodData, isActive}) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className='card-body'>
|
<div className='card-body'>
|
||||||
<div className='dates'>
|
<div className='dates'>
|
||||||
<span className='dates-start'>{periodData.startDate.toDateString().split(' ').slice(1).join(' ')}</span>
|
<span className='dates-start'>{(new Date(periodData.startDate)).toLocaleDateString()}</span>
|
||||||
<span> - </span>
|
<span> - </span>
|
||||||
<span className='dates-end'>{ periodData.endDate.toDateString().split(' ').slice(1).join(' ')}</span>
|
<span className='dates-end'>{(new Date(periodData.endDate)).toLocaleDateString()}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className='bank-current'>
|
<div className='bank-current'>
|
||||||
<span className='bank-current-label'>Current Balance</span>
|
<span className='bank-current-label'>Current Balance</span>
|
||||||
|
|||||||
13
server/src/controllers/AccountController.js
Normal file
13
server/src/controllers/AccountController.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const accountManager = require('../managers/AccountManager'),
|
||||||
|
accountStore = require('../stores/AccountStore');
|
||||||
|
|
||||||
|
exports.load = (app) => {
|
||||||
|
app.get('/accounts', (req, res) => {
|
||||||
|
accountStore.getAccounts().then(data => res.json({ accounts: data }));
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/:username/accounts', (req, res) => {
|
||||||
|
const { username } = req.params;
|
||||||
|
accountManager.getUserAccounts(username).then(data => res.json(data));
|
||||||
|
});
|
||||||
|
};
|
||||||
19
server/src/controllers/BudgetPeriodController.js
Normal file
19
server/src/controllers/BudgetPeriodController.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
const budgetPeriodManager = require('../managers/BudgetPeriodManager');
|
||||||
|
|
||||||
|
exports.load = (app) => {
|
||||||
|
// app.get('/:username/period/current', (req, res) => {
|
||||||
|
// const { username } = req.params;
|
||||||
|
// budgetPeriodManager.getBudgetPeriodForUserByDateInPeriod(username, new Date()).then(data => res.json(data));
|
||||||
|
// });
|
||||||
|
|
||||||
|
app.get('/:username/period/for/:date', (req, res) => {
|
||||||
|
const { username, date } = req.params;
|
||||||
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
budgetPeriodManager.getBudgetPeriodForUserByDateInPeriod(username, new Date(date)).then(data => res.json(data));
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/:username/period/in/:start..:end', (req, res) => {
|
||||||
|
const { username, start, end } = req.params;
|
||||||
|
budgetPeriodManager.getBudgetPeriodsForUserWithinDateRange(username, new Date(start), new Date(end)).then(data => res.json(data));
|
||||||
|
});
|
||||||
|
};
|
||||||
7
server/src/controllers/UserController.js
Normal file
7
server/src/controllers/UserController.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const userStore = require('../stores/UserStore');
|
||||||
|
|
||||||
|
exports.load = (app) => {
|
||||||
|
app.get('/users', (req, res) => {
|
||||||
|
userStore.getUsers().then(data => res.json({ users: data }));
|
||||||
|
});
|
||||||
|
};
|
||||||
22
server/src/managers/BudgetPeriodManager.js
Normal file
22
server/src/managers/BudgetPeriodManager.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
const userStore = require('../stores/UserStore'),
|
||||||
|
budgetPeriodStore = require('../stores/BudgetPeriodStore');
|
||||||
|
|
||||||
|
exports.getBudgetPeriodsForUserWithinDateRange = (username, startDate, endDate) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
userStore.findUser(username).then((user) => {
|
||||||
|
budgetPeriodStore.getBudgetPeriodsForUserWithinDateRange(user._id, startDate, endDate).then(budgetPeriods => {
|
||||||
|
resolve(budgetPeriods);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getBudgetPeriodForUserByDateInPeriod = (username, date) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
userStore.findUser(username).then((user) => {
|
||||||
|
budgetPeriodStore.getBudgetPeriodForUserByDateInPeriod(user._id, date).then(accounts => {
|
||||||
|
resolve(accounts);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
@ -1,22 +1,12 @@
|
|||||||
const express = require('express'),
|
const express = require('express'),
|
||||||
port = process.env.PORT || 3001,
|
port = process.env.PORT || 3001,
|
||||||
app = express(),
|
app = express();
|
||||||
userManager = require('./managers/UserManager'),
|
|
||||||
userStore = require('./stores/UserStore'),
|
|
||||||
accountStore = require('./stores/AccountStore');
|
|
||||||
|
|
||||||
app.get('/users', (req, res) => {
|
[
|
||||||
userStore.getUsers().then(data => res.json({ users: data }));
|
require('./controllers/UserController'),
|
||||||
});
|
require('./controllers/AccountController'),
|
||||||
|
require('./controllers/BudgetPeriodController')
|
||||||
app.get('/:username/accounts', (req, res) => {
|
].forEach(c => c.load(app));
|
||||||
const { username } = req.params;
|
|
||||||
userManager.getUserAccounts(username).then(data => res.json(data));
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/accounts', (req, res) => {
|
|
||||||
accountStore.getAccounts().then(data => res.json({ accounts: data }));
|
|
||||||
});
|
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`===> Server started: http://localhost:${port}/`);
|
console.log(`===> Server started: http://localhost:${port}/`);
|
||||||
|
|||||||
23
server/src/stores/BudgetPeriodStore.js
Normal file
23
server/src/stores/BudgetPeriodStore.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const mongo = require('./Mongo');
|
||||||
|
|
||||||
|
exports.getBudgetPeriods = () => {
|
||||||
|
return mongo.listAll('budgetPeriods');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getBudgetPeriodsForUserWithinDateRange = (userId, startDate, endDate) => {
|
||||||
|
return mongo.find('budgetPeriods', {
|
||||||
|
user: userId,
|
||||||
|
startDate: { $gte: startDate },
|
||||||
|
endDate: { $lt: endDate }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getBudgetPeriodForUserByDateInPeriod = (userId, date) => {
|
||||||
|
return mongo.findOne('budgetPeriods', {
|
||||||
|
user: userId,
|
||||||
|
startDate: { $lte: date },
|
||||||
|
endDate: { $gt: date }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// db.budgetPeriods.insert({ cashflows: [ { account: ObjectId("63fab01a23cd0682fe8c8ed7"), dueDate: new Date("2023-03-04"), postingDate: new Date("2023-03-04"), amount: 22.23, isIncome: false }], verified: true, adhocPurchases: [ { postingDate: new Date("2023-03-05"), amount: 1.99, description: "", isIncome: false }] })
|
||||||
Loading…
x
Reference in New Issue
Block a user