mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
commit
1e43969daf
2
Procfile
2
Procfile
@ -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
37
client/index.js
Normal 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);
|
||||
|
||||
}
|
||||
}
|
@ -32,5 +32,11 @@ module.exports = {
|
||||
"Expense"
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
events: {
|
||||
validate: (doc) => {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ module.exports = {
|
||||
keywordFields: [
|
||||
'account',
|
||||
'party',
|
||||
'reference_name'
|
||||
'referenceName'
|
||||
],
|
||||
fields: [
|
||||
{
|
||||
|
@ -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');
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -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,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "frappe-accounting",
|
||||
"version": "1.0.0",
|
||||
"main": "server.js",
|
||||
"main": "start.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "mocha tests",
|
||||
"start": "nodemon server.js"
|
||||
"start": "nodemon start.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"frappejs": "link:../frappejs"
|
||||
|
19
reports/GeneralLedger.js
Normal file
19
reports/GeneralLedger.js
Normal 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;
|
||||
}
|
||||
}
|
28
reports/GeneralLedgerView.js
Normal file
28
reports/GeneralLedgerView.js
Normal 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.url = '/api/report/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'}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
15
server.js
15
server.js
@ -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'));
|
||||
});
|
26
server/index.js
Normal file
26
server/index.js
Normal file
@ -0,0 +1,26 @@
|
||||
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.app.get('/api/report/general-ledger', frappe.asyncHandler(async function(request, response) {
|
||||
const generalLedger = new GeneralLedger();
|
||||
const data = await generalLedger.run(request.query);
|
||||
response.json(data);
|
||||
}));
|
||||
}
|
||||
}
|
33
src/index.js
33
src/index.js
@ -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;
|
6
dist/css/style.css → www/dist/css/style.css
vendored
6
dist/css/style.css → www/dist/css/style.css
vendored
@ -7380,8 +7380,6 @@ html {
|
||||
padding-bottom: 0; }
|
||||
.page .page-links {
|
||||
padding: 1rem 2rem; }
|
||||
.page .page-links .page-link {
|
||||
display: inline-block; }
|
||||
.page .page-error {
|
||||
text-align: center;
|
||||
padding: 200px 0px; }
|
||||
@ -7397,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 {
|
||||
@ -7436,6 +7436,8 @@ html {
|
||||
.table-page-wrapper {
|
||||
width: 100%;
|
||||
padding: 1rem 2rem; }
|
||||
.filter-toolbar {
|
||||
padding: 1rem 2rem; }
|
||||
.table-wrapper {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 2rem; }
|
689
dist/js/bundle.js → www/dist/js/bundle.js
vendored
689
dist/js/bundle.js → www/dist/js/bundle.js
vendored
File diff suppressed because it is too large
Load Diff
12
www/index.js
Normal file
12
www/index.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user