functional receiving, choosing and upload of transaction category
This commit is contained in:
parent
59efe7a650
commit
d17a686490
2 changed files with 27 additions and 2 deletions
|
@ -24,6 +24,20 @@
|
||||||
<span class="help-block">Enter the amount spent, such as 5.35 for £5.35.</span>
|
<span class="help-block">Enter the amount spent, such as 5.35 for £5.35.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-md-3 form-control-label" for="text-input">Category</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="input-group">
|
||||||
|
<select type="text" class="form-control" [(ngModel)]="categoryId">
|
||||||
|
<option value="" disabled>Choose a category</option>
|
||||||
|
<option *ngFor="let category of categoryIdList, let i=index" [ngValue]="category" >
|
||||||
|
{{ categoryNameList[i] }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<span class="help-block"><strong>Optional:</strong> Choose the relevant Category for the purchase.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Organisation Name</strong></label>
|
<label class="col-md-3 form-control-label" for="text-input"><strong>Organisation Name</strong></label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
|
|
|
@ -30,6 +30,7 @@ export class AddDataComponent implements OnInit {
|
||||||
organisationTown: string;
|
organisationTown: string;
|
||||||
organisationPostcode: string;
|
organisationPostcode: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
|
categoryId: number;
|
||||||
transactionAdditionType = 1;
|
transactionAdditionType = 1;
|
||||||
storeList = [];
|
storeList = [];
|
||||||
showAddStore = false;
|
showAddStore = false;
|
||||||
|
@ -37,8 +38,8 @@ export class AddDataComponent implements OnInit {
|
||||||
transactionFormInvalid = true;
|
transactionFormInvalid = true;
|
||||||
myDate: any;
|
myDate: any;
|
||||||
minDate: any;
|
minDate: any;
|
||||||
categoryIds: number[] = [];
|
categoryIdList: number[] = [];
|
||||||
categoryNames: string[] = [];
|
categoryNameList: string[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
|
@ -70,6 +71,7 @@ export class AddDataComponent implements OnInit {
|
||||||
result => {
|
result => {
|
||||||
this.categories = result;
|
this.categories = result;
|
||||||
console.log(this.categories);
|
console.log(this.categories);
|
||||||
|
this.setCategoryList(result.categories);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
console.log('Retrieval Error');
|
console.log('Retrieval Error');
|
||||||
|
@ -83,6 +85,11 @@ export class AddDataComponent implements OnInit {
|
||||||
this.accountType = localStorage.getItem('usertype');
|
this.accountType = localStorage.getItem('usertype');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setCategoryList(data: any) {
|
||||||
|
this.categoryIdList = Object.keys(data.ids).map(key => data.ids[key]);
|
||||||
|
this.categoryNameList = Object.keys(data.names).map(key => data.names[key]);
|
||||||
|
}
|
||||||
|
|
||||||
getMinDate() {
|
getMinDate() {
|
||||||
// gets the April 1st date of the current year
|
// gets the April 1st date of the current year
|
||||||
const aprilDate = moment().month(3).date(1);
|
const aprilDate = moment().month(3).date(1);
|
||||||
|
@ -182,6 +189,7 @@ export class AddDataComponent implements OnInit {
|
||||||
transaction_value : this.amount,
|
transaction_value : this.amount,
|
||||||
purchase_time : purchaseTime,
|
purchase_time : purchaseTime,
|
||||||
organisation_id : this.organisationId,
|
organisation_id : this.organisationId,
|
||||||
|
category : this.categoryId,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -190,6 +198,7 @@ export class AddDataComponent implements OnInit {
|
||||||
transaction_value : this.amount,
|
transaction_value : this.amount,
|
||||||
purchase_time : purchaseTime,
|
purchase_time : purchaseTime,
|
||||||
organisation_id : this.organisationId,
|
organisation_id : this.organisationId,
|
||||||
|
category : this.categoryId,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -201,6 +210,7 @@ export class AddDataComponent implements OnInit {
|
||||||
street_name : this.submitOrg.street_name,
|
street_name : this.submitOrg.street_name,
|
||||||
town : this.submitOrg.town,
|
town : this.submitOrg.town,
|
||||||
postcode : this.submitOrg.postcode,
|
postcode : this.submitOrg.postcode,
|
||||||
|
category : this.categoryId,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -251,6 +261,7 @@ export class AddDataComponent implements OnInit {
|
||||||
this.amount = null;
|
this.amount = null;
|
||||||
this.transactionFormInvalid = true;
|
this.transactionFormInvalid = true;
|
||||||
this.showAddStore = false;
|
this.showAddStore = false;
|
||||||
|
this.categoryId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmitPayroll() {
|
onSubmitPayroll() {
|
||||||
|
|
Reference in a new issue