|
|
@ -106,20 +106,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
.subscribe((state) => {
|
|
|
|
.subscribe((state) => {
|
|
|
|
if (state?.user) {
|
|
|
|
if (state?.user) {
|
|
|
|
this.user = state.user;
|
|
|
|
this.updateUser(state.user);
|
|
|
|
|
|
|
|
|
|
|
|
this.defaultAccountId = this.user?.accounts.find((account) => {
|
|
|
|
|
|
|
|
return account.isDefault;
|
|
|
|
|
|
|
|
})?.id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToCreateOrder = hasPermission(
|
|
|
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
|
|
|
permissions.createOrder
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.hasPermissionToDeleteOrder = hasPermission(
|
|
|
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
|
|
|
permissions.deleteOrder
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -352,43 +339,50 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private openCreateTransactionDialog(aTransaction?: OrderModel): void {
|
|
|
|
private openCreateTransactionDialog(aTransaction?: OrderModel): void {
|
|
|
|
const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, {
|
|
|
|
this.userService
|
|
|
|
data: {
|
|
|
|
.get()
|
|
|
|
accounts: this.user?.accounts?.filter((account) => {
|
|
|
|
|
|
|
|
return account.accountType === 'SECURITIES';
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
transaction: {
|
|
|
|
|
|
|
|
accountId: aTransaction?.accountId ?? this.defaultAccountId,
|
|
|
|
|
|
|
|
currency: aTransaction?.currency ?? null,
|
|
|
|
|
|
|
|
dataSource: aTransaction?.dataSource ?? null,
|
|
|
|
|
|
|
|
date: new Date(),
|
|
|
|
|
|
|
|
fee: 0,
|
|
|
|
|
|
|
|
quantity: null,
|
|
|
|
|
|
|
|
symbol: aTransaction?.symbol ?? null,
|
|
|
|
|
|
|
|
type: aTransaction?.type ?? 'BUY',
|
|
|
|
|
|
|
|
unitPrice: null
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
user: this.user
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
|
|
|
|
|
|
|
|
width: this.deviceType === 'mobile' ? '100vw' : '50rem'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dialogRef
|
|
|
|
|
|
|
|
.afterClosed()
|
|
|
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
.subscribe((data: any) => {
|
|
|
|
.subscribe((user) => {
|
|
|
|
const transaction: CreateOrderDto = data?.transaction;
|
|
|
|
this.updateUser(user);
|
|
|
|
|
|
|
|
|
|
|
|
if (transaction) {
|
|
|
|
const dialogRef = this.dialog.open(CreateOrUpdateTransactionDialog, {
|
|
|
|
this.dataService.postOrder(transaction).subscribe({
|
|
|
|
data: {
|
|
|
|
next: () => {
|
|
|
|
accounts: this.user?.accounts?.filter((account) => {
|
|
|
|
this.fetchOrders();
|
|
|
|
return account.accountType === 'SECURITIES';
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
transaction: {
|
|
|
|
|
|
|
|
accountId: aTransaction?.accountId ?? this.defaultAccountId,
|
|
|
|
|
|
|
|
currency: aTransaction?.currency ?? null,
|
|
|
|
|
|
|
|
dataSource: aTransaction?.dataSource ?? null,
|
|
|
|
|
|
|
|
date: new Date(),
|
|
|
|
|
|
|
|
fee: 0,
|
|
|
|
|
|
|
|
quantity: null,
|
|
|
|
|
|
|
|
symbol: aTransaction?.symbol ?? null,
|
|
|
|
|
|
|
|
type: aTransaction?.type ?? 'BUY',
|
|
|
|
|
|
|
|
unitPrice: null
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
user: this.user
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
|
|
|
|
|
|
|
|
width: this.deviceType === 'mobile' ? '100vw' : '50rem'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dialogRef
|
|
|
|
|
|
|
|
.afterClosed()
|
|
|
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
|
|
|
|
.subscribe((data: any) => {
|
|
|
|
|
|
|
|
const transaction: CreateOrderDto = data?.transaction;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (transaction) {
|
|
|
|
|
|
|
|
this.dataService.postOrder(transaction).subscribe({
|
|
|
|
|
|
|
|
next: () => {
|
|
|
|
|
|
|
|
this.fetchOrders();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.router.navigate(['.'], { relativeTo: this.route });
|
|
|
|
this.router.navigate(['.'], { relativeTo: this.route });
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -397,7 +391,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
.get()
|
|
|
|
.get()
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
.subscribe((user) => {
|
|
|
|
.subscribe((user) => {
|
|
|
|
this.user = user;
|
|
|
|
this.updateUser(user);
|
|
|
|
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(PositionDetailDialog, {
|
|
|
|
const dialogRef = this.dialog.open(PositionDetailDialog, {
|
|
|
|
autoFocus: false,
|
|
|
|
autoFocus: false,
|
|
|
@ -419,4 +413,21 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private updateUser(aUser: User) {
|
|
|
|
|
|
|
|
this.user = aUser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.defaultAccountId = this.user?.accounts.find((account) => {
|
|
|
|
|
|
|
|
return account.isDefault;
|
|
|
|
|
|
|
|
})?.id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToCreateOrder = hasPermission(
|
|
|
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
|
|
|
permissions.createOrder
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.hasPermissionToDeleteOrder = hasPermission(
|
|
|
|
|
|
|
|
this.user.permissions,
|
|
|
|
|
|
|
|
permissions.deleteOrder
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|