diff --git a/brewman/models/master.py b/brewman/models/master.py index 63d3a3af..dba4edde 100644 --- a/brewman/models/master.py +++ b/brewman/models/master.py @@ -435,7 +435,7 @@ class AttendanceType: @classmethod def list(cls): - list = [ + return [ AttendanceType(0, "Not Set", 0), AttendanceType(1, "Present", 1), AttendanceType(2, "Off Day", 1), @@ -449,15 +449,14 @@ class AttendanceType: AttendanceType(10, "Half Day + PL", 1), AttendanceType(11, "Half Day + CL", 1), ] - return list @classmethod def by_name(cls, name): - next(i for i in cls.list() if i.name == name) + return next(i for i in cls.list() if i.name == name) @classmethod def by_id(cls, id_): - next(i for i in cls.list() if i.id == id_) + return next(i for i in cls.list() if i.id == id_) class AccountType: @@ -499,11 +498,11 @@ class AccountType: @classmethod def by_name(cls, name): - next(i for i in cls.list() if i.name == name) + return next(i for i in cls.list() if i.name == name) @classmethod def by_id(cls, id_): - next(i for i in cls.list() if i.id == id_) + return next(i for i in cls.list() if i.id == id_) class DbSetting(Base): diff --git a/overlord/package.json b/overlord/package.json index 56bcff26..b5523b4d 100644 --- a/overlord/package.json +++ b/overlord/package.json @@ -1,6 +1,6 @@ { "name": "overlord", - "version": "7.0.1", + "version": "7.0.2", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/overlord/src/app/employee-benefits/employee-benefits.component.ts b/overlord/src/app/employee-benefits/employee-benefits.component.ts index 4dfe8db7..d464c05c 100644 --- a/overlord/src/app/employee-benefits/employee-benefits.component.ts +++ b/overlord/src/app/employee-benefits/employee-benefits.component.ts @@ -52,17 +52,7 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit { ngOnInit() { this.route.data .subscribe((data: { voucher: Voucher }) => { - this.voucher = data.voucher; - this.form.setValue({ - date: moment(this.voucher.date, 'DD-MMM-YYYY').toDate(), - addRow: { - employee: '1', - grossSalary: '', - daysWorked: '' - } - }); - this.dataSource = new EmployeeBenefitsDataSource(this.benefitsObservable); - this.benefitsObservable.next(this.voucher.employeeBenefits); + this.loadVoucher(data.voucher); }); } @@ -72,6 +62,20 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit { }, 0); } + loadVoucher(voucher) { + this.voucher = voucher; + this.form.setValue({ + date: moment(this.voucher.date, 'DD-MMM-YYYY').toDate(), + addRow: { + employee: '1', + grossSalary: '', + daysWorked: '' + } + }); + this.dataSource = new EmployeeBenefitsDataSource(this.benefitsObservable); + this.benefitsObservable.next(this.voucher.employeeBenefits); + } + createForm() { this.form = this.fb.group({ date: '', @@ -181,6 +185,7 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit { this.ser.post(this.voucher.id) .subscribe( (result) => { + this.loadVoucher(result); this.toaster.show('Success', 'Voucher Posted'); }, (error) => { @@ -190,11 +195,16 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit { } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/employee-benefits', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/overlord/src/app/incentive/incentive.component.ts b/overlord/src/app/incentive/incentive.component.ts index cb62abef..efb53a6c 100644 --- a/overlord/src/app/incentive/incentive.component.ts +++ b/overlord/src/app/incentive/incentive.component.ts @@ -46,20 +46,24 @@ export class IncentiveComponent implements OnInit { ngOnInit() { this.route.data .subscribe((data: { voucher: Voucher }) => { - this.voucher = data.voucher; - this.form.get('date').setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate()); - this.form.setControl('incentives', this.fb.array( - this.voucher.incentives.map( - x => this.fb.group({ - points: x.points - }) - ) - )); - this.dataSource = new IncentiveDataSource(this.incentiveObservable); - this.incentiveObservable.next(this.voucher.incentives); + this.loadVoucher(data.voucher); }); } + loadVoucher(voucher) { + this.voucher = voucher; + this.form.get('date').setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate()); + this.form.setControl('incentives', this.fb.array( + this.voucher.incentives.map( + x => this.fb.group({ + points: x.points + }) + ) + )); + this.dataSource = new IncentiveDataSource(this.incentiveObservable); + this.incentiveObservable.next(this.voucher.incentives); + } + createForm() { this.form = this.fb.group({ date: '', @@ -74,17 +78,7 @@ export class IncentiveComponent implements OnInit { if (x !== this.voucher.date && !this.voucher.id) { return this.ser.getIncentive(x) .subscribe((voucher: Voucher) => { - this.voucher = voucher; - this.form.get('date').setValue(moment(this.voucher.date, 'DD-MMM-YYYY').toDate()); - this.form.setControl('incentives', this.fb.array( - this.voucher.incentives.map( - i => this.fb.group({ - points: i.points - }) - ) - )); - this.dataSource = new IncentiveDataSource(this.incentiveObservable); - this.incentiveObservable.next(this.voucher.incentives); + this.loadVoucher(voucher); }); } }); @@ -137,6 +131,7 @@ export class IncentiveComponent implements OnInit { this.ser.post(this.voucher.id) .subscribe( (result) => { + this.loadVoucher(result); this.toaster.show('Success', 'Voucher Posted'); }, (error) => { @@ -146,11 +141,15 @@ export class IncentiveComponent implements OnInit { } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { - this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/incentive', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/overlord/src/app/issue/issue.component.ts b/overlord/src/app/issue/issue.component.ts index ca8ce574..38e579bf 100644 --- a/overlord/src/app/issue/issue.component.ts +++ b/overlord/src/app/issue/issue.component.ts @@ -215,12 +215,16 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy { } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { - this.loadVoucher(result); this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/issue', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/overlord/src/app/journal/journal.component.ts b/overlord/src/app/journal/journal.component.ts index 077a5e66..a0810a9e 100644 --- a/overlord/src/app/journal/journal.component.ts +++ b/overlord/src/app/journal/journal.component.ts @@ -17,7 +17,7 @@ import {ToasterService} from '../core/toaster.service'; import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators'; import {JournalDialogComponent} from './journal-dialog.component'; import {ImageDialogComponent} from '../shared/image-dialog/image-dialog.component'; -import {Hotkey, HotkeysService} from "angular2-hotkeys"; +import {Hotkey, HotkeysService} from 'angular2-hotkeys'; @Component({ selector: 'app-journal', @@ -66,13 +66,15 @@ export class JournalComponent implements OnInit, AfterViewInit, OnDestroy { return false; // Prevent bubbling }, ['INPUT', 'SELECT', 'TEXTAREA'])); this.hotkeys.add(new Hotkey('ctrl+s', (event: KeyboardEvent): boolean => { - if (this.canSave()) + if (this.canSave()) { this.save(); + } return false; // Prevent bubbling }, ['INPUT', 'SELECT', 'TEXTAREA'])); this.hotkeys.add(new Hotkey('ctrl+p', (event: KeyboardEvent): boolean => { - if (this.voucher.id && !this.voucher.posted && this.auth.user.perms.indexOf('post-vouchers') !== -1) + if (this.voucher.id && !this.voucher.posted && this.auth.user.perms.indexOf('post-vouchers') !== -1) { this.post(); + } return false; // Prevent bubbling }, ['INPUT', 'SELECT', 'TEXTAREA'])); } @@ -225,12 +227,16 @@ export class JournalComponent implements OnInit, AfterViewInit, OnDestroy { } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { - this.loadVoucher(result); this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/journal', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/overlord/src/app/payment/payment.component.ts b/overlord/src/app/payment/payment.component.ts index 45e795ad..06e10af7 100644 --- a/overlord/src/app/payment/payment.component.ts +++ b/overlord/src/app/payment/payment.component.ts @@ -17,7 +17,7 @@ import {ToasterService} from '../core/toaster.service'; import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators'; import {PaymentDialogComponent} from './payment-dialog.component'; import {ImageDialogComponent} from '../shared/image-dialog/image-dialog.component'; -import {Hotkey, HotkeysService} from "angular2-hotkeys"; +import {Hotkey, HotkeysService} from 'angular2-hotkeys'; @Component({ selector: 'app-payment', @@ -229,12 +229,16 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy { } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { - this.loadVoucher(result); this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/payment', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/overlord/src/app/purchase-return/purchase-return.component.ts b/overlord/src/app/purchase-return/purchase-return.component.ts index e0eb99f3..2970b118 100644 --- a/overlord/src/app/purchase-return/purchase-return.component.ts +++ b/overlord/src/app/purchase-return/purchase-return.component.ts @@ -215,12 +215,16 @@ export class PurchaseReturnComponent implements OnInit, AfterViewInit, OnDestroy } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { - this.loadVoucher(result); this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/purchase-return', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/overlord/src/app/purchase/purchase.component.ts b/overlord/src/app/purchase/purchase.component.ts index e2198866..67e6f068 100644 --- a/overlord/src/app/purchase/purchase.component.ts +++ b/overlord/src/app/purchase/purchase.component.ts @@ -228,12 +228,16 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy { } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { - this.loadVoucher(result); this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/purchase', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/overlord/src/app/receipt/receipt.component.ts b/overlord/src/app/receipt/receipt.component.ts index 68223e21..17a44fe7 100644 --- a/overlord/src/app/receipt/receipt.component.ts +++ b/overlord/src/app/receipt/receipt.component.ts @@ -17,7 +17,7 @@ import {ToasterService} from '../core/toaster.service'; import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators'; import {ReceiptDialogComponent} from './receipt-dialog.component'; import {ImageDialogComponent} from '../shared/image-dialog/image-dialog.component'; -import {Hotkey, HotkeysService} from "angular2-hotkeys"; +import {Hotkey, HotkeysService} from 'angular2-hotkeys'; @Component({ selector: 'app-receipt', @@ -70,13 +70,15 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy { return false; // Prevent bubbling }, ['INPUT', 'SELECT', 'TEXTAREA'])); this.hotkeys.add(new Hotkey('ctrl+s', (event: KeyboardEvent): boolean => { - if (this.canSave()) + if (this.canSave()) { this.save(); + } return false; // Prevent bubbling }, ['INPUT', 'SELECT', 'TEXTAREA'])); this.hotkeys.add(new Hotkey('ctrl+p', (event: KeyboardEvent): boolean => { - if (this.voucher.id && !this.voucher.posted && this.auth.user.perms.indexOf('post-vouchers') !== -1) + if (this.voucher.id && !this.voucher.posted && this.auth.user.perms.indexOf('post-vouchers') !== -1) { this.post(); + } return false; // Prevent bubbling }, ['INPUT', 'SELECT', 'TEXTAREA'])); } @@ -228,12 +230,16 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy { } save() { - this.ser.saveOrUpdate(this.getVoucher()) + const voucher: Voucher = this.getVoucher(); + this.ser.saveOrUpdate(voucher) .subscribe( (result) => { - this.loadVoucher(result); this.toaster.show('Success', ''); + if (voucher.id === result.id) { + this.loadVoucher(result); + } else { this.router.navigate(['/receipt', result.id]); + } }, (error) => { this.toaster.show('Danger', error); diff --git a/setup.py b/setup.py index 7a64acee..f28b0be7 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ with open(os.path.join(here, 'requirements.txt'), "r") as r: requires = r.read().splitlines() setup(name='brewman', - version='7.0.1', + version='7.0.2', description='brewman', long_description=README + '\n\n' + CHANGES, classifiers=[