mirror of
https://github.com/frappe/books.git
synced 2025-01-22 14:48:25 +00:00
wip
This commit is contained in:
parent
20db1fd391
commit
1c1f72281e
@ -70,7 +70,7 @@ module.exports = {
|
||||
// section 2
|
||||
{ fields: ["accounts"]},
|
||||
// section 3
|
||||
{
|
||||
{
|
||||
columns: [
|
||||
{ fields: [ "referenceNumber"] },
|
||||
{ fields: [ "referenceDate"] }
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
**/
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
30
reports/ProfitAndLoss/ProfitAndLoss.js
Normal file
30
reports/ProfitAndLoss/ProfitAndLoss.js
Normal 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);
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 = {};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user