2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 14:48:25 +00:00
This commit is contained in:
Faris Ansari 2018-04-18 14:32:05 +05:30
parent 20db1fd391
commit 1c1f72281e
8 changed files with 60 additions and 25 deletions

View File

@ -70,7 +70,7 @@ module.exports = {
// section 2
{ fields: ["accounts"]},
// section 3
{
{
columns: [
{ fields: [ "referenceNumber"] },
{ fields: [ "referenceDate"] }

View File

@ -1,10 +1,10 @@
const BaseDocument = require('frappejs/model/document');
const JournalEntry = require('./JournalEntry');
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 JournalEntryServer extends BaseDocument {
/**
getPosting() {
let entries = new LedgerPosting({reference: this, party: this.party});
entries.debit(this.paymentAccount, this.amount);
@ -24,6 +24,6 @@ module.exports = class PaymentServer extends BaseDocument {
async afterRevert() {
await this.getPosting().postReverse();
}
**/
}

View File

@ -1,8 +1,10 @@
const deepmerge = require('deepmerge');
const Invoice = require('../Invoice/Invoice');
const Quotation = Invoice;
Quotation.name = "Quotation";
Quotation.label = "Quotation";
Quotation.settings = "QuotationSettings";
const Quotation = deepmerge(Invoice, {
name: "Quotation",
label: "Quotation",
settings: "QuotationSettings"
});
module.exports = Quotation;

View File

@ -1,8 +1,11 @@
const deepmerge = require('deepmerge');
const InvoiceSettings = require('../InvoiceSettings/InvoiceSettings');
const QuotationSettings = InvoiceSettings;
QuotationSettings.name = "QuotationSettings";
QuotationSettings.label = "Quotation Settings";
QuotationSettings.fields.find((field)=>{
if (field.fieldname == "numberSeries") field.default = "QTN";
});
const QuotationSettings = deepmerge(InvoiceSettings, {
"name": "QuotationSettings",
"label": "Quotation Settings",
"fields": {
"default": "INV"
}
})
module.exports = QuotationSettings;

View File

@ -0,0 +1,30 @@
const frappe = require('frappejs');
const { getData } = require('../financialStatements');
class ProfitAndLoss {
async run(params) {
const filters = {};
if (params.account) filters.account = params.account;
if (params.party) filters.party = params.party;
if (params.referenceType) filters.referenceType = params.referenceType;
if (params.referenceName) filters.referenceName = params.referenceName;
if (params.fromDate) filters.date = ['>=', params.fromDate];
if (params.toDate) filters.date = ['<=', params.toDate];
let income = await getData({
rootType: 'Income',
balanceMustBe: 'Credit'
});
let expense = await getData({
rootType: 'Expense',
balanceMustBe: 'Credit'
});
return data;
}
}
module.exports = function execute(params) {
return new ProfitAndLoss().run(params);
}

View File

@ -1,8 +1,8 @@
const frappe = require('frappejs');
async function getData(rootType) {
async function getData({ rootType, balanceMustBe }) {
const accounts = await getAccounts(rootType);
if (!accounts || accounts.length === 0) return;
if (!accounts || accounts.length === 0) return [];
const ledgerEntries = await frappe.db.getAll({
doctype: 'AccountingLedgerEntry',
@ -38,4 +38,4 @@ async function getAccounts(rootType) {
module.exports = {
getData
}
}

View File

@ -1,9 +1,5 @@
const frappe = require('frappejs');
module.exports = function execute(params) {
return new GeneralLedger().run(params);
}
class GeneralLedger {
async run(params) {
const filters = {};
@ -22,4 +18,8 @@ class GeneralLedger {
return data;
}
}
}
module.exports = function execute(params) {
return new GeneralLedger().run(params);
}

View File

@ -23,7 +23,7 @@ module.exports = {
// set server-side modules
frappe.models.Invoice.documentClass = require('../models/doctype/Invoice/InvoiceServer.js');
frappe.models.Payment.documentClass = require('../models/doctype/Payment/PaymentServer.js');
frappe.models.JournalEntry.documentClass = require('../models/doctype/JournalEntry/JournalEntryServer.js');
// frappe.models.JournalEntry.documentClass = require('../models/doctype/JournalEntry/JournalEntryServer.js');
frappe.metaCache = {};