2
0
mirror of https://github.com/frappe/books.git synced 2025-01-05 16:12:21 +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:
Faris Ansari 2019-12-20 12:20:43 +05:30
parent 7fd5ce01d1
commit 9726fe4e8a
5 changed files with 150 additions and 127 deletions

View File

@ -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})`
);
} }
} }

View File

@ -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', fields: [
'party', {
'referenceName' fieldname: 'date',
], label: 'Date',
fields: [ fieldtype: 'Date'
{ },
fieldname: "date", {
label: "Date", fieldname: 'account',
fieldtype: "Date" label: 'Account',
}, fieldtype: 'Link',
{ target: 'Account',
fieldname: "account", required: 1
label: "Account", },
fieldtype: "Link", {
target: "Account", fieldname: 'description',
required: 1 label: 'Description',
}, fieldtype: 'Text'
{ },
fieldname: "description", {
label: "Description", fieldname: 'party',
fieldtype: "Text" label: 'Party',
}, fieldtype: 'Link',
{ target: 'Party'
fieldname: "party", },
label: "Party", {
fieldtype: "Link", fieldname: 'debit',
target: "Party" label: 'Debit',
}, fieldtype: 'Currency'
{ },
fieldname: "debit", {
label: "Debit", fieldname: 'credit',
fieldtype: "Currency", label: 'Credit',
}, fieldtype: 'Currency'
{ },
fieldname: "credit", {
label: "Credit", fieldname: 'againstAccount',
fieldtype: "Currency", label: 'Against Account',
}, fieldtype: 'Text'
{ },
fieldname: "againstAccount", {
label: "Against Account", fieldname: 'referenceType',
fieldtype: "Text" label: 'Ref. Type',
}, fieldtype: 'Data'
{ },
fieldname: "referenceType", {
label: "Ref. Type", fieldname: 'referenceName',
fieldtype: "Data", label: 'Ref. Name',
}, fieldtype: 'DynamicLink',
{ references: 'referenceType'
fieldname: "referenceName", },
label: "Ref. Name", {
fieldtype: "DynamicLink", fieldname: 'balance',
references: "referenceType" label: 'Balance',
}, fieldtype: 'Currency'
{ }
fieldname: "balance", ],
label: "Balance", quickEditFields: [
fieldtype: "Currency", 'date',
}, 'account',
] 'description',
} 'party',
'debit',
'credit',
'againstAccount',
'referenceType',
'referenceName',
'balance'
]
};

View File

@ -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;

View File

@ -1,72 +1,71 @@
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'), Currency: require('./doctype/Currency/Currency'),
Currency: require('./doctype/Currency/Currency'), Color: require('./doctype/Color/Color'),
Color: require('./doctype/Color/Color'), Account: require('./doctype/Account/Account.js'),
Account: require('./doctype/Account/Account.js'), AccountingSettings: require('./doctype/AccountingSettings/AccountingSettings'),
AccountingSettings: require('./doctype/AccountingSettings/AccountingSettings'), CompanySettings: require('./doctype/CompanySettings/CompanySettings'),
CompanySettings: require('./doctype/CompanySettings/CompanySettings'), AccountingLedgerEntry: require('./doctype/AccountingLedgerEntry/AccountingLedgerEntry.js'),
AccountingLedgerEntry: require('./doctype/AccountingLedgerEntry/AccountingLedgerEntry.js'), Party: require('./doctype/Party/Party.js'),
Party: require('./doctype/Party/Party.js'), Customer: require('./doctype/Party/Customer'),
Customer: require('./doctype/Party/Customer'), Supplier: require('./doctype/Party/Supplier'),
Supplier: require('./doctype/Party/Supplier'),
Payment: require('./doctype/Payment/Payment.js'), Payment: require('./doctype/Payment/Payment.js'),
PaymentFor: require('./doctype/PaymentFor/PaymentFor.js'), PaymentFor: require('./doctype/PaymentFor/PaymentFor.js'),
PaymentSettings: require('./doctype/PaymentSettings/PaymentSettings.js'), PaymentSettings: require('./doctype/PaymentSettings/PaymentSettings.js'),
Item: require('./doctype/Item/Item.js'), Item: require('./doctype/Item/Item.js'),
SalesInvoice: require('./doctype/SalesInvoice/SalesInvoice.js'), SalesInvoice: require('./doctype/SalesInvoice/SalesInvoice.js'),
SalesInvoiceItem: require('./doctype/SalesInvoiceItem/SalesInvoiceItem.js'), SalesInvoiceItem: require('./doctype/SalesInvoiceItem/SalesInvoiceItem.js'),
SalesInvoiceSettings: require('./doctype/SalesInvoiceSettings/SalesInvoiceSettings.js'), SalesInvoiceSettings: require('./doctype/SalesInvoiceSettings/SalesInvoiceSettings.js'),
PurchaseInvoice: require('./doctype/PurchaseInvoice/PurchaseInvoice.js'), PurchaseInvoice: require('./doctype/PurchaseInvoice/PurchaseInvoice.js'),
PurchaseInvoiceItem: require('./doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js'), PurchaseInvoiceItem: require('./doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js'),
PurchaseInvoiceSettings: require('./doctype/PurchaseInvoiceSettings/PurchaseInvoiceSettings.js'), PurchaseInvoiceSettings: require('./doctype/PurchaseInvoiceSettings/PurchaseInvoiceSettings.js'),
Tax: require('./doctype/Tax/Tax.js'), Tax: require('./doctype/Tax/Tax.js'),
TaxDetail: require('./doctype/TaxDetail/TaxDetail.js'), TaxDetail: require('./doctype/TaxDetail/TaxDetail.js'),
TaxSummary: require('./doctype/TaxSummary/TaxSummary.js'), TaxSummary: require('./doctype/TaxSummary/TaxSummary.js'),
GSTR3B: require('./doctype/GSTR3B/GSTR3B.js'), GSTR3B: require('./doctype/GSTR3B/GSTR3B.js'),
Address: require('./doctype/Address/Address.js'), Address: require('./doctype/Address/Address.js'),
Contact: require('./doctype/Contact/Contact.js'), Contact: require('./doctype/Contact/Contact.js'),
JournalEntry: require('./doctype/JournalEntry/JournalEntry.js'), JournalEntry: require('./doctype/JournalEntry/JournalEntry.js'),
JournalEntryAccount: require('./doctype/JournalEntryAccount/JournalEntryAccount.js'), JournalEntryAccount: require('./doctype/JournalEntryAccount/JournalEntryAccount.js'),
JournalEntrySettings: require('./doctype/JournalEntrySettings/JournalEntrySettings.js'), JournalEntrySettings: require('./doctype/JournalEntrySettings/JournalEntrySettings.js'),
Quotation: require('./doctype/Quotation/Quotation.js'), Quotation: require('./doctype/Quotation/Quotation.js'),
QuotationItem: require('./doctype/QuotationItem/QuotationItem.js'), QuotationItem: require('./doctype/QuotationItem/QuotationItem.js'),
QuotationSettings: require('./doctype/QuotationSettings/QuotationSettings.js'), QuotationSettings: require('./doctype/QuotationSettings/QuotationSettings.js'),
SalesOrder: require('./doctype/SalesOrder/SalesOrder.js'), SalesOrder: require('./doctype/SalesOrder/SalesOrder.js'),
SalesOrderItem: require('./doctype/SalesOrderItem/SalesOrderItem.js'), SalesOrderItem: require('./doctype/SalesOrderItem/SalesOrderItem.js'),
SalesOrderSettings: require('./doctype/SalesOrderSettings/SalesOrderSettings.js'), SalesOrderSettings: require('./doctype/SalesOrderSettings/SalesOrderSettings.js'),
Fulfillment: require('./doctype/Fulfillment/Fulfillment.js'), Fulfillment: require('./doctype/Fulfillment/Fulfillment.js'),
FulfillmentItem: require('./doctype/FulfillmentItem/FulfillmentItem.js'), FulfillmentItem: require('./doctype/FulfillmentItem/FulfillmentItem.js'),
FulfillmentSettings: require('./doctype/FulfillmentSettings/FulfillmentSettings.js'), FulfillmentSettings: require('./doctype/FulfillmentSettings/FulfillmentSettings.js'),
PurchaseOrder: require('./doctype/PurchaseOrder/PurchaseOrder.js'), PurchaseOrder: require('./doctype/PurchaseOrder/PurchaseOrder.js'),
PurchaseOrderItem: require('./doctype/PurchaseOrderItem/PurchaseOrderItem.js'), PurchaseOrderItem: require('./doctype/PurchaseOrderItem/PurchaseOrderItem.js'),
PurchaseOrderSettings: require('./doctype/PurchaseOrderSettings/PurchaseOrderSettings.js'), PurchaseOrderSettings: require('./doctype/PurchaseOrderSettings/PurchaseOrderSettings.js'),
PurchaseReceipt: require('./doctype/PurchaseReceipt/PurchaseReceipt.js'), PurchaseReceipt: require('./doctype/PurchaseReceipt/PurchaseReceipt.js'),
PurchaseReceiptItem: require('./doctype/PurchaseReceiptItem/PurchaseReceiptItem.js'), PurchaseReceiptItem: require('./doctype/PurchaseReceiptItem/PurchaseReceiptItem.js'),
PurchaseReceiptSettings: require('./doctype/PurchaseReceiptSettings/PurchaseReceiptSettings.js'), PurchaseReceiptSettings: require('./doctype/PurchaseReceiptSettings/PurchaseReceiptSettings.js'),
Event: require('./doctype/Event/Event'), Event: require('./doctype/Event/Event'),
EventSchedule: require('./doctype/EventSchedule/EventSchedule'), EventSchedule: require('./doctype/EventSchedule/EventSchedule'),
EventSettings: require('./doctype/EventSettings/EventSettings'), EventSettings: require('./doctype/EventSettings/EventSettings'),
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')
}; };

View File

@ -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);