You've already forked openaccounting-web
mirror of
https://github.com/openaccounting/oa-web.git
synced 2025-12-09 09:01:24 +13:00
make easier to understand labels for debits and credits
This commit is contained in:
40
src/app/shared/debit-credit.pipe.ts
Normal file
40
src/app/shared/debit-credit.pipe.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { Account } from './account';
|
||||
|
||||
@Pipe({name: 'debitCredit'})
|
||||
export class DebitCreditPipe implements PipeTransform {
|
||||
debitNames: any;
|
||||
creditNames: any;
|
||||
|
||||
|
||||
constructor() {
|
||||
this.debitNames = {
|
||||
'Assets': 'Deposit',
|
||||
'Liabilities': 'Payment',
|
||||
'Equity': 'Decrease',
|
||||
'Income': 'Deduction',
|
||||
'Expenses': 'Expense'
|
||||
};
|
||||
|
||||
this.creditNames = {
|
||||
'Assets': 'Withdrawal',
|
||||
'Liabilities': 'Charge',
|
||||
'Equity': 'Increase',
|
||||
'Income': 'Income',
|
||||
'Expenses': 'Refund'
|
||||
};
|
||||
}
|
||||
|
||||
transform(account: Account, type: string): string {
|
||||
if(!account) {
|
||||
return type === 'credit' ? 'Credit' : 'Debit';
|
||||
}
|
||||
|
||||
let parent = account.fullName.split(':')[0];
|
||||
if(type === 'credit') {
|
||||
return this.creditNames[parent];
|
||||
} else {
|
||||
return this.debitNames[parent];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user