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:
commit
eb0d1a770b
@ -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: [
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,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',
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user