@@ -429,6 +429,10 @@ export class TransactionsTabComponent implements OnInit {
429429 return this . isReAmortize ( transactionType ) || this . isReAge ( transactionType ) ;
430430 }
431431
432+ isBuyDownFee ( transactionType : LoanTransactionType ) : boolean {
433+ return transactionType . buyDownFee || transactionType . code === 'loanTransactionType.buyDownFee' ;
434+ }
435+
432436 viewJournalEntry ( transactionType : LoanTransactionType ) : boolean {
433437 return ! ( this . isReAmortize ( transactionType ) || this . isReAge ( transactionType ) ) ;
434438 }
@@ -446,6 +450,70 @@ export class TransactionsTabComponent implements OnInit {
446450 return true ;
447451 }
448452
453+ buyDownFeeAdjustmentTransaction ( transaction : LoanTransaction ) {
454+ const accountId = `${ this . loanId } ` ;
455+ this . loansService
456+ . getLoanTransactionActionTemplate ( accountId , 'buyDownFeeAdjustment' , `${ transaction . id } ` )
457+ . subscribe ( ( response : any ) => {
458+ const transactionDate = response . date || transaction . date ;
459+ if ( response . amount == 0 ) {
460+ this . displayAlertMessage ( 'Buy Down Fee amount adjusted already adjusted' , transaction . amount ) ;
461+ } else {
462+ const transactionAmount = response . amount || transaction . amount ;
463+ const formfields : FormfieldBase [ ] = [
464+ new DatepickerBase ( {
465+ controlName : 'transactionDate' ,
466+ label : 'Date' ,
467+ value : this . dateUtils . parseDate ( transactionDate ) ,
468+ type : 'datetime-local' ,
469+ required : true ,
470+ minDate : this . dateUtils . parseDate ( transaction . date ) ,
471+ order : 1
472+ } ) ,
473+ new InputBase ( {
474+ controlName : 'amount' ,
475+ label : 'Amount' ,
476+ value : transactionAmount ,
477+ type : 'number' ,
478+ required : true ,
479+ max : transactionAmount ,
480+ min : 0.001 ,
481+ order : 2
482+ } )
483+
484+ ] ;
485+ const data = {
486+ title : `Adjustment ${ transaction . type . value } Transaction` ,
487+ layout : { addButtonText : 'Adjustment' } ,
488+ formfields : formfields
489+ } ;
490+ const chargebackDialogRef = this . dialog . open ( FormDialogComponent , { data } ) ;
491+ chargebackDialogRef . afterClosed ( ) . subscribe ( ( response : { data : any } ) => {
492+ if ( response . data ) {
493+ const dateFormat = this . settingsService . dateFormat ;
494+
495+ if ( response . data . value . amount <= transactionAmount ) {
496+ const locale = this . settingsService . language . code ;
497+ const payload = {
498+ transactionDate : this . dateUtils . formatDate ( response . data . value . transactionDate , dateFormat ) ,
499+ transactionAmount : response . data . value . amount ,
500+ locale,
501+ dateFormat
502+ } ;
503+ this . loansService
504+ . executeLoansAccountTransactionsCommand ( accountId , 'buyDownFeeAdjustment' , payload , transaction . id )
505+ . subscribe ( ( ) => {
506+ this . reload ( ) ;
507+ } ) ;
508+ } else {
509+ this . displayAlertMessage ( 'Buy Down Fee Adjustment amount must be lower or equal to' , transactionAmount ) ;
510+ }
511+ }
512+ } ) ;
513+ }
514+ } ) ;
515+ }
516+
449517 capitalizedIncomeAdjustmentTransaction ( transaction : LoanTransaction ) {
450518 const accountId = `${ this . loanId } ` ;
451519 this . loansService
0 commit comments