mirror of
https://github.com/frappe/books.git
synced 2025-01-22 22:58:28 +00:00
Financial Statements init
This commit is contained in:
parent
82e0129011
commit
8a67e6bf9a
@ -6,10 +6,8 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
route: ['report', 'general-ledger'],
|
route: ['report', 'general-ledger'],
|
||||||
params: {
|
params: {
|
||||||
filters: {
|
referenceType: form.doc.doctype,
|
||||||
referenceType: form.doc.doctype,
|
referenceName: form.doc.name
|
||||||
referenceName: form.doc.name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ const SetupWizard = require('../setup');
|
|||||||
const { getPDFForElectron } = require('frappejs/server/pdf');
|
const { getPDFForElectron } = require('frappejs/server/pdf');
|
||||||
const { getSettings, saveSettings } = require('./settings');
|
const { getSettings, saveSettings } = require('./settings');
|
||||||
const { postStart } = require('../server');
|
const { postStart } = require('../server');
|
||||||
|
const { slug } = require('frappejs/utils');
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ require.extensions['.html'] = function (module, filename) {
|
|||||||
|
|
||||||
if (!electronSettings.dbPath) {
|
if (!electronSettings.dbPath) {
|
||||||
const values = await runSetupWizard();
|
const values = await runSetupWizard();
|
||||||
const dbPath = path.join(values.file[0].path, frappe.slug(values.companyName) + '.db');
|
const dbPath = path.join(values.file[0].path, slug(values.companyName) + '.db');
|
||||||
const config = {
|
const config = {
|
||||||
directory: path.dirname(dbPath),
|
directory: path.dirname(dbPath),
|
||||||
dbPath: dbPath
|
dbPath: dbPath
|
||||||
@ -36,10 +37,10 @@ require.extensions['.html'] = function (module, filename) {
|
|||||||
models: require('../models')
|
models: require('../models')
|
||||||
});
|
});
|
||||||
|
|
||||||
// await postStart();
|
await postStart();
|
||||||
|
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
await saveSetupWizardValues(values);
|
await saveSetupWizardValues(setupWizardValues);
|
||||||
await bootstrapChartOfAccounts();
|
await bootstrapChartOfAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
<link href="../www/dist/css/style.css" rel="stylesheet">
|
<link href="../www/dist/css/style.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="./client.js"></script>
|
<script src="./index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
5
electron/index.js
Normal file
5
electron/index.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
global.rootRequire = function(name) {
|
||||||
|
return require(process.cwd() + '/' + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
require('./client');
|
@ -1,4 +1,5 @@
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const path = require('path');
|
||||||
const { writeFile } = require('frappejs/server/utils');
|
const { writeFile } = require('frappejs/server/utils');
|
||||||
|
|
||||||
const homedir = os.homedir();
|
const homedir = os.homedir();
|
||||||
|
2
main.js
2
main.js
@ -17,7 +17,7 @@ function createWindow () {
|
|||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadURL(url.format({
|
mainWindow.loadURL(url.format({
|
||||||
pathname: path.join(__dirname, 'electron/index.html'),
|
pathname: path.join(__dirname, 'electron', 'index.html'),
|
||||||
protocol: 'file:',
|
protocol: 'file:',
|
||||||
slashes: true
|
slashes: true
|
||||||
}))
|
}))
|
||||||
|
@ -3,6 +3,7 @@ module.exports = {
|
|||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"documentClass": require("./AccountDocument.js"),
|
"documentClass": require("./AccountDocument.js"),
|
||||||
"isSingle": 0,
|
"isSingle": 0,
|
||||||
|
"isTree": 1,
|
||||||
"keywordFields": [
|
"keywordFields": [
|
||||||
"name",
|
"name",
|
||||||
"rootType",
|
"rootType",
|
||||||
|
@ -49,7 +49,7 @@ module.exports = {
|
|||||||
fieldname: "againstAccount",
|
fieldname: "againstAccount",
|
||||||
label: "Against Account",
|
label: "Against Account",
|
||||||
fieldtype: "Text",
|
fieldtype: "Text",
|
||||||
required: 1
|
required: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "referenceType",
|
fieldname: "referenceType",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const Invoice = require('./InvoiceDocument');
|
const Invoice = require('./InvoiceDocument');
|
||||||
const frappe = require('frappejs');
|
const frappe = require('frappejs');
|
||||||
const LedgerPosting = require.main.require('./accounting/ledgerPosting');
|
const LedgerPosting = rootRequire('accounting/ledgerPosting');
|
||||||
|
|
||||||
module.exports = class InvoiceServer extends Invoice {
|
module.exports = class InvoiceServer extends Invoice {
|
||||||
getPosting() {
|
getPosting() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const BaseDocument = require('frappejs/model/document');
|
const BaseDocument = require('frappejs/model/document');
|
||||||
const frappe = require('frappejs');
|
const frappe = require('frappejs');
|
||||||
const LedgerPosting = require.main.require('./accounting/ledgerPosting');
|
const LedgerPosting = rootRequire('accounting/ledgerPosting');
|
||||||
|
|
||||||
module.exports = class PaymentServer extends BaseDocument {
|
module.exports = class PaymentServer extends BaseDocument {
|
||||||
getPosting() {
|
getPosting() {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"test": "mocha tests",
|
"test": "mocha tests",
|
||||||
"start": "nodemon server.js",
|
"start": "nodemon server.js",
|
||||||
"watch": "rollup -c --watch",
|
"watch": "rollup -c --watch",
|
||||||
"electron": "electron main.js",
|
"electron": "EIO_WS_ENGINE=ws electron main.js",
|
||||||
"electron-pack": "electron-packager . --overwrite",
|
"electron-pack": "electron-packager . --overwrite",
|
||||||
"postinstall": "electron-builder install-app-deps"
|
"postinstall": "electron-builder install-app-deps"
|
||||||
},
|
},
|
||||||
|
41
reports/financialStatements.js
Normal file
41
reports/financialStatements.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
const frappe = require('frappejs');
|
||||||
|
|
||||||
|
async function getData(rootType) {
|
||||||
|
const accounts = await getAccounts(rootType);
|
||||||
|
if (!accounts || accounts.length === 0) return;
|
||||||
|
|
||||||
|
const ledgerEntries = await frappe.db.getAll({
|
||||||
|
doctype: 'AccountingLedgerEntry',
|
||||||
|
fields: ['account', 'debit', 'credit'],
|
||||||
|
filters: {
|
||||||
|
account: ['in', accounts]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let data = {};
|
||||||
|
|
||||||
|
for (let entry of ledgerEntries) {
|
||||||
|
if (!data[entry.account]) {
|
||||||
|
data[entry.account] = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
data[entry.account] += entry.debit - entry.credit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getAccounts(rootType) {
|
||||||
|
return (await frappe.db.getAll({
|
||||||
|
doctype: 'Account',
|
||||||
|
fields: ['name'],
|
||||||
|
filters: {
|
||||||
|
rootType
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.map(d => d.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getData
|
||||||
|
}
|
@ -1,3 +1,7 @@
|
|||||||
|
global.rootRequire = function(name) {
|
||||||
|
return require(process.cwd() + '/' + name);
|
||||||
|
}
|
||||||
|
|
||||||
const server = require('frappejs/server');
|
const server = require('frappejs/server');
|
||||||
const frappe = require('frappejs');
|
const frappe = require('frappejs');
|
||||||
const GeneralLedger = require('../reports/generalLedger/GeneralLedger');
|
const GeneralLedger = require('../reports/generalLedger/GeneralLedger');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user