|
|
@@ -22,7 +22,8 @@ import { mergeMap, take } from 'rxjs/operators';
|
|
|
styleUrls: ['./tax-category-detail.component.scss'],
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
})
|
|
|
-export class TaxCategoryDetailComponent extends BaseDetailComponent<TaxCategory.Fragment>
|
|
|
+export class TaxCategoryDetailComponent
|
|
|
+ extends BaseDetailComponent<TaxCategory.Fragment>
|
|
|
implements OnInit, OnDestroy {
|
|
|
taxCategory$: Observable<TaxCategory.Fragment>;
|
|
|
detailForm: FormGroup;
|
|
|
@@ -42,7 +43,7 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent<TaxCategory.
|
|
|
super(route, router, serverConfigService, dataService);
|
|
|
this.detailForm = this.formBuilder.group({
|
|
|
name: ['', Validators.required],
|
|
|
- taxRate: [0, Validators.required],
|
|
|
+ isDefault: false,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -64,9 +65,9 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent<TaxCategory.
|
|
|
return;
|
|
|
}
|
|
|
const formValue = this.detailForm.value;
|
|
|
- const input = { name: formValue.name } as CreateTaxCategoryInput;
|
|
|
+ const input = { name: formValue.name, isDefault: formValue.isDefault } as CreateTaxCategoryInput;
|
|
|
this.dataService.settings.createTaxCategory(input).subscribe(
|
|
|
- (data) => {
|
|
|
+ data => {
|
|
|
this.notificationService.success(_('common.notify-create-success'), {
|
|
|
entity: 'TaxCategory',
|
|
|
});
|
|
|
@@ -74,7 +75,7 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent<TaxCategory.
|
|
|
this.changeDetector.markForCheck();
|
|
|
this.router.navigate(['../', data.createTaxCategory.id], { relativeTo: this.route });
|
|
|
},
|
|
|
- (err) => {
|
|
|
+ err => {
|
|
|
this.notificationService.error(_('common.notify-create-error'), {
|
|
|
entity: 'TaxCategory',
|
|
|
});
|
|
|
@@ -90,23 +91,24 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent<TaxCategory.
|
|
|
this.taxCategory$
|
|
|
.pipe(
|
|
|
take(1),
|
|
|
- mergeMap((taxCategory) => {
|
|
|
+ mergeMap(taxCategory => {
|
|
|
const input = {
|
|
|
id: taxCategory.id,
|
|
|
name: formValue.name,
|
|
|
+ isDefault: formValue.isDefault,
|
|
|
} as UpdateTaxCategoryInput;
|
|
|
return this.dataService.settings.updateTaxCategory(input);
|
|
|
}),
|
|
|
)
|
|
|
.subscribe(
|
|
|
- (data) => {
|
|
|
+ data => {
|
|
|
this.notificationService.success(_('common.notify-update-success'), {
|
|
|
entity: 'TaxCategory',
|
|
|
});
|
|
|
this.detailForm.markAsPristine();
|
|
|
this.changeDetector.markForCheck();
|
|
|
},
|
|
|
- (err) => {
|
|
|
+ err => {
|
|
|
this.notificationService.error(_('common.notify-update-error'), {
|
|
|
entity: 'TaxCategory',
|
|
|
});
|
|
|
@@ -120,6 +122,7 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent<TaxCategory.
|
|
|
protected setFormValues(entity: TaxCategory.Fragment, languageCode: LanguageCode): void {
|
|
|
this.detailForm.patchValue({
|
|
|
name: entity.name,
|
|
|
+ isDefault: entity.isDefault,
|
|
|
});
|
|
|
}
|
|
|
}
|