2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

Merge pull request #11 from piyushsinghania/enhancement/added-filter-reverted-entry

Added enhancement to filter out reverted invoices
This commit is contained in:
Ankit Singhaniya 2021-10-21 23:13:18 +05:30 committed by GitHub
commit a242979108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 1 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

@ -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,18 @@ const viewConfig = {
placeholder: 'To Date',
label: 'To Date',
fieldname: 'toDate'
},
{
fieldtype: 'Select',
options: [
{ label: 'Hide Audits', value: '1' },
{ label: 'Show Audits', value: '' }
],
size: 'small',
label: 'Audits',
placeholder: 'Show Audits',
default: 1,
fieldname: 'reverted'
}
],
method: 'general-ledger',

View File

@ -18,6 +18,7 @@
:df="df"
:value="filters[df.fieldname]"
@change="value => onFilterChange(df, value)"
:show-label="df.fieldtype === 'Check'"
/>
</div>
</div>