2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 14:48:25 +00:00

Financial Statements init

This commit is contained in:
Faris Ansari 2018-04-18 12:17:00 +05:30
parent 82e0129011
commit 8a67e6bf9a
13 changed files with 64 additions and 13 deletions

View File

@ -6,10 +6,8 @@ module.exports = {
return {
route: ['report', 'general-ledger'],
params: {
filters: {
referenceType: form.doc.doctype,
referenceName: form.doc.name
}
referenceType: form.doc.doctype,
referenceName: form.doc.name
}
};
}

View File

@ -6,6 +6,7 @@ const SetupWizard = require('../setup');
const { getPDFForElectron } = require('frappejs/server/pdf');
const { getSettings, saveSettings } = require('./settings');
const { postStart } = require('../server');
const { slug } = require('frappejs/utils');
const fs = require('fs');
@ -19,7 +20,7 @@ require.extensions['.html'] = function (module, filename) {
if (!electronSettings.dbPath) {
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 = {
directory: path.dirname(dbPath),
dbPath: dbPath
@ -36,10 +37,10 @@ require.extensions['.html'] = function (module, filename) {
models: require('../models')
});
// await postStart();
await postStart();
if (firstRun) {
await saveSetupWizardValues(values);
await saveSetupWizardValues(setupWizardValues);
await bootstrapChartOfAccounts();
}

View File

@ -7,6 +7,6 @@
<link href="../www/dist/css/style.css" rel="stylesheet">
</head>
<body>
<script src="./client.js"></script>
<script src="./index.js"></script>
</body>
</html>

5
electron/index.js Normal file
View File

@ -0,0 +1,5 @@
global.rootRequire = function(name) {
return require(process.cwd() + '/' + name);
}
require('./client');

View File

@ -1,4 +1,5 @@
const os = require('os');
const path = require('path');
const { writeFile } = require('frappejs/server/utils');
const homedir = os.homedir();

View File

@ -17,7 +17,7 @@ function createWindow () {
// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'electron/index.html'),
pathname: path.join(__dirname, 'electron', 'index.html'),
protocol: 'file:',
slashes: true
}))

View File

@ -3,6 +3,7 @@ module.exports = {
"doctype": "DocType",
"documentClass": require("./AccountDocument.js"),
"isSingle": 0,
"isTree": 1,
"keywordFields": [
"name",
"rootType",

View File

@ -49,7 +49,7 @@ module.exports = {
fieldname: "againstAccount",
label: "Against Account",
fieldtype: "Text",
required: 1
required: 0
},
{
fieldname: "referenceType",

View File

@ -1,6 +1,6 @@
const Invoice = require('./InvoiceDocument');
const frappe = require('frappejs');
const LedgerPosting = require.main.require('./accounting/ledgerPosting');
const LedgerPosting = rootRequire('accounting/ledgerPosting');
module.exports = class InvoiceServer extends Invoice {
getPosting() {

View File

@ -1,6 +1,6 @@
const BaseDocument = require('frappejs/model/document');
const frappe = require('frappejs');
const LedgerPosting = require.main.require('./accounting/ledgerPosting');
const LedgerPosting = rootRequire('accounting/ledgerPosting');
module.exports = class PaymentServer extends BaseDocument {
getPosting() {

View File

@ -16,7 +16,7 @@
"test": "mocha tests",
"start": "nodemon server.js",
"watch": "rollup -c --watch",
"electron": "electron main.js",
"electron": "EIO_WS_ENGINE=ws electron main.js",
"electron-pack": "electron-packager . --overwrite",
"postinstall": "electron-builder install-app-deps"
},

View 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
}

View File

@ -1,3 +1,7 @@
global.rootRequire = function(name) {
return require(process.cwd() + '/' + name);
}
const server = require('frappejs/server');
const frappe = require('frappejs');
const GeneralLedger = require('../reports/generalLedger/GeneralLedger');