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.entries = [];
this.entryMap = {};
this.reverted = 0;
// To change balance while entering ledger entries
this.accountEntries = [];
}
@ -52,6 +53,7 @@ module.exports = class LedgerPosting {
referenceType: referenceType || this.reference.doctype,
referenceName: referenceName || this.reference.name,
description: this.description,
reverted: this.reverted,
debit: 0,
credit: 0
};
@ -70,11 +72,28 @@ module.exports = class LedgerPosting {
async postReverse() {
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;
for (let entry of this.entries) {
temp = entry.debit;
entry.debit = entry.credit;
entry.credit = temp;
entry.reverted = 1;
}
for (let entry of this.accountEntries) {
entry.balanceChange = -1 * entry.balanceChange;

View File

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

View File

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

View File

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

View File

@ -56,6 +56,17 @@ const viewConfig = {
placeholder: 'To Date',
label: 'To Date',
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',

View File

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