Added Wizard for Month/Year End Close
This commit is contained in:
@@ -130,13 +130,18 @@ function insertEntry(entry, book, userId, companyId, source) {
|
||||
}
|
||||
|
||||
function createEntry(book, body, userId, companyId) {
|
||||
return insertEntry(validateEntry(body), book, userId, companyId, 'manual');
|
||||
const entry = validateEntry(body);
|
||||
require('./closePeriods').assertPeriodOpen(companyId, book, entry.entry_date);
|
||||
return insertEntry(entry, book, userId, companyId, 'manual');
|
||||
}
|
||||
|
||||
function updateEntry(id, body, userId, companyId) {
|
||||
const before = getEntry(id, companyId);
|
||||
if (!before) return null;
|
||||
const entry = validateEntry({ ...before, ...body });
|
||||
// Block edits dated in (or moving into) a closed period for this entry's book.
|
||||
require('./closePeriods').assertPeriodOpen(companyId, before.book_code, before.entry_date);
|
||||
require('./closePeriods').assertPeriodOpen(companyId, before.book_code, entry.entry_date);
|
||||
run(
|
||||
`UPDATE gl_entries SET entry_date = ?, fiscal_year = ?, account = ?, account_type = ?, description = ?,
|
||||
reference = ?, debit = ?, credit = ?, asset_id = ?, external_id = ?, updated_at = ? WHERE id = ?`,
|
||||
@@ -153,6 +158,7 @@ function updateEntry(id, body, userId, companyId) {
|
||||
function deleteEntry(id, userId, companyId) {
|
||||
const before = getEntry(id, companyId);
|
||||
if (!before) return false;
|
||||
require('./closePeriods').assertPeriodOpen(companyId, before.book_code, before.entry_date);
|
||||
run('DELETE FROM gl_entries WHERE id = ?', [id]);
|
||||
audit(userId, 'delete', 'gl_entry', id, before, null);
|
||||
return true;
|
||||
@@ -280,6 +286,7 @@ module.exports = {
|
||||
entriesReport,
|
||||
entryHistory,
|
||||
getEntry,
|
||||
insertEntry,
|
||||
listEntries,
|
||||
previewImport,
|
||||
updateEntry
|
||||
|
||||
Reference in New Issue
Block a user