2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +00:00

Merge pull request #222 from ankitsinghaniyaz/master

Resolve ledger related issues
This commit is contained in:
Alan 2021-10-28 15:22:08 +05:30 committed by GitHub
commit eb0d1a770b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 5 deletions

View File

@ -9,6 +9,7 @@ module.exports = class LedgerPosting {
this.description = description; this.description = description;
this.entries = []; this.entries = [];
this.entryMap = {}; this.entryMap = {};
this.reverted = 0;
// To change balance while entering ledger entries // To change balance while entering ledger entries
this.accountEntries = []; this.accountEntries = [];
} }
@ -52,6 +53,7 @@ module.exports = class LedgerPosting {
referenceType: referenceType || this.reference.doctype, referenceType: referenceType || this.reference.doctype,
referenceName: referenceName || this.reference.name, referenceName: referenceName || this.reference.name,
description: this.description, description: this.description,
reverted: this.reverted,
debit: 0, debit: 0,
credit: 0 credit: 0
}; };
@ -70,11 +72,28 @@ module.exports = class LedgerPosting {
async postReverse() { async postReverse() {
this.validateEntries(); this.validateEntries();
let data = await frappe.db.getAll({
doctype: 'AccountingLedgerEntry',
fields: ['name'],
filters: {
referenceName: this.reference.name,
reverted: 0
}
});
for (let entry of data) {
let entryDoc = await frappe.getDoc('AccountingLedgerEntry', entry.name);
entryDoc.reverted = 1;
await entryDoc.update();
}
let temp; let temp;
for (let entry of this.entries) { for (let entry of this.entries) {
temp = entry.debit; temp = entry.debit;
entry.debit = entry.credit; entry.debit = entry.credit;
entry.credit = temp; entry.credit = temp;
entry.reverted = 1;
} }
for (let entry of this.accountEntries) { for (let entry of this.accountEntries) {
entry.balanceChange = -1 * entry.balanceChange; entry.balanceChange = -1 * entry.balanceChange;

View File

@ -60,6 +60,12 @@ module.exports = {
fieldname: 'balance', fieldname: 'balance',
label: 'Balance', label: 'Balance',
fieldtype: 'Currency' fieldtype: 'Currency'
},
{
fieldname: 'reverted',
label: 'Reverted',
fieldtype: 'Check',
default: 0
} }
], ],
quickEditFields: [ quickEditFields: [

View File

@ -15,9 +15,7 @@ module.exports = class PaymentServer extends BaseDocument {
async getPosting() { async getPosting() {
let entries = new LedgerPosting({ reference: this, party: this.party }); let entries = new LedgerPosting({ reference: this, party: this.party });
await entries.debit(this.paymentAccount, this.amount); await entries.debit(this.paymentAccount, this.amount);
for (let row of this.for) { await entries.credit(this.account, this.amount);
await entries.credit(this.account, row.amount);
}
return entries; return entries;
} }

View File

@ -7,6 +7,7 @@ class GeneralLedger {
if (params.party) filters.party = params.party; if (params.party) filters.party = params.party;
if (params.referenceType) filters.referenceType = params.referenceType; if (params.referenceType) filters.referenceType = params.referenceType;
if (params.referenceName) filters.referenceName = params.referenceName; if (params.referenceName) filters.referenceName = params.referenceName;
if (params.reverted) filters.reverted = params.reverted;
if (params.toDate || params.fromDate) { if (params.toDate || params.fromDate) {
filters.date = []; filters.date = [];
if (params.toDate) filters.date.push('<=', params.toDate); if (params.toDate) filters.date.push('<=', params.toDate);
@ -22,7 +23,8 @@ class GeneralLedger {
'referenceType', 'referenceType',
'referenceName', 'referenceName',
'debit', 'debit',
'credit' 'credit',
'reverted'
], ],
filters: filters filters: filters
}); });

View File

@ -56,6 +56,17 @@ const viewConfig = {
placeholder: 'To Date', placeholder: 'To Date',
label: 'To Date', label: 'To Date',
fieldname: 'toDate' fieldname: 'toDate'
},
{
fieldtype: 'Select',
options: [
{ label: 'Show Reverted', value: '' },
{ label: 'Hide Reverted', value: '0' }
],
size: 'small',
default: '0',
label: 'Reverted',
fieldname: 'reverted'
} }
], ],
method: 'general-ledger', method: 'general-ledger',

View File

@ -8,7 +8,7 @@
</PageHeader> </PageHeader>
<div class="flex px-8 mt-2 text-base" v-if="report.filterFields"> <div class="flex px-8 mt-2 text-base" v-if="report.filterFields">
<div <div
class="w-32 ml-3 first:ml-0" class="w-40 ml-2 first:ml-0"
v-for="df in report.filterFields" v-for="df in report.filterFields"
:key="df.fieldname" :key="df.fieldname"
> >
@ -18,6 +18,7 @@
:df="df" :df="df"
:value="filters[df.fieldname]" :value="filters[df.fieldname]"
@change="value => onFilterChange(df, value)" @change="value => onFilterChange(df, value)"
:show-label="df.fieldtype === 'Check'"
/> />
</div> </div>
</div> </div>