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:
parent
82e0129011
commit
8a67e6bf9a
@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
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 path = require('path');
|
||||
const { writeFile } = require('frappejs/server/utils');
|
||||
|
||||
const homedir = os.homedir();
|
||||
|
2
main.js
2
main.js
@ -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
|
||||
}))
|
||||
|
@ -3,6 +3,7 @@ module.exports = {
|
||||
"doctype": "DocType",
|
||||
"documentClass": require("./AccountDocument.js"),
|
||||
"isSingle": 0,
|
||||
"isTree": 1,
|
||||
"keywordFields": [
|
||||
"name",
|
||||
"rootType",
|
||||
|
@ -49,7 +49,7 @@ module.exports = {
|
||||
fieldname: "againstAccount",
|
||||
label: "Against Account",
|
||||
fieldtype: "Text",
|
||||
required: 1
|
||||
required: 0
|
||||
},
|
||||
{
|
||||
fieldname: "referenceType",
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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"
|
||||
},
|
||||
|
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 frappe = require('frappejs');
|
||||
const GeneralLedger = require('../reports/generalLedger/GeneralLedger');
|
||||
|
Loading…
x
Reference in New Issue
Block a user