2019-11-20 00:40:01 +05:30
|
|
|
<template>
|
|
|
|
<div class="flex flex-col">
|
2022-04-27 17:32:43 +05:30
|
|
|
<PageHeader :backLink="true">
|
2022-02-10 13:12:43 +05:30
|
|
|
<template #actions v-if="doc">
|
2021-11-11 15:05:34 +05:30
|
|
|
<StatusBadge :status="status" />
|
2019-12-20 12:14:31 +05:30
|
|
|
<DropdownWithActions class="ml-2" :actions="actions" />
|
2019-11-20 00:40:01 +05:30
|
|
|
<Button
|
|
|
|
v-if="doc._notInserted || doc._dirty"
|
|
|
|
type="primary"
|
|
|
|
class="text-white text-xs ml-2"
|
|
|
|
@click="onSaveClick"
|
|
|
|
>
|
2022-02-14 10:45:26 +05:30
|
|
|
{{ t`Save` }}
|
2019-12-20 12:14:31 +05:30
|
|
|
</Button>
|
2019-11-20 00:40:01 +05:30
|
|
|
<Button
|
|
|
|
v-if="!doc._dirty && !doc._notInserted && !doc.submitted"
|
|
|
|
type="primary"
|
|
|
|
class="text-white text-xs ml-2"
|
|
|
|
@click="onSubmitClick"
|
|
|
|
>
|
2022-02-14 10:45:26 +05:30
|
|
|
{{ t`Submit` }}
|
2019-12-20 12:14:31 +05:30
|
|
|
</Button>
|
2019-11-20 00:40:01 +05:30
|
|
|
</template>
|
|
|
|
</PageHeader>
|
2021-09-16 17:54:22 +05:30
|
|
|
<div v-if="doc" class="flex justify-center flex-1 mb-8 mt-2">
|
2019-11-20 00:40:01 +05:30
|
|
|
<div
|
|
|
|
class="border rounded-lg shadow h-full flex flex-col justify-between"
|
|
|
|
style="width: 600px"
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<div class="mt-8 px-6">
|
|
|
|
<h1 class="text-2xl font-semibold">
|
2022-02-14 10:45:26 +05:30
|
|
|
{{ doc._notInserted ? t`New Journal Entry` : doc.name }}
|
2019-11-20 00:40:01 +05:30
|
|
|
</h1>
|
2022-03-08 13:13:04 +05:30
|
|
|
<div class="flex justify-between mt-2 gap-2">
|
2019-11-20 00:40:01 +05:30
|
|
|
<div class="w-1/3">
|
|
|
|
<FormControl
|
|
|
|
:df="meta.getField('entryType')"
|
|
|
|
:value="doc.entryType"
|
|
|
|
placeholder="Entry Type"
|
2021-11-11 15:05:34 +05:30
|
|
|
@change="(value) => doc.set('entryType', value)"
|
2019-12-11 15:08:20 +05:30
|
|
|
input-class="bg-gray-100 px-3 py-2 text-base"
|
2021-09-16 17:54:22 +05:30
|
|
|
:read-only="doc.submitted"
|
|
|
|
:class="doc.submitted && 'pointer-events-none'"
|
2019-11-20 00:40:01 +05:30
|
|
|
/>
|
|
|
|
<FormControl
|
|
|
|
class="mt-2"
|
|
|
|
:df="meta.getField('date')"
|
|
|
|
:value="doc.date"
|
|
|
|
:placeholder="'Date'"
|
2021-11-11 15:05:34 +05:30
|
|
|
@change="(value) => doc.set('date', value)"
|
2019-12-11 15:08:20 +05:30
|
|
|
input-class="bg-gray-100 px-3 py-2 text-base"
|
2021-09-16 17:54:22 +05:30
|
|
|
:read-only="doc.submitted"
|
|
|
|
:class="doc.submitted && 'pointer-events-none'"
|
2019-11-20 00:40:01 +05:30
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="w-1/3">
|
|
|
|
<FormControl
|
|
|
|
:df="meta.getField('referenceNumber')"
|
|
|
|
:value="doc.referenceNumber"
|
|
|
|
:placeholder="'Reference Number'"
|
2021-11-11 15:05:34 +05:30
|
|
|
@change="(value) => doc.set('referenceNumber', value)"
|
2019-12-11 15:08:20 +05:30
|
|
|
input-class="bg-gray-100 p-2 text-base"
|
2021-09-16 17:54:22 +05:30
|
|
|
:read-only="doc.submitted"
|
|
|
|
:class="doc.submitted && 'pointer-events-none'"
|
2019-11-20 00:40:01 +05:30
|
|
|
/>
|
|
|
|
<FormControl
|
|
|
|
class="mt-2"
|
|
|
|
:df="meta.getField('referenceDate')"
|
2021-12-16 15:54:01 +05:30
|
|
|
:value="doc.referenceDate"
|
2019-11-20 00:40:01 +05:30
|
|
|
:placeholder="'Reference Date'"
|
2021-11-11 15:05:34 +05:30
|
|
|
@change="(value) => doc.set('referenceDate', value)"
|
2019-12-11 15:08:20 +05:30
|
|
|
input-class="bg-gray-100 px-3 py-2 text-base"
|
2021-09-16 17:54:22 +05:30
|
|
|
:read-only="doc.submitted"
|
|
|
|
:class="doc.submitted && 'pointer-events-none'"
|
2019-11-20 00:40:01 +05:30
|
|
|
/>
|
|
|
|
</div>
|
2022-03-08 13:13:04 +05:30
|
|
|
<div class="w-1/3">
|
|
|
|
<FormControl
|
|
|
|
:df="meta.getField('numberSeries')"
|
|
|
|
:value="doc.numberSeries"
|
|
|
|
@change="(value) => doc.set('numberSeries', value)"
|
|
|
|
input-class="bg-gray-100 p-2 text-base"
|
2022-04-04 14:09:15 +05:30
|
|
|
:read-only="!doc._notInserted || doc.submitted"
|
2022-03-08 13:13:04 +05:30
|
|
|
:class="doc.submitted && 'pointer-events-none'"
|
|
|
|
/>
|
2022-04-21 18:38:36 +05:30
|
|
|
</div>
|
2019-11-20 00:40:01 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mt-2 px-6 text-base">
|
|
|
|
<FormControl
|
|
|
|
:df="meta.getField('accounts')"
|
|
|
|
:value="doc.accounts"
|
|
|
|
:showHeader="true"
|
2021-09-16 17:54:22 +05:30
|
|
|
:max-rows-before-overflow="4"
|
2021-11-11 15:05:34 +05:30
|
|
|
@change="(value) => doc.set('accounts', value)"
|
2019-11-20 00:40:01 +05:30
|
|
|
:read-only="doc.submitted"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="px-6 mb-6">
|
|
|
|
<div
|
|
|
|
class="grid items-center border-t pt-3 pr-2"
|
|
|
|
style="grid-template-columns: 1.3fr 1fr 1fr"
|
|
|
|
>
|
|
|
|
<div class="text-sm">
|
|
|
|
<FormControl
|
|
|
|
:df="meta.getField('userRemark')"
|
|
|
|
:value="doc.userRemark"
|
2021-11-11 15:05:34 +05:30
|
|
|
@change="(value) => doc.set('userRemark', value)"
|
2021-09-16 17:54:22 +05:30
|
|
|
:class="doc.submitted && 'pointer-events-none'"
|
|
|
|
:read-only="doc.submitted"
|
2019-11-20 00:40:01 +05:30
|
|
|
/>
|
|
|
|
</div>
|
2021-11-22 11:25:09 +05:30
|
|
|
<div class="text-right font-semibold text-green-600 px-3">
|
2019-11-20 00:40:01 +05:30
|
|
|
{{ totalDebit }}
|
|
|
|
</div>
|
2021-11-22 11:25:09 +05:30
|
|
|
<div class="text-right font-semibold text-red-600 px-3">
|
2019-11-20 00:40:01 +05:30
|
|
|
{{ totalCredit }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2022-04-20 12:08:47 +05:30
|
|
|
import Button from 'src/components/Button';
|
2022-04-22 16:32:03 +05:30
|
|
|
import FormControl from 'src/components/Controls/FormControl.vue';
|
2022-04-20 12:08:47 +05:30
|
|
|
import DropdownWithActions from 'src/components/DropdownWithActions';
|
|
|
|
import PageHeader from 'src/components/PageHeader';
|
|
|
|
import StatusBadge from 'src/components/StatusBadge';
|
2022-04-21 18:38:36 +05:30
|
|
|
import { fyo } from 'src/initFyo';
|
2022-04-20 12:08:47 +05:30
|
|
|
import { getActionsForDocument, routeTo, showMessageDialog } from 'src/utils';
|
2022-01-19 13:09:39 +05:30
|
|
|
import { handleErrorWithDialog } from '../errorHandling';
|
2019-11-20 00:40:01 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'JournalEntryForm',
|
|
|
|
props: ['name'],
|
|
|
|
components: {
|
|
|
|
PageHeader,
|
|
|
|
Button,
|
2019-12-20 12:14:31 +05:30
|
|
|
DropdownWithActions,
|
2021-11-11 15:05:34 +05:30
|
|
|
StatusBadge,
|
2019-11-20 00:40:01 +05:30
|
|
|
FormControl,
|
|
|
|
},
|
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
doctype: 'JournalEntry',
|
2021-11-11 15:05:34 +05:30
|
|
|
name: this.name,
|
2019-11-20 00:40:01 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
doctype: 'JournalEntry',
|
2021-11-11 15:05:34 +05:30
|
|
|
doc: null,
|
2019-11-20 00:40:01 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2019-12-20 12:14:31 +05:30
|
|
|
meta() {
|
2022-04-21 18:38:36 +05:30
|
|
|
return fyo.getMeta(this.doctype);
|
2019-12-20 12:14:31 +05:30
|
|
|
},
|
2021-11-11 15:05:34 +05:30
|
|
|
status() {
|
|
|
|
if (this.doc._notInserted || !this.doc.submitted) {
|
|
|
|
return 'Draft';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
},
|
2019-11-20 00:40:01 +05:30
|
|
|
totalDebit() {
|
|
|
|
let value = 0;
|
|
|
|
if (this.doc.accounts) {
|
|
|
|
value = this.doc.getSum('accounts', 'debit');
|
|
|
|
}
|
2022-04-21 18:38:36 +05:30
|
|
|
return fyo.format(value, 'Currency');
|
2019-11-20 00:40:01 +05:30
|
|
|
},
|
|
|
|
totalCredit() {
|
|
|
|
let value = 0;
|
|
|
|
if (this.doc.accounts) {
|
|
|
|
value = this.doc.getSum('accounts', 'credit');
|
|
|
|
}
|
2022-04-21 18:38:36 +05:30
|
|
|
return fyo.format(value, 'Currency');
|
2019-12-20 12:14:31 +05:30
|
|
|
},
|
|
|
|
actions() {
|
|
|
|
return getActionsForDocument(this.doc);
|
2021-11-11 15:05:34 +05:30
|
|
|
},
|
2019-11-20 00:40:01 +05:30
|
|
|
},
|
|
|
|
async mounted() {
|
2019-12-20 12:14:31 +05:30
|
|
|
try {
|
2022-04-21 18:38:36 +05:30
|
|
|
this.doc = await fyo.doc.getDoc(this.doctype, this.name);
|
2019-12-20 12:14:31 +05:30
|
|
|
window.je = this.doc;
|
|
|
|
} catch (error) {
|
2022-04-21 18:38:36 +05:30
|
|
|
if (error instanceof fyo.errors.NotFoundError) {
|
2021-11-21 21:45:27 +05:30
|
|
|
routeTo(`/list/${this.doctype}`);
|
2019-12-20 12:14:31 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.handleError(error);
|
|
|
|
}
|
2019-11-20 00:40:01 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async onSaveClick() {
|
2022-04-24 12:18:44 +05:30
|
|
|
return this.doc.sync().catch(this.handleError);
|
2019-11-20 00:40:01 +05:30
|
|
|
},
|
|
|
|
async onSubmitClick() {
|
2021-12-16 17:22:23 +05:30
|
|
|
showMessageDialog({
|
2022-02-09 12:47:54 +05:30
|
|
|
message: this.t`Are you sure you want to submit this Journal Entry?`,
|
2021-12-16 17:22:23 +05:30
|
|
|
buttons: [
|
|
|
|
{
|
2022-02-09 12:47:54 +05:30
|
|
|
label: this.t`Yes`,
|
2021-12-16 17:22:23 +05:30
|
|
|
action: () => {
|
|
|
|
this.doc.submit().catch(this.handleError);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 12:47:54 +05:30
|
|
|
label: this.t`No`,
|
2021-12-16 17:22:23 +05:30
|
|
|
action() {},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2019-11-20 00:40:01 +05:30
|
|
|
},
|
2019-12-20 12:14:31 +05:30
|
|
|
handleError(e) {
|
|
|
|
handleErrorWithDialog(e, this.doc);
|
2021-11-11 15:05:34 +05:30
|
|
|
},
|
|
|
|
},
|
2019-11-20 00:40:01 +05:30
|
|
|
};
|
|
|
|
</script>
|