2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +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 = {
name: 'Account',
label: 'Account',
doctype: 'DocType',
documentClass: require('./AccountDocument.js'),
isSingle: 0,

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
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",
label: "Quotation",
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 InvoiceItem = require('../InvoiceItem/InvoiceItem');
const SalesInvoiceItem = require('../SalesInvoiceItem/SalesInvoiceItem');
module.exports = model.extend(InvoiceItem, {
module.exports = model.extend(SalesInvoiceItem, {
name: "QuotationItem"
});

View File

@ -1,7 +1,7 @@
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",
"label": "Quotation Settings",
"fields": [

View File

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

View File

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

View File

@ -1,55 +1,53 @@
const frappe = require('frappejs');
class SalesRegister {
async run({ fromDate, toDate, customer }) {
let filters = {};
if(customer) {
filters.customer = customer;
}
if (fromDate && toDate) {
filters.date = ['>=', fromDate, '<=', toDate];
}
else if (fromDate) {
filters.date = ['>=', fromDate];
}
else if (toDate) {
filters.date = ['<=', toDate];
}
const invoices = await frappe.db.getAll({
doctype: 'Invoice',
fields: ['name', 'date', 'customer', 'account', 'netTotal', 'grandTotal'],
filters: filters,
orderBy: 'date',
order: 'desc'
});
const invoiceNames = invoices.map(d => d.name);
const taxes = await frappe.db.getAll({
doctype: 'TaxSummary',
fields: ['parent', 'amount'],
filters: {
parenttype: 'Invoice',
parent: ['in', invoiceNames]
},
orderBy: 'name'
});
for (let invoice of invoices) {
invoice.totalTax = taxes
.filter(tax => tax.parent === invoice.name)
.reduce((acc, tax) => {
if (tax.amount) {
acc = acc + tax.amount;
}
return acc;
}, 0);
}
return { rows: invoices };
async run({ fromDate, toDate, customer }) {
let filters = {};
if (customer) {
filters.customer = customer;
}
if (fromDate && toDate) {
filters.date = ['>=', fromDate, '<=', toDate];
} else if (fromDate) {
filters.date = ['>=', fromDate];
} else if (toDate) {
filters.date = ['<=', toDate];
}
const invoices = await frappe.db.getAll({
doctype: 'SalesInvoice',
fields: ['name', 'date', 'customer', 'account', 'netTotal', 'grandTotal'],
filters: filters,
orderBy: 'date',
order: 'desc'
});
const invoiceNames = invoices.map(d => d.name);
const taxes = await frappe.db.getAll({
doctype: 'TaxSummary',
fields: ['parent', 'amount'],
filters: {
parenttype: 'Invoice',
parent: ['in', invoiceNames]
},
orderBy: 'name'
});
for (let invoice of invoices) {
invoice.totalTax = taxes
.filter(tax => tax.parent === invoice.name)
.reduce((acc, tax) => {
if (tax.amount) {
acc = acc + tax.amount;
}
return acc;
}, 0);
}
return { rows: invoices };
}
}
module.exports = SalesRegister;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<template>
<div class="bg-white">
<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
v-if="shouldRenderForm"
:doc="doc"
@ -56,12 +56,12 @@ export default {
if (this.doc)
return [
{
title: this.meta.label || this.meta.name,
title: this.meta.label || this.doctype,
route: '#/list/' + this.doctype
},
{
title: this.doc._notInserted
? 'New ' + this.meta.label || this.meta.name
? 'New ' + (this.meta.label || this.doctype)
: this.doc.name,
route: ''
}

View File

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

View File

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

View File

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