got new transaction working

This commit is contained in:
Patrick Nagurny
2018-11-27 16:46:00 -05:00
parent 72eac48f42
commit 70a20b6611
4 changed files with 359 additions and 111 deletions

View File

@@ -1,28 +1,10 @@
<h1>New Transaction</h1>
<div class="section">
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<form [formGroup]="form" (ngSubmit)="onSubmit()" *ngIf="accountTree">
<ngb-accordion #acc="ngbAccordion" activeIds="toggle-1">
<ngb-panel id="toggle-1" [title]="getToggle1Title()">
<ng-template ngbPanelContent>
<!-- <input type="radio" class="btn btn-outline-primary mr-2" id="type-expense" value="Expense">
<input type="radio" class="btn btn-outline-primary mr-2" id="type-income" value="Income">
<input type="radio" class="btn btn-outline-primary mr-2" id="type-ob" value="Opening Balance">
<input type="radio" class="btn btn-outline-primary mr-2" id="type-other" value="Other"> -->
<div>
<!-- <button type="button" class="btn mr-2" (click)="setType('expense')" [ngClass]="{'btn-outline-primary': type !== 'expense', 'btn-primary': type === 'expense'}">
Expense
</button>
<button type="button" class="btn mr-2" (click)="setType('income')" [ngClass]="{'btn-outline-primary': type !== 'income', 'btn-primary': type === 'income'}">
Income
</button>
<button type="button" class="btn mr-2" (click)="setType('openingBalance')" [ngClass]="{'btn-outline-primary': type !== 'openingBalance', 'btn-primary': type === 'openingBalance'}">
Opening Balance
</button>
<button type="button" class="btn mr-2" (click)="setType('other')" [ngClass]="{'btn-outline-primary': type !== 'other', 'btn-primary': type === 'other'}">
Other
</button> -->
<div class="btn-group-toggle" ngbRadioGroup name="radioBasic" formControlName="type">
<label ngbButtonLabel class="btn-primary mr-2">
<input ngbButton type="radio" value="expense"> Expense
@@ -30,14 +12,13 @@
<label ngbButtonLabel class="btn-primary mr-2">
<input ngbButton type="radio" value="income"> Income
</label>
<label ngbButtonLabel class="btn-primary mr-2">
<label ngbButtonLabel class="btn-primary mr-2" *ngIf="openingBalances">
<input ngbButton type="radio" value="openingBalance"> Opening Balance
</label>
<label ngbButtonLabel class="btn-primary mr-2">
<input ngbButton type="radio" value="other"> Other
</label>
</div>
</div>
<div id="firstAccountPrimary" *ngIf="form.value?.type === 'expense'" class="mt-3">
<div class="btn-group-toggle" ngbRadioGroup name="radioBasic2" formControlName="firstAccountPrimary">
<label *ngFor="let account of expenseAccounts" ngbButtonLabel class="btn-primary mr-2">
@@ -78,9 +59,21 @@
</div>
</div>
</div>
<div id="firstAccountPrimary" *ngIf="form.value?.type === 'openingBalance'" class="mt-3">
<div id="firstAccountSelect" class="mt-3">
<div class="form-group">
<label for="firstAccountSecondary" class="col-sm-3 col-form-label">Choose Account</label>
<select class="form-control" id="account" formControlName="firstAccountSecondary">
<option *ngFor="let account of paymentAccountsAll" [value]="account.id">
{{account.label | slice:0:30}}
</option>
</select>
</div>
</div>
</div>
</ng-template>
</ngb-panel>
<ngb-panel id="toggle-2" [title]="getTitle()">
<ngb-panel id="toggle-2" [title]="getToggle2Title()" *ngIf="form.value?.type !== 'openingBalance'">
<ng-template ngbPanelContent>
<div id="secondAccountPrimary" *ngIf="form.value?.type === 'expense'" class="mt-3">
<div class="btn-group-toggle" ngbRadioGroup name="secondAccountPrimary" formControlName="secondAccountPrimary">
@@ -122,22 +115,12 @@
</div>
</div>
</div>
<div id="secondAccountSelect" *ngIf="form.value?.type === 'openingBalance'" class="mt-3">
<div class="form-group">
<label for="secondAccountSecondary" class="col-sm-3 col-form-label">Choose Account</label>
<select class="form-control" id="account" formControlName="secondAccountSecondary">
<option *ngFor="let account of paymentAccountsAll" [value]="account.id">
{{account.label | slice:0:30}}
</option>
</select>
</div>
</div>
</ng-template>
</ngb-panel>
<ngb-panel id="toggle-3" title="Amount">
<ng-template ngbPanelContent>
<div class="form-group">
<input type="number" class="form-control" id="amount" formControlName="amount">
<input #amount type="number" class="form-control" id="amount" formControlName="amount">
</div>
</ng-template>
</ngb-panel>
@@ -157,17 +140,47 @@
</ngb-panel>
<ngb-panel id="toggle-6" title="Advanced">
<ng-template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon
officia
aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon
tempor,
sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh
helvetica,
craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Leggings
occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them
accusamus
labore sustainable VHS.
<div class="container-fluid" formArrayName="splits">
<div class="row">
<div class="col-8">
<h3>Account</h3>
</div>
<div class="col-2">
<h3>Debit</h3>
</div>
<div class="col-2">
<h3>Credit</h3>
</div>
</div>
<div class="row" *ngFor="let split of form.get('splits').controls; let i=index" [formGroup]="split">
<div class="col-8">
<div class="form-group">
<select class="form-control" id="account" formControlName="accountId">
<option *ngFor="let account of selectAccounts" [value]="account.id">
{{account.fullName | slice:0:50}}
</option>
</select>
</div>
</div>
<div class="col-2">
<div class="form-group">
<input type="number" class="form-control" formControlName="debit" [ngClass]="{'positive': accountMap[split.value.accountId]?.debitBalance, 'negative': !accountMap[split.value.accountId]?.debitBalance}"/>
</div>
</div>
<div class="col-2">
<div class="form-group">
<input type="number" class="form-control" formControlName="credit" [ngClass]="{'positive': !accountMap[split.value.accountId]?.debitBalance, 'negative': accountMap[split.value.accountId]?.debitBalance}"/>
</div>
</div>
</div>
<div class="row">
<div class="col-8">
<p>
<a (click)="addSplit()">Add Split</a>
</p>
</div>
</div>
</div>
</ng-template>
</ngb-panel>
</ngb-accordion>