mirror of
https://github.com/frappe/books.git
synced 2025-02-02 12:08:27 +00:00
wip
This commit is contained in:
parent
20db1fd391
commit
1c1f72281e
@ -70,7 +70,7 @@ module.exports = {
|
|||||||
// section 2
|
// section 2
|
||||||
{ fields: ["accounts"]},
|
{ fields: ["accounts"]},
|
||||||
// section 3
|
// section 3
|
||||||
{
|
{
|
||||||
columns: [
|
columns: [
|
||||||
{ fields: [ "referenceNumber"] },
|
{ fields: [ "referenceNumber"] },
|
||||||
{ fields: [ "referenceDate"] }
|
{ fields: [ "referenceDate"] }
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const BaseDocument = require('frappejs/model/document');
|
const JournalEntry = require('./JournalEntry');
|
||||||
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 JournalEntryServer extends BaseDocument {
|
||||||
/**
|
/**
|
||||||
|
|
||||||
getPosting() {
|
getPosting() {
|
||||||
let entries = new LedgerPosting({reference: this, party: this.party});
|
let entries = new LedgerPosting({reference: this, party: this.party});
|
||||||
entries.debit(this.paymentAccount, this.amount);
|
entries.debit(this.paymentAccount, this.amount);
|
||||||
@ -24,6 +24,6 @@ module.exports = class PaymentServer extends BaseDocument {
|
|||||||
async afterRevert() {
|
async afterRevert() {
|
||||||
await this.getPosting().postReverse();
|
await this.getPosting().postReverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
**/
|
**/
|
||||||
}
|
}
|
@ -1,8 +1,10 @@
|
|||||||
|
const deepmerge = require('deepmerge');
|
||||||
const Invoice = require('../Invoice/Invoice');
|
const Invoice = require('../Invoice/Invoice');
|
||||||
const Quotation = Invoice;
|
|
||||||
|
|
||||||
Quotation.name = "Quotation";
|
const Quotation = deepmerge(Invoice, {
|
||||||
Quotation.label = "Quotation";
|
name: "Quotation",
|
||||||
Quotation.settings = "QuotationSettings";
|
label: "Quotation",
|
||||||
|
settings: "QuotationSettings"
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = Quotation;
|
module.exports = Quotation;
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
const deepmerge = require('deepmerge');
|
||||||
const InvoiceSettings = require('../InvoiceSettings/InvoiceSettings');
|
const InvoiceSettings = require('../InvoiceSettings/InvoiceSettings');
|
||||||
const QuotationSettings = InvoiceSettings;
|
const QuotationSettings = deepmerge(InvoiceSettings, {
|
||||||
QuotationSettings.name = "QuotationSettings";
|
"name": "QuotationSettings",
|
||||||
QuotationSettings.label = "Quotation Settings";
|
"label": "Quotation Settings",
|
||||||
QuotationSettings.fields.find((field)=>{
|
"fields": {
|
||||||
if (field.fieldname == "numberSeries") field.default = "QTN";
|
"default": "INV"
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = QuotationSettings;
|
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');
|
const frappe = require('frappejs');
|
||||||
|
|
||||||
async function getData(rootType) {
|
async function getData({ rootType, balanceMustBe }) {
|
||||||
const accounts = await getAccounts(rootType);
|
const accounts = await getAccounts(rootType);
|
||||||
if (!accounts || accounts.length === 0) return;
|
if (!accounts || accounts.length === 0) return [];
|
||||||
|
|
||||||
const ledgerEntries = await frappe.db.getAll({
|
const ledgerEntries = await frappe.db.getAll({
|
||||||
doctype: 'AccountingLedgerEntry',
|
doctype: 'AccountingLedgerEntry',
|
||||||
@ -38,4 +38,4 @@ async function getAccounts(rootType) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getData
|
getData
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
const frappe = require('frappejs');
|
const frappe = require('frappejs');
|
||||||
|
|
||||||
module.exports = function execute(params) {
|
|
||||||
return new GeneralLedger().run(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
class GeneralLedger {
|
class GeneralLedger {
|
||||||
async run(params) {
|
async run(params) {
|
||||||
const filters = {};
|
const filters = {};
|
||||||
@ -22,4 +18,8 @@ class GeneralLedger {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = function execute(params) {
|
||||||
|
return new GeneralLedger().run(params);
|
||||||
|
}
|
||||||
|
@ -23,7 +23,7 @@ module.exports = {
|
|||||||
// set server-side modules
|
// set server-side modules
|
||||||
frappe.models.Invoice.documentClass = require('../models/doctype/Invoice/InvoiceServer.js');
|
frappe.models.Invoice.documentClass = require('../models/doctype/Invoice/InvoiceServer.js');
|
||||||
frappe.models.Payment.documentClass = require('../models/doctype/Payment/PaymentServer.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 = {};
|
frappe.metaCache = {};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user