added updating transaction
This commit is contained in:
parent
49bd7d2e0c
commit
2188c1272f
7 changed files with 61 additions and 20 deletions
|
@ -114,6 +114,25 @@
|
|||
<span class="help-block"><strong>Optional:</strong> Choose the Budget Type for the majority of the purchase.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="input-group">
|
||||
<span class="col-12"><strong>WARNING: Clicking "Delete" will completely remove the Recurring Transaction.</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div [ngSwitch]="transactionFormStatus">
|
||||
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
|
||||
Edit Succeeded.
|
||||
</div>
|
||||
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
||||
{{transactionFormStatusError}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer d-flex justify-content-between">
|
||||
<button type="submit" (click)="deleteRecurringTransaction()" class="btn btn-sm btn-danger"><i class="fa fa-times"></i> Delete</button>
|
||||
<button type="submit" (click)="editRecurringTransaction()" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Edit</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
|
|
@ -25,6 +25,8 @@ export class TransactionLogComponent implements OnInit {
|
|||
categoryIdList: number[] = [];
|
||||
categoryList: any;
|
||||
categoryNameList: string[] = [];
|
||||
transactionFormStatus: string;
|
||||
transactionFormStatusError = 'Error received, please try again.';
|
||||
|
||||
public paginateConfig: PaginationInstance = {
|
||||
id: 'transpaginate',
|
||||
|
@ -89,9 +91,7 @@ export class TransactionLogComponent implements OnInit {
|
|||
|
||||
recurringTransactionDetails(clicked, template: TemplateRef<any>) {
|
||||
this.clickedRecur = clicked;
|
||||
console.log(this.clickedRecur);
|
||||
this.updatedTime = moment(this.clickedRecur.last_updated).format('YYYY-MM-DD[T]HH:mm');
|
||||
this.startTime = moment(this.clickedRecur.start_time).format('YYYY-MM-DD[T]HH:mm');
|
||||
this.updatedTime = moment(this.clickedRecur.display_time, 'llll').format('YYYY-MM-DD[T]HH:mm');
|
||||
this.openModal(template);
|
||||
}
|
||||
|
||||
|
@ -100,34 +100,44 @@ export class TransactionLogComponent implements OnInit {
|
|||
}
|
||||
|
||||
editRecurringTransaction() {
|
||||
let updatedDateSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
||||
let startTimeSubmit = moment(this.startTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
||||
let updatedTimeSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
||||
this.clickedRecur.display_time = moment(this.updatedTime).format('llll');
|
||||
let myParams = {
|
||||
category: this.clickedRecur.category,
|
||||
category: 111,
|
||||
essential: this.clickedRecur.essential,
|
||||
id: this.clickedRecur.id,
|
||||
last_updated: this.updatedDate,
|
||||
recurring_period: this.updatedDateSubmit,
|
||||
apply_time: updatedTimeSubmit,
|
||||
recurring_period: this.clickedRecur.recurring_period,
|
||||
seller: this.clickedRecur.seller,
|
||||
start_time: this.startTimeSubmit,
|
||||
value: this.clickedRecur.value,
|
||||
};
|
||||
/******************************/
|
||||
|
||||
this.api
|
||||
.upload(myParams)
|
||||
.recurUpdate(myParams)
|
||||
.subscribe(
|
||||
result => {
|
||||
if ( result.success === true ) {
|
||||
console.log('Successful Upload');
|
||||
this.transactionFormStatus = 'success';
|
||||
this.resetForm();
|
||||
} else {
|
||||
console.log('Upload Error');
|
||||
this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message);
|
||||
this.transactionFormStatus = 'send_failed';
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.log('Upload Error');
|
||||
console.log(error);
|
||||
try {
|
||||
console.log(error.error);
|
||||
this.transactionFormStatusError = '"' + error.error.error + '" Error, ' + error.error.message;
|
||||
} catch (e) {
|
||||
this.transactionFormStatusError = 'There was a server error, please try again later.';
|
||||
}
|
||||
this.transactionFormStatus = 'send_failed';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
deleteRecurringTransaction() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -158,6 +158,16 @@ export class ApiService {
|
|||
);
|
||||
}
|
||||
|
||||
// Uploads a transaction
|
||||
|
||||
public recurUpdate(data) {
|
||||
data.session_key = this.sessionKey;
|
||||
return this.http.post<any>(
|
||||
this.apiUrl + '/recurring-transactions',
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
// gets payroll list for log
|
||||
|
||||
public payrollList(data) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<td (click)="recurClick()">{{recur.seller}}</td>
|
||||
<td (click)="recurClick()">{{categories[recur.category] || 'Uncategorised'}}</td>
|
||||
<td (click)="recurClick()">{{recur.essential}}</td>
|
||||
<td (click)="recurClick()">{{updatedDate}}</td>
|
||||
<td (click)="recurClick()">{{recur.essential == 1 ? 'true' : 'false'}}</td>
|
||||
<td (click)="recurClick()">{{recur.display_time}}</td>
|
||||
<td (click)="recurClick()">{{recur.recurring_period}}</td>
|
||||
<td (click)="recurClick()">{{recur.value}}</td>
|
||||
|
|
|
@ -10,6 +10,7 @@ interface RecurData {
|
|||
seller: string;
|
||||
start_time: string;
|
||||
value: number;
|
||||
display_time: any;
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
@ -25,9 +26,9 @@ export class RecurResultComponent {
|
|||
|
||||
ngOnInit(): void {
|
||||
if (this.recur.last_updated) {
|
||||
this.updatedDate = moment(this.recur.last_updated).format('llll');
|
||||
this.recur.display_time = moment(this.recur.last_updated).format('llll');
|
||||
} else {
|
||||
this.updatedDate = moment(this.recur.start_time).format('llll');
|
||||
this.recur.display_time = moment(this.recur.start_time).format('llll');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<th>Seller</th>
|
||||
<th>Category</th>
|
||||
<th>Essential</th>
|
||||
<th>Last Updated</th>
|
||||
<th>Last Applied</th>
|
||||
<th>Recurring Period</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
|
|
|
@ -10,6 +10,7 @@ interface RecurData {
|
|||
seller: string;
|
||||
start_time: string;
|
||||
value: number;
|
||||
display_time: any;
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
|
Reference in a new issue