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:
commit
a242979108
@ -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;
|
||||
|
@ -60,6 +60,12 @@ module.exports = {
|
||||
fieldname: 'balance',
|
||||
label: 'Balance',
|
||||
fieldtype: 'Currency'
|
||||
},
|
||||
{
|
||||
fieldname: 'reverted',
|
||||
label: 'Reverted',
|
||||
fieldtype: 'Check',
|
||||
default: 0
|
||||
}
|
||||
],
|
||||
quickEditFields: [
|
||||
|
@ -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
|
||||
});
|
||||
|
@ -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',
|
||||
|
@ -18,6 +18,7 @@
|
||||
:df="df"
|
||||
:value="filters[df.fieldname]"
|
||||
@change="value => onFilterChange(df, value)"
|
||||
:show-label="df.fieldtype === 'Check'"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user