mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix bugs.
This commit is contained in:
@@ -185,7 +185,6 @@ export default {
|
||||
check('entries.*.debit').optional({ nullable: true }).isNumeric().toInt(),
|
||||
check('entries.*.account_id').isNumeric().toInt(),
|
||||
check('entries.*.note').optional(),
|
||||
check('attachment').optional(),
|
||||
],
|
||||
async handler(req, res) {
|
||||
const validationErrors = validationResult(req);
|
||||
@@ -244,28 +243,9 @@ export default {
|
||||
if (journalNumber.length > 0) {
|
||||
errorReasons.push({ type: 'JOURNAL.NUMBER.ALREADY.EXISTS', code: 300 });
|
||||
}
|
||||
|
||||
const { attachment } = req.files;
|
||||
const supportedMimes = ['image/png', 'image/jpeg'];
|
||||
|
||||
if (attachment && supportedMimes.indexOf(attachment.mimeType) === -1) {
|
||||
errorReasons.push({ type: 'ATTACHMENT.MINETYPE.NOT.SUPPORTED', code: 400 });
|
||||
}
|
||||
if (errorReasons.length > 0) {
|
||||
return res.status(400).send({ errors: errorReasons });
|
||||
}
|
||||
|
||||
if (attachment) {
|
||||
const publicPath = 'storage/app/public/';
|
||||
try {
|
||||
await attachment.mv(`${publicPath}${req.organizationId}/${attachment.md5}.png`);
|
||||
} catch (error) {
|
||||
return res.status(400).send({
|
||||
errors: [{ type: 'ATTACHMENT.UPLOAD.FAILED', code: 600 }],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Save manual journal transaction.
|
||||
const manualJournal = await ManualJournal.query().insert({
|
||||
reference: form.reference,
|
||||
@@ -276,7 +256,6 @@ export default {
|
||||
description: form.description,
|
||||
status: form.status,
|
||||
user_id: user.id,
|
||||
attachment_file: (attachment) ? `${attachment.md5}.png` : null,
|
||||
});
|
||||
const journalPoster = new JournalPoster();
|
||||
|
||||
@@ -682,13 +661,12 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Deletes bulk manual journals.
|
||||
*/
|
||||
deleteBulkManualJournals: {
|
||||
validation: [
|
||||
query('ids').isArray({ min: 2 }),
|
||||
query('ids').isArray({ min: 1 }),
|
||||
query('ids.*').isNumeric().toInt(),
|
||||
],
|
||||
async handler(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user