2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +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 {
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.entryMap = {};
// To change balance while entering ledger entries
@ -102,7 +105,9 @@ module.exports = class LedgerPosting {
validateEntries() {
let { debit, credit } = this.getTotalDebitAndCredit();
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 = {
name: "AccountingLedgerEntry",
label: "Ledger Entry",
naming: "autoincrement",
doctype: "DocType",
isSingle: 0,
isChild: 0,
keywordFields: [
'account',
'party',
'referenceName'
],
fields: [
{
fieldname: "date",
label: "Date",
fieldtype: "Date"
},
{
fieldname: "account",
label: "Account",
fieldtype: "Link",
target: "Account",
required: 1
},
{
fieldname: "description",
label: "Description",
fieldtype: "Text"
},
{
fieldname: "party",
label: "Party",
fieldtype: "Link",
target: "Party"
},
{
fieldname: "debit",
label: "Debit",
fieldtype: "Currency",
},
{
fieldname: "credit",
label: "Credit",
fieldtype: "Currency",
},
{
fieldname: "againstAccount",
label: "Against Account",
fieldtype: "Text"
},
{
fieldname: "referenceType",
label: "Ref. Type",
fieldtype: "Data",
},
{
fieldname: "referenceName",
label: "Ref. Name",
fieldtype: "DynamicLink",
references: "referenceType"
},
{
fieldname: "balance",
label: "Balance",
fieldtype: "Currency",
},
]
}
name: 'AccountingLedgerEntry',
label: 'Ledger Entry',
naming: 'autoincrement',
doctype: 'DocType',
isSingle: 0,
isChild: 0,
keywordFields: ['account', 'party', 'referenceName'],
fields: [
{
fieldname: 'date',
label: 'Date',
fieldtype: 'Date'
},
{
fieldname: 'account',
label: 'Account',
fieldtype: 'Link',
target: 'Account',
required: 1
},
{
fieldname: 'description',
label: 'Description',
fieldtype: 'Text'
},
{
fieldname: 'party',
label: 'Party',
fieldtype: 'Link',
target: 'Party'
},
{
fieldname: 'debit',
label: 'Debit',
fieldtype: 'Currency'
},
{
fieldname: 'credit',
label: 'Credit',
fieldtype: 'Currency'
},
{
fieldname: 'againstAccount',
label: 'Against Account',
fieldtype: 'Text'
},
{
fieldname: 'referenceType',
label: 'Ref. Type',
fieldtype: 'Data'
},
{
fieldname: 'referenceName',
label: 'Ref. Name',
fieldtype: 'DynamicLink',
references: 'referenceType'
},
{
fieldname: 'balance',
label: 'Balance',
fieldtype: 'Currency'
}
],
quickEditFields: [
'date',
'account',
'description',
'party',
'debit',
'credit',
'againstAccount',
'referenceType',
'referenceName',
'balance'
]
};

View File

@ -48,6 +48,7 @@ module.exports = {
{
fieldname: 'paymentAccount',
label: 'To Account',
placeholder: 'To Account',
fieldtype: 'Link',
target: 'Account',
required: 1,
@ -59,11 +60,17 @@ module.exports = {
return { accountType: ['in', ['Bank', 'Cash']], isGroup: 0 };
}
}
},
formula: doc => {
if (doc.paymentMethod === 'Cash') {
return 'Cash';
}
}
},
{
fieldname: 'paymentMethod',
label: 'Payment Method',
placeholder: 'Payment Method',
fieldtype: 'Select',
options: ['', 'Cash', 'Cheque', 'Transfer'],
required: 1
@ -71,17 +78,20 @@ module.exports = {
{
fieldname: 'referenceId',
label: 'Ref. / Cheque No.',
placeholder: 'Ref. / Cheque No.',
fieldtype: 'Data',
required: 1 // TODO: UNIQUE
},
{
fieldname: 'referenceDate',
label: 'Ref. Date',
placeholder: 'Ref. Date',
fieldtype: 'Date'
},
{
fieldname: 'clearanceDate',
label: 'Clearance Date',
placeholder: 'Clearance Date',
fieldtype: 'Date',
hidden: doc => {
return doc.paymentMethod === 'Cash' ? 1 : 0;

View File

@ -1,72 +1,71 @@
module.exports = {
models: {
SetupWizard: require('./doctype/SetupWizard/SetupWizard'),
DashboardSettings: require('./doctype/DashboardSettings/DashboardSettings'),
DashboardChart: require('./doctype/DashboardChart/DashboardChart'),
Currency: require('./doctype/Currency/Currency'),
Color: require('./doctype/Color/Color'),
Account: require('./doctype/Account/Account.js'),
AccountingSettings: require('./doctype/AccountingSettings/AccountingSettings'),
CompanySettings: require('./doctype/CompanySettings/CompanySettings'),
AccountingLedgerEntry: require('./doctype/AccountingLedgerEntry/AccountingLedgerEntry.js'),
Party: require('./doctype/Party/Party.js'),
Customer: require('./doctype/Party/Customer'),
Supplier: require('./doctype/Party/Supplier'),
SetupWizard: require('./doctype/SetupWizard/SetupWizard'),
DashboardSettings: require('./doctype/DashboardSettings/DashboardSettings'),
DashboardChart: require('./doctype/DashboardChart/DashboardChart'),
Currency: require('./doctype/Currency/Currency'),
Color: require('./doctype/Color/Color'),
Account: require('./doctype/Account/Account.js'),
AccountingSettings: require('./doctype/AccountingSettings/AccountingSettings'),
CompanySettings: require('./doctype/CompanySettings/CompanySettings'),
AccountingLedgerEntry: require('./doctype/AccountingLedgerEntry/AccountingLedgerEntry.js'),
Party: require('./doctype/Party/Party.js'),
Customer: require('./doctype/Party/Customer'),
Supplier: require('./doctype/Party/Supplier'),
Payment: require('./doctype/Payment/Payment.js'),
PaymentFor: require('./doctype/PaymentFor/PaymentFor.js'),
PaymentSettings: require('./doctype/PaymentSettings/PaymentSettings.js'),
Payment: require('./doctype/Payment/Payment.js'),
PaymentFor: require('./doctype/PaymentFor/PaymentFor.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'),
SalesInvoiceItem: require('./doctype/SalesInvoiceItem/SalesInvoiceItem.js'),
SalesInvoiceSettings: require('./doctype/SalesInvoiceSettings/SalesInvoiceSettings.js'),
SalesInvoice: require('./doctype/SalesInvoice/SalesInvoice.js'),
SalesInvoiceItem: require('./doctype/SalesInvoiceItem/SalesInvoiceItem.js'),
SalesInvoiceSettings: require('./doctype/SalesInvoiceSettings/SalesInvoiceSettings.js'),
PurchaseInvoice: require('./doctype/PurchaseInvoice/PurchaseInvoice.js'),
PurchaseInvoiceItem: require('./doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js'),
PurchaseInvoiceSettings: require('./doctype/PurchaseInvoiceSettings/PurchaseInvoiceSettings.js'),
PurchaseInvoice: require('./doctype/PurchaseInvoice/PurchaseInvoice.js'),
PurchaseInvoiceItem: require('./doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js'),
PurchaseInvoiceSettings: require('./doctype/PurchaseInvoiceSettings/PurchaseInvoiceSettings.js'),
Tax: require('./doctype/Tax/Tax.js'),
TaxDetail: require('./doctype/TaxDetail/TaxDetail.js'),
TaxSummary: require('./doctype/TaxSummary/TaxSummary.js'),
Tax: require('./doctype/Tax/Tax.js'),
TaxDetail: require('./doctype/TaxDetail/TaxDetail.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'),
Contact: require('./doctype/Contact/Contact.js'),
Address: require('./doctype/Address/Address.js'),
Contact: require('./doctype/Contact/Contact.js'),
JournalEntry: require('./doctype/JournalEntry/JournalEntry.js'),
JournalEntryAccount: require('./doctype/JournalEntryAccount/JournalEntryAccount.js'),
JournalEntrySettings: require('./doctype/JournalEntrySettings/JournalEntrySettings.js'),
JournalEntry: require('./doctype/JournalEntry/JournalEntry.js'),
JournalEntryAccount: require('./doctype/JournalEntryAccount/JournalEntryAccount.js'),
JournalEntrySettings: require('./doctype/JournalEntrySettings/JournalEntrySettings.js'),
Quotation: require('./doctype/Quotation/Quotation.js'),
QuotationItem: require('./doctype/QuotationItem/QuotationItem.js'),
QuotationSettings: require('./doctype/QuotationSettings/QuotationSettings.js'),
Quotation: require('./doctype/Quotation/Quotation.js'),
QuotationItem: require('./doctype/QuotationItem/QuotationItem.js'),
QuotationSettings: require('./doctype/QuotationSettings/QuotationSettings.js'),
SalesOrder: require('./doctype/SalesOrder/SalesOrder.js'),
SalesOrderItem: require('./doctype/SalesOrderItem/SalesOrderItem.js'),
SalesOrderSettings: require('./doctype/SalesOrderSettings/SalesOrderSettings.js'),
SalesOrder: require('./doctype/SalesOrder/SalesOrder.js'),
SalesOrderItem: require('./doctype/SalesOrderItem/SalesOrderItem.js'),
SalesOrderSettings: require('./doctype/SalesOrderSettings/SalesOrderSettings.js'),
Fulfillment: require('./doctype/Fulfillment/Fulfillment.js'),
FulfillmentItem: require('./doctype/FulfillmentItem/FulfillmentItem.js'),
FulfillmentSettings: require('./doctype/FulfillmentSettings/FulfillmentSettings.js'),
Fulfillment: require('./doctype/Fulfillment/Fulfillment.js'),
FulfillmentItem: require('./doctype/FulfillmentItem/FulfillmentItem.js'),
FulfillmentSettings: require('./doctype/FulfillmentSettings/FulfillmentSettings.js'),
PurchaseOrder: require('./doctype/PurchaseOrder/PurchaseOrder.js'),
PurchaseOrderItem: require('./doctype/PurchaseOrderItem/PurchaseOrderItem.js'),
PurchaseOrderSettings: require('./doctype/PurchaseOrderSettings/PurchaseOrderSettings.js'),
PurchaseOrder: require('./doctype/PurchaseOrder/PurchaseOrder.js'),
PurchaseOrderItem: require('./doctype/PurchaseOrderItem/PurchaseOrderItem.js'),
PurchaseOrderSettings: require('./doctype/PurchaseOrderSettings/PurchaseOrderSettings.js'),
PurchaseReceipt: require('./doctype/PurchaseReceipt/PurchaseReceipt.js'),
PurchaseReceiptItem: require('./doctype/PurchaseReceiptItem/PurchaseReceiptItem.js'),
PurchaseReceiptSettings: require('./doctype/PurchaseReceiptSettings/PurchaseReceiptSettings.js'),
PurchaseReceipt: require('./doctype/PurchaseReceipt/PurchaseReceipt.js'),
PurchaseReceiptItem: require('./doctype/PurchaseReceiptItem/PurchaseReceiptItem.js'),
PurchaseReceiptSettings: require('./doctype/PurchaseReceiptSettings/PurchaseReceiptSettings.js'),
Event: require('./doctype/Event/Event'),
EventSchedule: require('./doctype/EventSchedule/EventSchedule'),
EventSettings: require('./doctype/EventSettings/EventSettings'),
Event: require('./doctype/Event/Event'),
EventSchedule: require('./doctype/EventSchedule/EventSchedule'),
EventSettings: require('./doctype/EventSettings/EventSettings'),
Email: require('./doctype/Email/Email'),
EmailAccount: require('./doctype/EmailAccount/EmailAccount'),
Email: require('./doctype/Email/Email'),
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 }">
<template v-for="df in fields">
<FormControl
:key="df.fieldname"
v-if="df.fieldtype === 'Table'"
ref="controls"
size="small"
@ -11,7 +12,7 @@
/>
<template v-else>
<template v-if="inlineEditField === df && inlineEditDoc">
<div class="border-b">
<div class="border-b" :key="df.fieldname">
<TwoColumnForm
ref="inlineEditForm"
:doc="inlineEditDoc"
@ -39,6 +40,7 @@
</div>
</template>
<div
:key="df.fieldname"
v-else
class="grid"
:class="{ 'border-b': !noBorder }"
@ -71,7 +73,7 @@
</div>
</template>
<script>
import { _ } from 'frappejs/utils';
import frappe from 'frappejs';
import FormControl from '@/components/Controls/FormControl';
import Button from '@/components/Button';
import { handleErrorWithDialog } from '@/utils';
@ -128,7 +130,6 @@ let TwoColumnForm = {
// handle rename
if (this.autosave && df.fieldname === 'name' && !this.doc.isNew()) {
return this.doc.rename(value);
return;
}
this.doc.set(df.fieldname, value);