Settle Options are now stored in the Database and can be updated
This commit is contained in:
@ -106,6 +106,11 @@ const routes: Routes = [
|
||||
loadChildren: () =>
|
||||
import('./section-printers/section-printers.module').then((mod) => mod.SectionPrintersModule),
|
||||
},
|
||||
{
|
||||
path: 'settle-options',
|
||||
loadChildren: () =>
|
||||
import('./settle-option/settle-options.module').then((mod) => mod.SettleOptionsModule),
|
||||
},
|
||||
{
|
||||
path: 'tables',
|
||||
loadChildren: () => import('./tables/tables.module').then((mod) => mod.TableModule),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export interface ReceivePaymentItem {
|
||||
id: number;
|
||||
name: string;
|
||||
import { SettleOption } from './settle-option';
|
||||
|
||||
export interface ReceivePaymentItem extends SettleOption {
|
||||
amount: number;
|
||||
}
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
import { ReceivePaymentItem } from './receive-payment-item';
|
||||
|
||||
export interface ReceivePaymentList {
|
||||
[billType: string]: ReceivePaymentItem[];
|
||||
}
|
||||
5
bookie/src/app/core/reporting-level.ts
Normal file
5
bookie/src/app/core/reporting-level.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export enum ReportingLevel {
|
||||
Skip = 0,
|
||||
Aggregate = 1,
|
||||
Detailed = 2,
|
||||
}
|
||||
22
bookie/src/app/core/settle-option.ts
Normal file
22
bookie/src/app/core/settle-option.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { VoucherType } from '../sales/bills/voucher-type';
|
||||
|
||||
import { ReportingLevel } from './reporting-level';
|
||||
|
||||
export class SettleOption {
|
||||
id: number;
|
||||
name: string;
|
||||
voucherType: VoucherType;
|
||||
reportingLevel: ReportingLevel;
|
||||
hasReason: boolean;
|
||||
isFixture: boolean;
|
||||
|
||||
public constructor(init?: Partial<SettleOption>) {
|
||||
this.id = 0;
|
||||
this.name = '';
|
||||
this.voucherType = VoucherType.Kot;
|
||||
this.reportingLevel = ReportingLevel.Skip;
|
||||
this.hasReason = false;
|
||||
this.isFixture = false;
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
@ -232,6 +232,15 @@
|
||||
>
|
||||
<h3 class="item-name">Header / Footer</h3>
|
||||
</mat-card>
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
*ngIf="auth.allowed('owner')"
|
||||
[routerLink]="['/', 'settle-options']"
|
||||
>
|
||||
<h3 class="item-name">Settle Options</h3>
|
||||
</mat-card>
|
||||
</div>
|
||||
<footer class="footer">
|
||||
<p>Backend: v{{ auth.user?.ver }} / Frontend: v{{ version }} on {{ auth.device.name }}</p>
|
||||
|
||||
@ -29,5 +29,5 @@
|
||||
</div>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||
<button mat-button [mat-dialog-close]="selected">Done</button>
|
||||
<button mat-button [mat-dialog-close]="selectedVal">Done</button>
|
||||
</mat-dialog-actions>
|
||||
|
||||
@ -9,25 +9,20 @@ import { VoucherType } from '../bills/voucher-type';
|
||||
styleUrls: ['./bill-type.component.css'],
|
||||
})
|
||||
export class BillTypeComponent {
|
||||
selected: string;
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<BillTypeComponent>) {
|
||||
this.selected = '';
|
||||
}
|
||||
selected?: string;
|
||||
selectedVal?: VoucherType;
|
||||
constructor(public dialogRef: MatDialogRef<BillTypeComponent>) {}
|
||||
|
||||
select(voucherType: string) {
|
||||
this.selected = voucherType;
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
if (this.selected === 'REGULAR_BILL') {
|
||||
this.dialogRef.close(VoucherType.Bill);
|
||||
} else if (this.selected === 'STAFF') {
|
||||
this.dialogRef.close(VoucherType.Staff);
|
||||
} else if (this.selected === 'NO_CHARGE') {
|
||||
this.dialogRef.close(VoucherType.NoCharge);
|
||||
} else {
|
||||
this.dialogRef.close();
|
||||
this.selectedVal = VoucherType.Bill;
|
||||
}
|
||||
if (this.selected === 'STAFF') {
|
||||
this.selectedVal = VoucherType.Staff;
|
||||
}
|
||||
if (this.selected === 'NO_CHARGE') {
|
||||
this.selectedVal = VoucherType.NoCharge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import { Observable } from 'rxjs/internal/Observable';
|
||||
import { BillViewItem } from '../core/bill-view-item';
|
||||
import { ModifierCategory } from '../core/modifier-category';
|
||||
import { Product } from '../core/product';
|
||||
import { ReceivePaymentItem } from '../core/receive-payment-item';
|
||||
import { Table } from '../core/table';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { ModifierCategoryService } from '../modifier-categories/modifier-category.service';
|
||||
@ -219,11 +220,8 @@ export class BillService {
|
||||
return this.bill.voucherType;
|
||||
}
|
||||
|
||||
receivePayment(
|
||||
amounts: { id: number; name: string; amount: number }[],
|
||||
name: string,
|
||||
): Observable<boolean> {
|
||||
return this.ser.receivePayment(this.bill.id as string, amounts, name, true);
|
||||
receivePayment(value: { choices: ReceivePaymentItem[]; reason: string }): Observable<boolean> {
|
||||
return this.ser.receivePayment(this.bill.id as string, value.choices, value.reason, true);
|
||||
}
|
||||
|
||||
moveTable(table: Table): Observable<boolean> {
|
||||
|
||||
@ -3,6 +3,7 @@ import { User } from '../../core/user';
|
||||
import { GuestBook } from '../../guest-book/guest-book';
|
||||
|
||||
import { Kot } from './kot';
|
||||
import { VoucherType } from './voucher-type';
|
||||
|
||||
export class Bill {
|
||||
id: string | undefined;
|
||||
@ -18,7 +19,7 @@ export class Bill {
|
||||
guest: GuestBook;
|
||||
// settlements: any[];
|
||||
voidReason: string;
|
||||
voucherType: string;
|
||||
voucherType: VoucherType;
|
||||
serial: number;
|
||||
kots: Kot[];
|
||||
// reprints: any[];
|
||||
@ -48,7 +49,7 @@ export class Bill {
|
||||
this.guest = new GuestBook();
|
||||
// this.settlements = [];
|
||||
this.voidReason = '';
|
||||
this.voucherType = '';
|
||||
this.voucherType = VoucherType.Kot;
|
||||
this.serial = 0;
|
||||
this.kots = [];
|
||||
// this.reprints = [];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
export enum VoucherType {
|
||||
Kot = 'KOT',
|
||||
Bill = 'REGULAR_BILL',
|
||||
NoCharge = 'NO_CHARGE',
|
||||
Staff = 'STAFF',
|
||||
Void = 'VOID',
|
||||
Kot = 0,
|
||||
Bill = 1,
|
||||
NoCharge = 2,
|
||||
Staff = 4,
|
||||
Void = 8,
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ export class VoucherService {
|
||||
updateTable: boolean,
|
||||
): Observable<boolean> {
|
||||
const options = {
|
||||
params: new HttpParams().set('p', voucherType).set('u', updateTable.toString()),
|
||||
params: new HttpParams().set('p', voucherType.toString()).set('u', updateTable.toString()),
|
||||
};
|
||||
if (guestBookId !== null) {
|
||||
options.params = options.params.set('g', guestBookId);
|
||||
@ -74,7 +74,7 @@ export class VoucherService {
|
||||
updateTable: boolean,
|
||||
): Observable<boolean> {
|
||||
const options = {
|
||||
params: new HttpParams().set('p', voucherType).set('u', updateTable.toString()),
|
||||
params: new HttpParams().set('p', voucherType.toString()).set('u', updateTable.toString()),
|
||||
};
|
||||
if (guestBookId !== null) {
|
||||
options.params = options.params.set('g', guestBookId);
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Observable, of as observableOf, throwError } from 'rxjs';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { map, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
import { AuthService } from '../../auth/auth.service';
|
||||
import { ReceivePaymentList } from '../../core/receive-payment-list';
|
||||
import { ReceivePaymentItem } from '../../core/receive-payment-item';
|
||||
import { Table } from '../../core/table';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { SaleCategoryService } from '../../sale-category/sale-category.service';
|
||||
@ -156,7 +156,7 @@ export class SalesHomeComponent {
|
||||
if (x) {
|
||||
return observableOf(x);
|
||||
}
|
||||
return throwError('No Bill Type Chosen');
|
||||
throw new Error('No Bill Type Chosen');
|
||||
}),
|
||||
switchMap((x: VoucherType) => this.bs.printBill(guestBookId, x as VoucherType)),
|
||||
)
|
||||
@ -187,43 +187,14 @@ export class SalesHomeComponent {
|
||||
return true;
|
||||
}
|
||||
|
||||
receivePaymentWithReason(type: string, amount: number): Observable<boolean> {
|
||||
const types: ReceivePaymentList = {
|
||||
NO_CHARGE: [
|
||||
{
|
||||
id: 4,
|
||||
name: 'No Charge',
|
||||
amount,
|
||||
},
|
||||
],
|
||||
STAFF: [
|
||||
{
|
||||
id: 10,
|
||||
name: 'Staff Account',
|
||||
amount,
|
||||
},
|
||||
],
|
||||
};
|
||||
return this.dialog
|
||||
.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: { title: type === 'NO_CHARGE' ? 'NC for whom' : 'Staff name' },
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
switchMap((value: boolean | string) => {
|
||||
if (value) {
|
||||
return this.bs.receivePayment(types[type], value as string);
|
||||
}
|
||||
return throwError('Cancelled');
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
receiveRegularPayment(type: string, amount: number): Observable<boolean> {
|
||||
return this.dialog
|
||||
receivePayment() {
|
||||
if (!this.receivePaymentAllowed()) {
|
||||
return;
|
||||
}
|
||||
const amount = this.bs.amountVal();
|
||||
const type = this.bs.type();
|
||||
this.dialog
|
||||
.open(ReceivePaymentComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
type,
|
||||
amount,
|
||||
@ -231,36 +202,24 @@ export class SalesHomeComponent {
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
switchMap((value: boolean | { id: number; name: string; amount: number }[]) => {
|
||||
if (value) {
|
||||
return this.bs.receivePayment(
|
||||
value as { id: number; name: string; amount: number }[],
|
||||
'',
|
||||
);
|
||||
switchMap((value: undefined | { choices: ReceivePaymentItem[]; reason: string }) => {
|
||||
if (value === undefined) {
|
||||
throw new Error('Receive Payment Choices / Reason not selected');
|
||||
}
|
||||
return throwError('Cancelled');
|
||||
return this.bs.receivePayment(value);
|
||||
}),
|
||||
)
|
||||
.subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
(value) => {
|
||||
this.toaster.show('Error', value);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
receivePayment() {
|
||||
if (!this.receivePaymentAllowed()) {
|
||||
return;
|
||||
}
|
||||
const amount = this.bs.amountVal();
|
||||
const type = this.bs.type();
|
||||
let obs: Observable<boolean>;
|
||||
if (type === 'NO_CHARGE' || type === 'STAFF') {
|
||||
obs = this.receivePaymentWithReason(type, amount);
|
||||
} else {
|
||||
obs = this.receiveRegularPayment(type, amount);
|
||||
}
|
||||
obs.subscribe(() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
});
|
||||
}
|
||||
|
||||
moveTableAllowed(): boolean {
|
||||
if (!this.auth.allowed('move-table') && !this.auth.allowed('merge-tables')) {
|
||||
return false;
|
||||
@ -290,12 +249,12 @@ export class SalesHomeComponent {
|
||||
if (x) {
|
||||
return this.confirmTableDialog(x as Table);
|
||||
}
|
||||
return throwError('Please choose a table');
|
||||
throw new Error('Please choose a table');
|
||||
}),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
switchMap((value: { table: Table; confirmed: boolean }, index: number) => {
|
||||
if (!value.confirmed) {
|
||||
return throwError('Please confirm move');
|
||||
throw new Error('Please confirm move');
|
||||
}
|
||||
if (value.table.status) {
|
||||
return this.bs.mergeTable(value.table);
|
||||
@ -350,13 +309,13 @@ export class SalesHomeComponent {
|
||||
if (x) {
|
||||
return this.confirmVoidDialog(x as string);
|
||||
}
|
||||
return throwError('Please choose a reason to void the bill');
|
||||
throw new Error('Please choose a reason to void the bill');
|
||||
}),
|
||||
switchMap((x: boolean | string) => {
|
||||
if (x) {
|
||||
return this.bs.voidBill(x as string);
|
||||
}
|
||||
return throwError('You chose not to void the bill');
|
||||
throw new Error('You chose not to void the bill');
|
||||
}),
|
||||
)
|
||||
.subscribe(
|
||||
@ -398,12 +357,12 @@ export class SalesHomeComponent {
|
||||
if (x) {
|
||||
return this.confirmTableDialog(x as Table);
|
||||
}
|
||||
return throwError('Please choose a table');
|
||||
throw new Error('Please choose a table');
|
||||
}),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
switchMap((value: { table: Table; confirmed: boolean }, index: number) => {
|
||||
if (!value.confirmed) {
|
||||
return throwError('Please confirm split');
|
||||
throw new Error('Please confirm split');
|
||||
}
|
||||
return this.bs.splitBill(value.table);
|
||||
}),
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
import { ReceivePaymentItem } from '../../core/receive-payment-item';
|
||||
import { SettleOption } from '../../core/settle-option';
|
||||
|
||||
export class ReceivePaymentDatasource extends DataSource<ReceivePaymentItem> {
|
||||
constructor(private data: ReceivePaymentItem[]) {
|
||||
export class ReceivePaymentDatasource extends DataSource<SettleOption> {
|
||||
constructor(private data: SettleOption[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<ReceivePaymentItem[]> {
|
||||
connect(): Observable<SettleOption[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<h2 mat-dialog-title>Receive Payment</h2>
|
||||
<mat-dialog-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<mat-table #table [dataSource]="dataSource" formArrayName="amounts">
|
||||
<mat-table #table [dataSource]="dataSource" formArrayName="amounts" *ngIf="this.displayTable">
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef class="bold">Amount</mat-header-cell>
|
||||
@ -28,9 +28,22 @@
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
<mat-footer-row *matFooterRowDef="displayedColumns"></mat-footer-row>
|
||||
</mat-table>
|
||||
<mat-form-field fxFlex *ngIf="this.displayReason">
|
||||
<mat-label>Reason</mat-label>
|
||||
<input
|
||||
type="text"
|
||||
matInput
|
||||
#son
|
||||
placeholder="Reason"
|
||||
formControlName="son"
|
||||
autocomplete="off"
|
||||
(focus)="select(son.value) && son.select()"
|
||||
(input)="select(son.value)"
|
||||
/>
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||
<button mat-button [mat-dialog-close]>Cancel</button>
|
||||
<button mat-button (click)="accept()" color="primary" [disabled]="!!balance">Ok</button>
|
||||
</mat-dialog-actions>
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Component, ElementRef, Inject, ViewChild } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { distinctUntilChanged } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
|
||||
|
||||
import { ReceivePaymentItem } from '../../core/receive-payment-item';
|
||||
import { ReceivePaymentList } from '../../core/receive-payment-list';
|
||||
import { SettleOption } from '../../core/settle-option';
|
||||
import { SettleOptionService } from '../../settle-option/settle-option.service';
|
||||
import { VoucherType } from '../bills/voucher-type';
|
||||
|
||||
import { ReceivePaymentDatasource } from './receive-payment-datasource';
|
||||
@ -15,48 +16,15 @@ import { ReceivePaymentDatasource } from './receive-payment-datasource';
|
||||
styleUrls: ['./receive-payment.component.css'],
|
||||
})
|
||||
export class ReceivePaymentComponent {
|
||||
choices: ReceivePaymentList = {
|
||||
REGULAR_BILL: [
|
||||
{
|
||||
id: 2,
|
||||
name: 'Cash',
|
||||
amount: 0,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Credit Card',
|
||||
amount: 0,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Bill To Company',
|
||||
amount: 0,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Tip',
|
||||
amount: 0,
|
||||
},
|
||||
],
|
||||
NO_CHARGE: [
|
||||
{
|
||||
id: 4,
|
||||
name: 'No Charge',
|
||||
amount: 0,
|
||||
},
|
||||
],
|
||||
STAFF: [
|
||||
{
|
||||
id: 10,
|
||||
name: 'Staff Account',
|
||||
amount: 0,
|
||||
},
|
||||
],
|
||||
};
|
||||
@ViewChild('son', { static: true }) son?: ElementRef;
|
||||
choices: ReceivePaymentItem[] = [];
|
||||
|
||||
type: VoucherType;
|
||||
amount: number;
|
||||
balance: number;
|
||||
reason = '';
|
||||
displayReason: boolean;
|
||||
displayTable: boolean;
|
||||
form: FormGroup;
|
||||
dataSource: ReceivePaymentDatasource;
|
||||
|
||||
@ -65,41 +33,70 @@ export class ReceivePaymentComponent {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ReceivePaymentComponent>,
|
||||
private fb: FormBuilder,
|
||||
private ser: SettleOptionService,
|
||||
@Inject(MAT_DIALOG_DATA) public data: { type: VoucherType; amount: number },
|
||||
) {
|
||||
this.form = this.fb.group({
|
||||
amounts: '',
|
||||
son: '',
|
||||
});
|
||||
this.type = data.type;
|
||||
this.amount = data.amount;
|
||||
this.balance = data.amount;
|
||||
this.form.setControl(
|
||||
'amounts',
|
||||
this.fb.array(
|
||||
this.choices[this.type].map((x: ReceivePaymentItem) =>
|
||||
this.fb.group({
|
||||
name: [x.name],
|
||||
amount: [''],
|
||||
}),
|
||||
this.displayReason = false;
|
||||
this.displayTable = false;
|
||||
this.ser
|
||||
.listForType(data.type)
|
||||
.pipe(
|
||||
tap(
|
||||
(x: SettleOption[]) =>
|
||||
(this.displayReason = x.reduce((o, n) => o || n.hasReason, this.displayReason)),
|
||||
),
|
||||
),
|
||||
);
|
||||
this.dataSource = new ReceivePaymentDatasource(this.choices[this.type]);
|
||||
tap((x: SettleOption[]) => (this.displayTable = x.length > 1)),
|
||||
map((x: SettleOption[]) =>
|
||||
x.map(
|
||||
(y) => ({ ...y, amount: !this.displayTable ? this.amount : 0 } as ReceivePaymentItem),
|
||||
),
|
||||
),
|
||||
)
|
||||
.subscribe((x) => {
|
||||
this.choices = x;
|
||||
this.form.setControl(
|
||||
'amounts',
|
||||
this.fb.array(
|
||||
this.choices.map((y: ReceivePaymentItem) =>
|
||||
this.fb.group({
|
||||
name: [y.name],
|
||||
amount: [y.amount === 0 ? '' : '' + this.amount],
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
this.dataSource = new ReceivePaymentDatasource(this.choices);
|
||||
this.listenToAmountChange();
|
||||
this.balance = this.amount - this.choices.reduce((a, c) => a + c.amount, 0);
|
||||
});
|
||||
this.dataSource = new ReceivePaymentDatasource(this.choices);
|
||||
this.listenToAmountChange();
|
||||
}
|
||||
|
||||
listenToAmountChange() {
|
||||
const array = this.form.get('amounts') as FormArray;
|
||||
this.choices[this.type].forEach((z, i) =>
|
||||
this.choices.forEach((z, i) =>
|
||||
array.controls[i].valueChanges.pipe(distinctUntilChanged()).subscribe((x) => {
|
||||
(this.choices[this.type].find((s) => s.name === x.name) as ReceivePaymentItem).amount =
|
||||
(this.choices.find((s) => s.name === x.name) as ReceivePaymentItem).amount =
|
||||
x.amount === '' ? 0 : parseInt(x.amount, 10);
|
||||
this.balance = this.amount - this.choices[this.type].reduce((a, c) => a + c.amount, 0);
|
||||
this.balance = this.amount - this.choices.reduce((a, c) => a + c.amount, 0);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
select(reason: string) {
|
||||
this.reason = reason.trim();
|
||||
return true;
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
this.dialogRef.close(this.choices[this.type]);
|
||||
this.dialogRef.close({ choices: this.choices, reason: this.reason });
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
.example-card {
|
||||
max-width: 400px;
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
<div fxLayout="row" fxFlex="50%" fxLayoutAlign="space-around center" class="example-card">
|
||||
<mat-card fxFlex>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Settle Option</mat-card-title>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Voucher Type</mat-label>
|
||||
<mat-select placeholder="Voucher Type" formControlName="voucherType">
|
||||
<mat-option *ngFor="let vt of voucherTypes" [value]="vt.id">
|
||||
{{ vt.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Reporting Level</mat-label>
|
||||
<mat-select placeholder="Reporting Level" formControlName="reportingLevel">
|
||||
<mat-option *ngFor="let rl of reportingLevel" [value]="rl.id">
|
||||
{{ rl.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-checkbox formControlName="hasReason">Has Reason?</mat-checkbox>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" (click)="save()">Save</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">
|
||||
Delete
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
@ -0,0 +1,26 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
|
||||
import { SettleOptionDetailComponent } from './settle-option-detail.component';
|
||||
|
||||
describe('SettleOptionDetailComponent', () => {
|
||||
let component: SettleOptionDetailComponent;
|
||||
let fixture: ComponentFixture<SettleOptionDetailComponent>;
|
||||
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SettleOptionDetailComponent],
|
||||
}).compileComponents();
|
||||
}),
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SettleOptionDetailComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,118 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { ReportingLevel } from '../../core/reporting-level';
|
||||
import { SettleOption } from '../../core/settle-option';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { VoucherType } from '../../sales/bills/voucher-type';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { SettleOptionService } from '../settle-option.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settle-option-detail',
|
||||
templateUrl: './settle-option-detail.component.html',
|
||||
styleUrls: ['./settle-option-detail.component.css'],
|
||||
})
|
||||
export class SettleOptionDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup;
|
||||
item: SettleOption = new SettleOption();
|
||||
voucherTypes: { id: number; name: string }[];
|
||||
reportingLevel: { id: number; name: string }[];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: SettleOptionService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
voucherType: '',
|
||||
reportingLevel: '',
|
||||
hasReason: '',
|
||||
});
|
||||
this.voucherTypes = Object.keys(VoucherType)
|
||||
.filter((e) => !isNaN(+e))
|
||||
.map((o) => ({ id: +o, name: VoucherType[+o] as string }));
|
||||
this.reportingLevel = Object.keys(ReportingLevel)
|
||||
.filter((e) => !isNaN(+e))
|
||||
.map((o) => ({ id: +o, name: ReportingLevel[+o] as string }));
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { item: SettleOption };
|
||||
this.showItem(data.item);
|
||||
});
|
||||
}
|
||||
|
||||
showItem(item: SettleOption) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name,
|
||||
voucherType: this.item.voucherType,
|
||||
reportingLevel: this.item.reportingLevel,
|
||||
hasReason: this.item.hasReason,
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
if (this.nameElement !== undefined) {
|
||||
this.nameElement.nativeElement.focus();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/settle-options');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/settle-options');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: { title: 'Delete Settle Option?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
if (result) {
|
||||
this.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getItem(): SettleOption {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.voucherType = formModel.voucherType;
|
||||
this.item.reportingLevel = formModel.reportingLevel;
|
||||
this.item.hasReason = formModel.hasReason;
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SettleOptionListResolver } from './settle-option-list-resolver.service';
|
||||
|
||||
describe('SettleOptionListResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SettleOptionListResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject(
|
||||
[SettleOptionListResolver],
|
||||
(service: SettleOptionListResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { SettleOption } from '../core/settle-option';
|
||||
|
||||
import { SettleOptionService } from './settle-option.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SettleOptionListResolver implements Resolve<SettleOption[]> {
|
||||
constructor(private ser: SettleOptionService) {}
|
||||
|
||||
resolve(): Observable<SettleOption[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
import { SettleOption } from '../../core/settle-option';
|
||||
|
||||
export class SettleOptionListDatasource extends DataSource<SettleOption> {
|
||||
private data: SettleOption[] = [];
|
||||
|
||||
constructor(private readonly dataObs: Observable<SettleOption[]>) {
|
||||
super();
|
||||
this.dataObs = dataObs.pipe(
|
||||
tap((x) => {
|
||||
this.data = x;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
connect(): Observable<SettleOption[]> {
|
||||
return this.dataObs;
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Settle Options</mat-card-title>
|
||||
<a mat-button [routerLink]="['/settle-options', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a [routerLink]="['/settle-options', row.id]">{{ row.name }}</a></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Voucher Type Column -->
|
||||
<ng-container matColumnDef="voucherType">
|
||||
<mat-header-cell *matHeaderCellDef>Voucher Type</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ voucherType(row.voucherType) }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Reporting Level Column -->
|
||||
<ng-container matColumnDef="reportingLevel">
|
||||
<mat-header-cell *matHeaderCellDef>Reporting Level</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ reportingLevel(row.reportingLevel) }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Has Reason Column -->
|
||||
<ng-container matColumnDef="hasReason">
|
||||
<mat-header-cell *matHeaderCellDef>Has Reason?</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.hasReason }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Fixture Column -->
|
||||
<ng-container matColumnDef="isFixture">
|
||||
<mat-header-cell *matHeaderCellDef>Fixture?</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.isFixture }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@ -0,0 +1,22 @@
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SettleOptionListComponent } from './settle-option-list.component';
|
||||
|
||||
describe('SettleOptionListComponent', () => {
|
||||
let component: SettleOptionListComponent;
|
||||
let fixture: ComponentFixture<SettleOptionListComponent>;
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SettleOptionListComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SettleOptionListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should compile', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,69 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ReportingLevel } from '../../core/reporting-level';
|
||||
import { SettleOption } from '../../core/settle-option';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { VoucherType } from '../../sales/bills/voucher-type';
|
||||
import { SettleOptionService } from '../settle-option.service';
|
||||
|
||||
import { SettleOptionListDatasource } from './settle-option-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settle-option-list',
|
||||
templateUrl: './settle-option-list.component.html',
|
||||
styleUrls: ['./settle-option-list.component.css'],
|
||||
})
|
||||
export class SettleOptionListComponent implements OnInit {
|
||||
@ViewChild('table', { static: true }) table?: MatTable<SettleOption>;
|
||||
data: BehaviorSubject<SettleOption[]> = new BehaviorSubject<SettleOption[]>([]);
|
||||
dataSource: SettleOptionListDatasource = new SettleOptionListDatasource(this.data);
|
||||
list: SettleOption[] = [];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'voucherType', 'reportingLevel', 'hasReason', 'isFixture'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private ser: SettleOptionService,
|
||||
) {
|
||||
this.data.subscribe((data: SettleOption[]) => {
|
||||
this.list = data;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.pipe(
|
||||
map((x) => {
|
||||
const data = (x as { list: SettleOption[] }).list;
|
||||
return data.map((y) => {
|
||||
y.voucherType = y.voucherType;
|
||||
y.reportingLevel = y.reportingLevel;
|
||||
return y;
|
||||
});
|
||||
}),
|
||||
)
|
||||
.subscribe((list) => {
|
||||
this.data.next(list);
|
||||
});
|
||||
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: SettleOption[] };
|
||||
this.data.next(data.list);
|
||||
});
|
||||
this.dataSource = new SettleOptionListDatasource(this.data);
|
||||
}
|
||||
|
||||
voucherType(input: VoucherType): string {
|
||||
return VoucherType[input];
|
||||
}
|
||||
|
||||
reportingLevel(input: ReportingLevel): string {
|
||||
return ReportingLevel[input];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SettleOptionResolver } from './settle-option-resolver.service';
|
||||
|
||||
describe('SettleOptionResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SettleOptionResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SettleOptionResolver], (service: SettleOptionResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { SettleOption } from '../core/settle-option';
|
||||
|
||||
import { SettleOptionService } from './settle-option.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SettleOptionResolver implements Resolve<SettleOption> {
|
||||
constructor(private ser: SettleOptionService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<SettleOption> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
}
|
||||
}
|
||||
15
bookie/src/app/settle-option/settle-option.service.spec.ts
Normal file
15
bookie/src/app/settle-option/settle-option.service.spec.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SettleOptionService } from './settle-option.service';
|
||||
|
||||
describe('SettleOptionService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SettleOptionService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SettleOptionService], (service: SettleOptionService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
69
bookie/src/app/settle-option/settle-option.service.ts
Normal file
69
bookie/src/app/settle-option/settle-option.service.ts
Normal file
@ -0,0 +1,69 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { SettleOption } from '../core/settle-option';
|
||||
import { VoucherType } from '../sales/bills/voucher-type';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
const url = '/api/settle-options';
|
||||
const serviceName = 'SettleOptionService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SettleOptionService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(id: string | null): Observable<SettleOption> {
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
return this.http
|
||||
.get<SettleOption>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`)),
|
||||
) as Observable<SettleOption>;
|
||||
}
|
||||
|
||||
list(): Observable<SettleOption[]> {
|
||||
return this.http
|
||||
.get<SettleOption[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<SettleOption[]>;
|
||||
}
|
||||
|
||||
listForType(voucherType: VoucherType): Observable<SettleOption[]> {
|
||||
return this.http
|
||||
.get<SettleOption[]>(`${url}/for-type/${voucherType}`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `listForType voucherType=${voucherType}`)),
|
||||
) as Observable<SettleOption[]>;
|
||||
}
|
||||
|
||||
save(settleOption: SettleOption): Observable<SettleOption> {
|
||||
return this.http
|
||||
.post<SettleOption>(url, settleOption, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<SettleOption>;
|
||||
}
|
||||
|
||||
update(settleOption: SettleOption): Observable<SettleOption> {
|
||||
return this.http
|
||||
.put<SettleOption>(`${url}/${settleOption.id}`, settleOption, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<SettleOption>;
|
||||
}
|
||||
|
||||
saveOrUpdate(settleOption: SettleOption): Observable<SettleOption> {
|
||||
if (!settleOption.id) {
|
||||
return this.save(settleOption);
|
||||
}
|
||||
return this.update(settleOption);
|
||||
}
|
||||
|
||||
delete(id: number): Observable<SettleOption> {
|
||||
return this.http
|
||||
.delete<SettleOption>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<SettleOption>;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import { SettleOptionsRoutingModule } from './settle-options-routing.module';
|
||||
|
||||
describe('SettleOptionsRoutingModule', () => {
|
||||
let settleOptionsRoutingModule: SettleOptionsRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
settleOptionsRoutingModule = new SettleOptionsRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(settleOptionsRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,54 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { TaxListResolver } from '../taxes/tax-list-resolver.service';
|
||||
|
||||
import { SettleOptionDetailComponent } from './settle-option-detail/settle-option-detail.component';
|
||||
import { SettleOptionListResolver } from './settle-option-list-resolver.service';
|
||||
import { SettleOptionListComponent } from './settle-option-list/settle-option-list.component';
|
||||
import { SettleOptionResolver } from './settle-option-resolver.service';
|
||||
|
||||
const settleOptionsRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: SettleOptionListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Owner',
|
||||
},
|
||||
resolve: {
|
||||
list: SettleOptionListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: SettleOptionDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Owner',
|
||||
},
|
||||
resolve: {
|
||||
item: SettleOptionResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: SettleOptionDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Owner',
|
||||
},
|
||||
resolve: {
|
||||
item: SettleOptionResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(settleOptionsRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [SettleOptionListResolver, SettleOptionResolver],
|
||||
})
|
||||
export class SettleOptionsRoutingModule {}
|
||||
13
bookie/src/app/settle-option/settle-options.module.spec.ts
Normal file
13
bookie/src/app/settle-option/settle-options.module.spec.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { SettleOptionsModule } from './settle-options.module';
|
||||
|
||||
describe('SettleOptionsModule', () => {
|
||||
let settleOptionsModule: SettleOptionsModule;
|
||||
|
||||
beforeEach(() => {
|
||||
settleOptionsModule = new SettleOptionsModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(settleOptionsModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
37
bookie/src/app/settle-option/settle-options.module.ts
Normal file
37
bookie/src/app/settle-option/settle-options.module.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatOptionModule } from '@angular/material/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
|
||||
import { SettleOptionDetailComponent } from './settle-option-detail/settle-option-detail.component';
|
||||
import { SettleOptionListComponent } from './settle-option-list/settle-option-list.component';
|
||||
import { SettleOptionsRoutingModule } from './settle-options-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatOptionModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSelectModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SettleOptionsRoutingModule,
|
||||
],
|
||||
declarations: [SettleOptionListComponent, SettleOptionDetailComponent],
|
||||
})
|
||||
export class SettleOptionsModule {}
|
||||
Reference in New Issue
Block a user