2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +00:00

- SalesInvoice renaming typo

- Reports search
This commit is contained in:
thefalconx33 2019-08-05 15:03:05 +05:30
parent f88fbe240a
commit 88021193fc
20 changed files with 141 additions and 104 deletions

View File

@ -1,5 +1,6 @@
module.exports = { module.exports = {
name: 'Account', name: 'Account',
label: 'Account',
doctype: 'DocType', doctype: 'DocType',
documentClass: require('./AccountDocument.js'), documentClass: require('./AccountDocument.js'),
isSingle: 0, isSingle: 0,

View File

@ -2,6 +2,7 @@ const frappe = require('frappejs');
module.exports = { module.exports = {
name: 'GSTR3B', name: 'GSTR3B',
label: 'GSTR 3B',
doctype: 'DocType', doctype: 'DocType',
documentClass: require('./GSTR3BDocument.js'), documentClass: require('./GSTR3BDocument.js'),
print: { print: {

View File

@ -49,7 +49,7 @@ module.exports = class GSTR3B extends BaseDocument {
gstr3bData[0].push(await this.makeGSTRow(ledgerEntry)); gstr3bData[0].push(await this.makeGSTRow(ledgerEntry));
} }
for (let ledgerEntry of gstr2Data) { for (let ledgerEntry of gstr2Data) {
ledgerEntry.doctype = 'BiPurchaseInvoicell'; ledgerEntry.doctype = 'PurchaseInvoice';
gstr3bData[1].push(await this.makeGSTRow(ledgerEntry)); gstr3bData[1].push(await this.makeGSTRow(ledgerEntry));
} }

View File

@ -27,13 +27,24 @@ module.exports = {
label: 'From Account', label: 'From Account',
fieldtype: 'Link', fieldtype: 'Link',
target: 'Account', target: 'Account',
required: 1 required: 1,
getFilters: (query, doc) => {
if (doc.paymentType === 'Pay') {
if (doc.paymentMethod === 'Cash')
return { accountType: 'Cash', isGroup: 0 };
else
return {
accountType: ['in', ['Bank', 'Cash']],
isGroup: 0
};
}
}
}, },
{ {
fieldname: 'paymentType', fieldname: 'paymentType',
label: 'Payment Type', label: 'Payment Type',
fieldtype: 'Select', fieldtype: 'Select',
options: ['Recieve', 'Pay'], options: ['', 'Receive', 'Pay'],
required: 1 required: 1
}, },
{ {
@ -43,12 +54,13 @@ module.exports = {
target: 'Account', target: 'Account',
required: 1, required: 1,
getFilters: (query, doc) => { getFilters: (query, doc) => {
if (doc.paymentMethod === 'Cash') if (doc.paymentType === 'Receive') {
if (doc.paymentMethod === 'Cash') {
return { accountType: 'Cash', isGroup: 0 }; return { accountType: 'Cash', isGroup: 0 };
return { } else {
accountType: ['in', ['Bank', 'Cash']], return { accountType: ['in', ['Bank', 'Cash']], isGroup: 0 };
isGroup: 0 }
}; }
} }
}, },
{ {

View File

@ -1,7 +1,7 @@
const model = require('frappejs/model'); const model = require('frappejs/model');
const Invoice = require('../Invoice/Invoice'); const SalesInvoice = require('../SalesInvoice/SalesInvoice');
const Quotation = model.extend(Invoice, { const Quotation = model.extend(SalesInvoice, {
name: "Quotation", name: "Quotation",
label: "Quotation", label: "Quotation",
settings: "QuotationSettings", settings: "QuotationSettings",

View File

@ -1,3 +1,3 @@
const InvoiceDocument = require('../Invoice/InvoiceDocument'); const SalesInvoiceDocument = require('../SalesInvoice/SalesInvoiceDocument');
module.exports = class Quotation extends InvoiceDocument { } module.exports = class Quotation extends SalesInvoiceDocument {};

View File

@ -1,6 +1,6 @@
const model = require('frappejs/model'); const model = require('frappejs/model');
const InvoiceItem = require('../InvoiceItem/InvoiceItem'); const SalesInvoiceItem = require('../SalesInvoiceItem/SalesInvoiceItem');
module.exports = model.extend(InvoiceItem, { module.exports = model.extend(SalesInvoiceItem, {
name: "QuotationItem" name: "QuotationItem"
}); });

View File

@ -1,7 +1,7 @@
const model = require('frappejs/model'); const model = require('frappejs/model');
const InvoiceSettings = require('../InvoiceSettings/InvoiceSettings'); const SalesInvoiceSettings = require('../SalesInvoiceSettings/SalesInvoiceSettings');
module.exports = model.extend(InvoiceSettings, { module.exports = model.extend(SalesInvoiceSettings, {
"name": "QuotationSettings", "name": "QuotationSettings",
"label": "Quotation Settings", "label": "Quotation Settings",
"fields": [ "fields": [

View File

@ -145,7 +145,7 @@ module.exports = {
form.doc.submitted && form.doc.outstandingAmount !== 0.0, form.doc.submitted && form.doc.outstandingAmount !== 0.0,
action: async form => { action: async form => {
const payment = await frappe.getNewDoc('Payment'); const payment = await frappe.getNewDoc('Payment');
payment.paymentType = 'Recieve'; payment.paymentType = 'Receive';
payment.party = form.doc.customer; payment.party = form.doc.customer;
payment.account = form.doc.account; payment.account = form.doc.account;
payment.for = [ payment.for = [

View File

@ -61,15 +61,15 @@ export default {
await this.getFont(); await this.getFont();
}, },
async getTemplate() { async getTemplate() {
let invoiceSettings = await frappe.getDoc('InvoiceSettings'); let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings');
this.template = invoiceTemplates[invoiceSettings.template]; this.template = invoiceTemplates[invoiceSettings.template];
}, },
async getColor() { async getColor() {
let invoiceSettings = await frappe.getDoc('InvoiceSettings'); let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings');
this.themeColor = invoiceSettings.themeColor; this.themeColor = invoiceSettings.themeColor;
}, },
async getFont() { async getFont() {
let invoiceSettings = await frappe.getDoc('InvoiceSettings'); let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings');
this.font = invoiceSettings.font; this.font = invoiceSettings.font;
}, },
async toggleCustomizer() { async toggleCustomizer() {

View File

@ -3,22 +3,20 @@ const frappe = require('frappejs');
class SalesRegister { class SalesRegister {
async run({ fromDate, toDate, customer }) { async run({ fromDate, toDate, customer }) {
let filters = {}; let filters = {};
if(customer) { if (customer) {
filters.customer = customer; filters.customer = customer;
} }
if (fromDate && toDate) { if (fromDate && toDate) {
filters.date = ['>=', fromDate, '<=', toDate]; filters.date = ['>=', fromDate, '<=', toDate];
} } else if (fromDate) {
else if (fromDate) {
filters.date = ['>=', fromDate]; filters.date = ['>=', fromDate];
} } else if (toDate) {
else if (toDate) {
filters.date = ['<=', toDate]; filters.date = ['<=', toDate];
} }
const invoices = await frappe.db.getAll({ const invoices = await frappe.db.getAll({
doctype: 'Invoice', doctype: 'SalesInvoice',
fields: ['name', 'date', 'customer', 'account', 'netTotal', 'grandTotal'], fields: ['name', 'date', 'customer', 'account', 'netTotal', 'grandTotal'],
filters: filters, filters: filters,
orderBy: 'date', orderBy: 'date',

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="col-6"> <div class="col-6">
<div class="card mx-2 my-2"> <div class="card mx-3 my-3">
<div class="card-body"> <div class="card-body">
<div :ref="chartData.title"></div> <div :ref="chartData.title"></div>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <div v-on-outside-click="clearInput">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text pt-1"> <span class="input-group-text pt-1">
@ -17,18 +17,15 @@
aria-label="Recipient's username" aria-label="Recipient's username"
/> />
</div> </div>
<div v-if="inputValue" class="suggestion-list position-absolute shadow-sm" style="width: 100%"> <div v-if="inputValue" class="suggestion-list position-absolute shadow-sm" style="width: 98%">
<list-row <list-row
v-for="doc in suggestion" v-for="doc in suggestion"
:key="doc.name" :key="doc.name"
:class="doc.sep ? 'seperator': ''" :class="doc.seperator ? 'seperator': ''"
class="d-flex align-items-center" class="d-flex align-items-center"
@click.native="routeTo(doc.route)" @click.native="routeTo(doc.route)"
> >
<span v-if="!doc.sep"> <div :class="doc.seperator ? 'small' : ''">{{ doc.name }}</div>
<feather-icon class="mr-1" name="minus" />
</span>
<div :class="doc.sep ? 'small' : ''">{{ doc.name }}</div>
<div class="small ml-auto">{{ doc.doctype }}</div> <div class="small ml-auto">{{ doc.doctype }}</div>
</list-row> </list-row>
</div> </div>
@ -61,17 +58,18 @@ export default {
isSingle: 0, isSingle: 0,
isChild: 0 isChild: 0
}); });
const documents = await this.getSearchedDocuments(searchableDoctypes); const documents = await this.getDocuments(searchableDoctypes);
const doctypes = await this.getSearchedDoctypes(searchableDoctypes); const doctypes = this.getDoctypes(searchableDoctypes);
this.suggestion = documents.concat(doctypes); const reports = this.getReports();
this.suggestion = documents.concat(doctypes).concat(reports);
if (this.suggestion.length === 0) if (this.suggestion.length === 0)
this.suggestion = [{ sep: true, name: 'No results found.' }]; this.suggestion = [{ seperator: true, name: 'No results found.' }];
}, },
clearInput() { clearInput(e) {
this.inputValue = ''; this.inputValue = '';
this.$emit('change', null); this.$emit('change', null);
}, },
async getSearchedDocuments(searchableDoctypes) { async getDocuments(searchableDoctypes) {
const promises = searchableDoctypes.map(doctype => { const promises = searchableDoctypes.map(doctype => {
return frappe.db.getAll({ return frappe.db.getAll({
doctype, doctype,
@ -83,7 +81,7 @@ export default {
// data contains list of documents, sorted according to position of its doctype in searchableDoctypes // data contains list of documents, sorted according to position of its doctype in searchableDoctypes
const items = []; const items = [];
items.push({ items.push({
sep: true, seperator: true,
name: 'Documents' name: 'Documents'
}); });
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
@ -102,20 +100,43 @@ export default {
if (items.length !== 1) return items; if (items.length !== 1) return items;
return []; return [];
}, },
getSearchedDoctypes(searchableDoctypes) { getDoctypes(searchableDoctypes) {
const items = [{ sep: true, name: 'DocTypes' }]; const items = [{ seperator: true, name: 'Lists' }];
let filteredDoctypes = searchableDoctypes.filter(doctype => { let filteredDoctypes = searchableDoctypes.filter(doctype => {
return doctype.indexOf(this.inputValue) != -1; return (
doctype.toLowerCase().indexOf(this.inputValue.toLowerCase()) != -1
);
}); });
filteredDoctypes = filteredDoctypes.map(doctype => { filteredDoctypes = filteredDoctypes.map(doctype => {
var titleCase = doctype.replace(/([A-Z])/g, ' $1');
titleCase = titleCase.charAt(0).toUpperCase() + titleCase.slice(1);
return { return {
name: doctype, name: titleCase,
route: `/list/${doctype}` route: `/list/${doctype}`
}; };
}); });
if (filteredDoctypes.length > 0) return items.concat(filteredDoctypes); if (filteredDoctypes.length > 0) return items.concat(filteredDoctypes);
return []; return [];
}, },
getReports() {
const items = [{ seperator: true, name: 'Reports' }];
let reports = require('../../reports/view');
reports = Object.values(reports);
let filteredReports = reports.filter(report => {
return (
report.title.toLowerCase().indexOf(this.inputValue.toLowerCase()) !=
-1
);
});
filteredReports = filteredReports.map(report => {
return {
name: report.title,
route: `/report/${report.method}`
};
});
if (filteredReports.length > 0) return items.concat(filteredReports);
return [];
},
routeTo(route) { routeTo(route) {
this.$router.push(route); this.$router.push(route);
this.inputValue = ''; this.inputValue = '';
@ -147,6 +168,8 @@ input:focus {
} }
.suggestion-list { .suggestion-list {
z-index: 2; z-index: 2;
max-height: 90vh;
overflow: auto;
} }
</style> </style>

View File

@ -155,9 +155,6 @@ export default Branch;
border-radius: 4px; border-radius: 4px;
cursor: pointer; cursor: pointer;
} }
.branch-label:hover {
background-color: $dropdown-link-hover-bg;
}
.branch-children { .branch-children {
padding-left: 2.25rem; padding-left: 2.25rem;
} }

View File

@ -25,8 +25,8 @@ export default {
}; };
}, },
async beforeMount() { async beforeMount() {
const dashboardSettings = await frappe.getDoc('DashboardSettings'); const { charts } = await frappe.getDoc('DashboardSettings');
this.charts = dashboardSettings.charts; this.charts = charts;
this.charts.forEach(async c => { this.charts.forEach(async c => {
const { labels, datasets } = await this.getAccountData(c.account, c.type); const { labels, datasets } = await this.getAccountData(c.account, c.type);
this.chartData.push({ this.chartData.push({
@ -44,6 +44,7 @@ export default {
async getAccountData(account, chartType) { async getAccountData(account, chartType) {
let entriesArray = []; let entriesArray = [];
let accountType; let accountType;
async function getAccountEntries(accountName) { async function getAccountEntries(accountName) {
const account = await frappe.getDoc('Account', accountName); const account = await frappe.getDoc('Account', accountName);
accountType = account.rootType; accountType = account.rootType;
@ -66,7 +67,9 @@ export default {
} }
return entriesArray; return entriesArray;
} }
let ledgerEntries = await getAccountEntries(account); let ledgerEntries = await getAccountEntries(account);
accountType = ['Asset', 'Expense'].includes(accountType) accountType = ['Asset', 'Expense'].includes(accountType)
? 'debit' ? 'debit'
: 'credit'; : 'credit';
@ -111,6 +114,7 @@ export default {
values: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] values: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
} }
]; ];
// Arrange month labels according to current month.
for (let i = 0; i < 13; i++) { for (let i = 0; i < 13; i++) {
let year = i + currentMonthIndex >= 12 ? currentYear : currentYear - 1; let year = i + currentMonthIndex >= 12 ? currentYear : currentYear - 1;
labels.push(monthName[(i + currentMonthIndex) % 12]); labels.push(monthName[(i + currentMonthIndex) % 12]);

View File

@ -24,5 +24,6 @@ export default {
} }
.sidebar { .sidebar {
position: fixed; position: fixed;
z-index: 1;
} }
</style> </style>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="bg-white"> <div class="bg-white">
<page-header :breadcrumbs="breadcrumbs" /> <page-header :breadcrumbs="breadcrumbs" />
<div class="form-container col-sm-8 col-lg-6 mx-2 mt-4"> <div class="form-container col-9 col-lg-7 col-xl-6 mx-2 mt-4">
<form-actions <form-actions
v-if="shouldRenderForm" v-if="shouldRenderForm"
:doc="doc" :doc="doc"
@ -56,12 +56,12 @@ export default {
if (this.doc) if (this.doc)
return [ return [
{ {
title: this.meta.label || this.meta.name, title: this.meta.label || this.doctype,
route: '#/list/' + this.doctype route: '#/list/' + this.doctype
}, },
{ {
title: this.doc._notInserted title: this.doc._notInserted
? 'New ' + this.meta.label || this.meta.name ? 'New ' + (this.meta.label || this.doctype)
: this.doc.name, : this.doc.name,
route: '' route: ''
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="bg-white"> <div class="bg-light">
<page-header :breadcrumbs="breadcrumbs" /> <page-header :breadcrumbs="breadcrumbs" />
<component :is="printComponent" v-if="doc" :doc="doc" @send="send" @makePDF="makePDF" /> <component :is="printComponent" v-if="doc" :doc="doc" @send="send" @makePDF="makePDF" />
</div> </div>
@ -25,12 +25,12 @@ export default {
if (this.doc) if (this.doc)
return [ return [
{ {
title: this.meta.label || this.meta.name, title: this.meta.label || this.doctype,
route: '#/list/' + this.doctype route: '#/list/' + this.doctype
}, },
{ {
title: this.doc._notInserted title: this.doc._notInserted
? 'New ' + this.meta.label || this.meta.name ? 'New ' + this.meta.label || this.doctype
: this.doc.name, : this.doc.name,
route: `#/edit/${this.doctype}/${this.name}` route: `#/edit/${this.doctype}/${this.name}`
}, },

View File

@ -5,9 +5,9 @@
<page-header :breadcrumbs="breadcrumbs" style="flex-grow: 1;" /> <page-header :breadcrumbs="breadcrumbs" style="flex-grow: 1;" />
<report-links class="d-flex flex-row-reverse" v-if="linksExists" :links="links"></report-links> <report-links class="d-flex flex-row-reverse" v-if="linksExists" :links="links"></report-links>
</div> </div>
<div class="row pb-4"> <div class="row pb-4 pl-1">
<report-filters <report-filters
class="col-12 pr-0" class="col-12"
v-if="shouldRenderFields" v-if="shouldRenderFields"
:filterFields="reportConfig.filterFields" :filterFields="reportConfig.filterFields"
:filterDoc="filterDoc" :filterDoc="filterDoc"
@ -15,7 +15,7 @@
@change="getReportData" @change="getReportData"
></report-filters> ></report-filters>
</div> </div>
<div class="pt-2 pr-3" ref="datatable" v-once></div> <div class="pt-2 pr-2 pl-2" ref="datatable" v-once></div>
</div> </div>
<not-found v-if="!reportConfig" /> <not-found v-if="!reportConfig" />
</div> </div>

View File

@ -8,11 +8,11 @@
<hr class="mt-4" /> <hr class="mt-4" />
<setting-section doctype="CompanySettings" /> <setting-section doctype="CompanySettings" />
<hr class="mt-4" /> <hr class="mt-4" />
<setting-section doctype="DashboardSettings" />
<hr class="mt-4" />
<setting-section doctype="EmailAccount" /> <setting-section doctype="EmailAccount" />
<hr class="mt-4" /> <hr class="mt-4" />
<setting-section doctype="SystemSettings" /> <setting-section doctype="SystemSettings" />
<hr class="mt-4" />
<setting-section doctype="DashboardSettings" />
</div> </div>
</div> </div>
</div> </div>