mirror of
https://github.com/frappe/books.git
synced 2025-01-07 09:04:13 +00:00
fix: Minor fixes
- Better error message in ledgerPosting - Remove models key from model/index.js - Format AccountingLedgerEntry.js - Set default Account to Cash for Payment Type Cash - Add placeholders for Payment Form - Add key to v-for elements in TwoColumnForm
This commit is contained in:
parent
7fd5ce01d1
commit
9726fe4e8a
@ -3,7 +3,10 @@ const { round } = require('frappejs/utils/numberFormat');
|
|||||||
|
|
||||||
module.exports = class LedgerPosting {
|
module.exports = class LedgerPosting {
|
||||||
constructor({ reference, party, date, description }) {
|
constructor({ reference, party, date, description }) {
|
||||||
Object.assign(this, arguments[0]);
|
this.reference = reference;
|
||||||
|
this.party = party;
|
||||||
|
this.date = date;
|
||||||
|
this.description = description;
|
||||||
this.entries = [];
|
this.entries = [];
|
||||||
this.entryMap = {};
|
this.entryMap = {};
|
||||||
// To change balance while entering ledger entries
|
// To change balance while entering ledger entries
|
||||||
@ -102,7 +105,9 @@ module.exports = class LedgerPosting {
|
|||||||
validateEntries() {
|
validateEntries() {
|
||||||
let { debit, credit } = this.getTotalDebitAndCredit();
|
let { debit, credit } = this.getTotalDebitAndCredit();
|
||||||
if (debit !== credit) {
|
if (debit !== credit) {
|
||||||
throw new Error(`Debit ${debit} must be equal to Credit ${credit}`);
|
throw new Error(
|
||||||
|
`Total Debit (${debit}) must be equal to Total Credit (${credit})`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,69 +1,77 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: "AccountingLedgerEntry",
|
name: 'AccountingLedgerEntry',
|
||||||
label: "Ledger Entry",
|
label: 'Ledger Entry',
|
||||||
naming: "autoincrement",
|
naming: 'autoincrement',
|
||||||
doctype: "DocType",
|
doctype: 'DocType',
|
||||||
isSingle: 0,
|
isSingle: 0,
|
||||||
isChild: 0,
|
isChild: 0,
|
||||||
keywordFields: [
|
keywordFields: ['account', 'party', 'referenceName'],
|
||||||
'account',
|
|
||||||
'party',
|
|
||||||
'referenceName'
|
|
||||||
],
|
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
fieldname: "date",
|
fieldname: 'date',
|
||||||
label: "Date",
|
label: 'Date',
|
||||||
fieldtype: "Date"
|
fieldtype: 'Date'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "account",
|
fieldname: 'account',
|
||||||
label: "Account",
|
label: 'Account',
|
||||||
fieldtype: "Link",
|
fieldtype: 'Link',
|
||||||
target: "Account",
|
target: 'Account',
|
||||||
required: 1
|
required: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "description",
|
fieldname: 'description',
|
||||||
label: "Description",
|
label: 'Description',
|
||||||
fieldtype: "Text"
|
fieldtype: 'Text'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party",
|
fieldname: 'party',
|
||||||
label: "Party",
|
label: 'Party',
|
||||||
fieldtype: "Link",
|
fieldtype: 'Link',
|
||||||
target: "Party"
|
target: 'Party'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "debit",
|
fieldname: 'debit',
|
||||||
label: "Debit",
|
label: 'Debit',
|
||||||
fieldtype: "Currency",
|
fieldtype: 'Currency'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "credit",
|
fieldname: 'credit',
|
||||||
label: "Credit",
|
label: 'Credit',
|
||||||
fieldtype: "Currency",
|
fieldtype: 'Currency'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "againstAccount",
|
fieldname: 'againstAccount',
|
||||||
label: "Against Account",
|
label: 'Against Account',
|
||||||
fieldtype: "Text"
|
fieldtype: 'Text'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "referenceType",
|
fieldname: 'referenceType',
|
||||||
label: "Ref. Type",
|
label: 'Ref. Type',
|
||||||
fieldtype: "Data",
|
fieldtype: 'Data'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "referenceName",
|
fieldname: 'referenceName',
|
||||||
label: "Ref. Name",
|
label: 'Ref. Name',
|
||||||
fieldtype: "DynamicLink",
|
fieldtype: 'DynamicLink',
|
||||||
references: "referenceType"
|
references: 'referenceType'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "balance",
|
fieldname: 'balance',
|
||||||
label: "Balance",
|
label: 'Balance',
|
||||||
fieldtype: "Currency",
|
fieldtype: 'Currency'
|
||||||
},
|
}
|
||||||
|
],
|
||||||
|
quickEditFields: [
|
||||||
|
'date',
|
||||||
|
'account',
|
||||||
|
'description',
|
||||||
|
'party',
|
||||||
|
'debit',
|
||||||
|
'credit',
|
||||||
|
'againstAccount',
|
||||||
|
'referenceType',
|
||||||
|
'referenceName',
|
||||||
|
'balance'
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
@ -48,6 +48,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
fieldname: 'paymentAccount',
|
fieldname: 'paymentAccount',
|
||||||
label: 'To Account',
|
label: 'To Account',
|
||||||
|
placeholder: 'To Account',
|
||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
target: 'Account',
|
target: 'Account',
|
||||||
required: 1,
|
required: 1,
|
||||||
@ -59,11 +60,17 @@ module.exports = {
|
|||||||
return { accountType: ['in', ['Bank', 'Cash']], isGroup: 0 };
|
return { accountType: ['in', ['Bank', 'Cash']], isGroup: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
formula: doc => {
|
||||||
|
if (doc.paymentMethod === 'Cash') {
|
||||||
|
return 'Cash';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'paymentMethod',
|
fieldname: 'paymentMethod',
|
||||||
label: 'Payment Method',
|
label: 'Payment Method',
|
||||||
|
placeholder: 'Payment Method',
|
||||||
fieldtype: 'Select',
|
fieldtype: 'Select',
|
||||||
options: ['', 'Cash', 'Cheque', 'Transfer'],
|
options: ['', 'Cash', 'Cheque', 'Transfer'],
|
||||||
required: 1
|
required: 1
|
||||||
@ -71,17 +78,20 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
fieldname: 'referenceId',
|
fieldname: 'referenceId',
|
||||||
label: 'Ref. / Cheque No.',
|
label: 'Ref. / Cheque No.',
|
||||||
|
placeholder: 'Ref. / Cheque No.',
|
||||||
fieldtype: 'Data',
|
fieldtype: 'Data',
|
||||||
required: 1 // TODO: UNIQUE
|
required: 1 // TODO: UNIQUE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'referenceDate',
|
fieldname: 'referenceDate',
|
||||||
label: 'Ref. Date',
|
label: 'Ref. Date',
|
||||||
|
placeholder: 'Ref. Date',
|
||||||
fieldtype: 'Date'
|
fieldtype: 'Date'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'clearanceDate',
|
fieldname: 'clearanceDate',
|
||||||
label: 'Clearance Date',
|
label: 'Clearance Date',
|
||||||
|
placeholder: 'Clearance Date',
|
||||||
fieldtype: 'Date',
|
fieldtype: 'Date',
|
||||||
hidden: doc => {
|
hidden: doc => {
|
||||||
return doc.paymentMethod === 'Cash' ? 1 : 0;
|
return doc.paymentMethod === 'Cash' ? 1 : 0;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
models: {
|
|
||||||
SetupWizard: require('./doctype/SetupWizard/SetupWizard'),
|
SetupWizard: require('./doctype/SetupWizard/SetupWizard'),
|
||||||
DashboardSettings: require('./doctype/DashboardSettings/DashboardSettings'),
|
DashboardSettings: require('./doctype/DashboardSettings/DashboardSettings'),
|
||||||
DashboardChart: require('./doctype/DashboardChart/DashboardChart'),
|
DashboardChart: require('./doctype/DashboardChart/DashboardChart'),
|
||||||
@ -67,6 +66,6 @@ module.exports = {
|
|||||||
Email: require('./doctype/Email/Email'),
|
Email: require('./doctype/Email/Email'),
|
||||||
EmailAccount: require('./doctype/EmailAccount/EmailAccount'),
|
EmailAccount: require('./doctype/EmailAccount/EmailAccount'),
|
||||||
|
|
||||||
PrintSettings: require('./doctype/PrintSettings/PrintSettings')
|
PrintSettings: require('./doctype/PrintSettings/PrintSettings'),
|
||||||
}
|
GetStarted: require('./doctype/GetStarted/GetStarted')
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<div class="text-sm" :class="{ 'border-t': !noBorder }">
|
<div class="text-sm" :class="{ 'border-t': !noBorder }">
|
||||||
<template v-for="df in fields">
|
<template v-for="df in fields">
|
||||||
<FormControl
|
<FormControl
|
||||||
|
:key="df.fieldname"
|
||||||
v-if="df.fieldtype === 'Table'"
|
v-if="df.fieldtype === 'Table'"
|
||||||
ref="controls"
|
ref="controls"
|
||||||
size="small"
|
size="small"
|
||||||
@ -11,7 +12,7 @@
|
|||||||
/>
|
/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<template v-if="inlineEditField === df && inlineEditDoc">
|
<template v-if="inlineEditField === df && inlineEditDoc">
|
||||||
<div class="border-b">
|
<div class="border-b" :key="df.fieldname">
|
||||||
<TwoColumnForm
|
<TwoColumnForm
|
||||||
ref="inlineEditForm"
|
ref="inlineEditForm"
|
||||||
:doc="inlineEditDoc"
|
:doc="inlineEditDoc"
|
||||||
@ -39,6 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div
|
<div
|
||||||
|
:key="df.fieldname"
|
||||||
v-else
|
v-else
|
||||||
class="grid"
|
class="grid"
|
||||||
:class="{ 'border-b': !noBorder }"
|
:class="{ 'border-b': !noBorder }"
|
||||||
@ -71,7 +73,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { _ } from 'frappejs/utils';
|
import frappe from 'frappejs';
|
||||||
import FormControl from '@/components/Controls/FormControl';
|
import FormControl from '@/components/Controls/FormControl';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import { handleErrorWithDialog } from '@/utils';
|
import { handleErrorWithDialog } from '@/utils';
|
||||||
@ -128,7 +130,6 @@ let TwoColumnForm = {
|
|||||||
// handle rename
|
// handle rename
|
||||||
if (this.autosave && df.fieldname === 'name' && !this.doc.isNew()) {
|
if (this.autosave && df.fieldname === 'name' && !this.doc.isNew()) {
|
||||||
return this.doc.rename(value);
|
return this.doc.rename(value);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doc.set(df.fieldname, value);
|
this.doc.set(df.fieldname, value);
|
||||||
|
Loading…
Reference in New Issue
Block a user