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

Merge with upstream

This commit is contained in:
Faris Ansari 2018-03-27 11:23:18 +05:30
commit ba32967956
19 changed files with 2707 additions and 2282 deletions

View File

@ -1,2 +1,2 @@
server: nodemon server.js
server: nodemon start.js
watch: node_modules/.bin/rollup -c --watch

37
client/index.js Normal file
View File

@ -0,0 +1,37 @@
const GeneralLedgerView = require('../reports/GeneralLedgerView');
const frappe = require('frappejs');
module.exports = {
start() {
// require modules
frappe.registerModels(require('../models'), 'client');
frappe.registerView('List', 'ToDo', require('frappejs/models/doctype/ToDo/ToDoList.js'));
frappe.registerView('Form', 'FilterSelector', require('frappejs/models/doctype/FilterSelector/FilterSelectorForm.js'));
frappe.registerView('List', 'Account', require('../models/doctype/Account/AccountList.js'));
frappe.registerView('Form', 'Account', require('../models/doctype/Account/AccountForm.js'));
frappe.registerView('List', 'Invoice', require('../models/doctype/Invoice/InvoiceList.js'));
frappe.registerView('List', 'Customer', require('../models/doctype/Party/CustomerList.js'));
frappe.router.add('report/general-ledger', async (params) => {
if (!frappe.views.generalLedger) {
frappe.views.generalLedger = new GeneralLedgerView();
}
await frappe.views.generalLedger.show(params);
})
frappe.desk.menu.addItem('ToDo', '#list/ToDo');
frappe.desk.menu.addItem('Accounts', '#list/Account');
frappe.desk.menu.addItem('Items', '#list/Item');
frappe.desk.menu.addItem('Customers', '#list/Customer');
frappe.desk.menu.addItem('Invoice', '#list/Invoice');
frappe.desk.menu.addItem('Settings', () => frappe.desk.showFormModal('SystemSettings'));
frappe.router.default = '#list/ToDo';
frappe.router.show(window.location.hash);
}
}

View File

@ -32,5 +32,11 @@ module.exports = {
"Expense"
]
}
]
],
events: {
validate: (doc) => {
}
}
}

View File

@ -8,7 +8,7 @@ module.exports = {
keywordFields: [
'account',
'party',
'reference_name'
'referenceName'
],
fields: [
{

View File

@ -99,17 +99,21 @@ module.exports = {
{ fields: [ "terms" ] },
],
formEvents: {
refresh: (form) => {
if (!form.ledgerLink) {
form.ledgerLink = form.container.addLink('Ledger Entries', () => {
frappe.flags.filters = {
reference_type: 'Invoice',
reference_name: form.doc.name
links: [
{
label: 'Ledger Entries',
condition: (form) => form.doc.submitted,
action:(form) => {
return {
route: ['table', 'AccountingLedgerEntry'],
params: {
filters: {
referenceType: 'Invoice',
referenceName: form.doc.name
}
}
frappe.router.setRoute('table', 'AccountingLedgerEntry');
});
};
}
}
}
]
}

View File

@ -23,5 +23,23 @@ module.exports = {
"label": "Supplier",
"fieldtype": "Check"
}
],
links: [
{
label: 'Invoices',
condition: (form) => form.doc.customer,
action: (form) => {
return {
route: ['table', 'Invoice'],
params: {
filters: {
customer: form.doc.name,
}
}
};
}
}
]
}

19
reports/GeneralLedger.js Normal file
View File

@ -0,0 +1,19 @@
const frappe = require('frappejs');
module.exports = class GeneralLedger {
async run(params) {
const filters = {};
if (params.account) filters.account = params.account;
if (params.party) filters.party = params.party;
if (params.from_date) filters.date = ('>=', params.from_date);
if (params.to_date) filters.date = ('<=', params.to_date);
let data = await frappe.db.getAll({
doctype: 'AccountingLedgerEntry',
fields: ['date', 'account', 'party', 'referenceType', 'referenceName', 'debit', 'credit'],
filters: filters
});
return data;
}
}

View File

@ -0,0 +1,28 @@
const ReportPage = require('frappejs/client/desk/reportpage');
const frappe = require('frappejs');
module.exports = class GeneralLedgerView extends ReportPage {
constructor() {
super({title: frappe._('General Ledger')});
this.addFilter({fieldtype: 'Link', target: 'Account', label: 'Account'});
this.addFilter({fieldtype: 'Link', target: 'Party', label: 'Party'});
this.addFilter({fieldtype: 'Date', label: 'From Date'});
this.addFilter({fieldtype: 'Date', label: 'To Date'});
this.method = 'general-ledger';
}
getColumns() {
return [
{label: 'Date', fieldtype: 'Date'},
{label: 'Account', fieldtype: 'Link'},
{label: 'Party', fieldtype: 'Link'},
{label: 'Description', fieldtype: 'Data'},
{label: 'Debit', fieldtype: 'Currency'},
{label: 'Credit', fieldtype: 'Currency'},
{label: 'Balance', fieldtype: 'Currency'}
]
}
}

View File

@ -1,15 +0,0 @@
const server = require('frappejs/server');
const frappe = require('frappejs');
server.start({
backend: 'sqlite',
connectionParams: {dbPath: 'test.db'},
static: './',
models: require('./models')
}).then(() => {
// set server-side modules
frappe.models.Invoice.documentClass = require('./models/doctype/Invoice/InvoiceServer.js');
frappe.metaCache = {};
frappe.syncDoc(require('./fixtures/invoicePrint'));
});

28
server/index.js Normal file
View File

@ -0,0 +1,28 @@
const server = require('frappejs/server');
const frappe = require('frappejs');
const GeneralLedger = require('../reports/GeneralLedger')
module.exports = {
async start() {
await server.start({
backend: 'sqlite',
connectionParams: {dbPath: 'test.db'},
staticPath: './www',
models: require('../models')
})
// set server-side modules
frappe.models.Invoice.documentClass = require('../models/doctype/Invoice/InvoiceServer.js');
frappe.metaCache = {};
frappe.syncDoc(require('../fixtures/invoicePrint'));
frappe.registerMethod({
method: 'general-ledger',
handler: async (args) => {
const generalLedger = new GeneralLedger();
return await generalLedger.run(args);
}
});
}
}

View File

@ -1,33 +0,0 @@
const client = require('frappejs/client');
// start server
client.start({
columns: 3,
server: 'localhost:8000'
}).then(() => {
// require modules
frappe.registerModels(require('../models'), 'client');
frappe.registerView('List', 'ToDo', require('frappejs/models/doctype/ToDo/ToDoList.js'));
frappe.registerView('Form', 'FilterSelector', require('frappejs/models/doctype/FilterSelector/FilterSelectorForm.js'));
frappe.registerView('List', 'Account', require('../models/doctype/Account/AccountList.js'));
frappe.registerView('Form', 'Account', require('../models/doctype/Account/AccountForm.js'));
frappe.registerView('List', 'Invoice', require('../models/doctype/Invoice/InvoiceList.js'));
frappe.registerView('List', 'Customer', require('../models/doctype/Party/CustomerList.js'));
frappe.desk.menu.addItem('ToDo', '#list/ToDo');
frappe.desk.menu.addItem('Accounts', '#list/Account');
frappe.desk.menu.addItem('Items', '#list/Item');
frappe.desk.menu.addItem('Customers', '#list/Customer');
frappe.desk.menu.addItem('Invoice', '#list/Invoice');
frappe.desk.menu.addItem('Settings', () => frappe.desk.showFormModal('SystemSettings'));
frappe.router.default = '#list/ToDo';
frappe.router.show(window.location.hash);
});
module.exports = false;

2
start.js Normal file
View File

@ -0,0 +1,2 @@
const server = require('./server');
server.start();

View File

@ -7395,6 +7395,8 @@ html {
background-color: lightyellow; }
.form-body .alert {
margin-top: 1rem; }
.form-inline .form-group {
margin-right: 0.5rem; }
.list-search {
padding: 1rem 2rem; }
.list-body .list-row {

File diff suppressed because one or more lines are too long

12
www/index.js Normal file
View File

@ -0,0 +1,12 @@
const client = require('frappejs/client');
const appClient = require('../client');
// start server
client.start({
columns: 3,
server: 'localhost:8000'
}).then(() => {
appClient.start();
});
module.exports = false;