report creation improvements (#314)

This commit is contained in:
Denis Ezhov 2020-11-13 14:21:52 +03:00 committed by GitHub
parent 4c0615acd1
commit 46f1973409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import moment from 'moment';
import { BehaviorSubject, of, Subject } from 'rxjs';
import { catchError, filter, map, switchMap, tap } from 'rxjs/operators';
@ -6,8 +7,12 @@ import { ReportsService } from '../../../../api';
import { Payout } from '../../../../api-codegen/anapi';
import { CreateReportReq } from '../../../../api/reports/create-reports';
const daterangeReducer = (_, { fromTime, toTime }) => ({ fromTime, toTime } as any);
const toCreateReportParams = ({ shopID, payoutSummary }: Payout): CreateReportReq => ({
const daterangeReducer = (_, { fromTime, toTime }) =>
({
fromTime,
toTime: moment(toTime).add(1, 'ms').utc().format('YYYY-MM-DDTHH:mm:ss.SSSS[Z]'),
} as any);
export const toCreateReportParams = ({ shopID, payoutSummary }: Payout): CreateReportReq => ({
...payoutSummary.reduce(daterangeReducer, null),
shopID,
});

View File

@ -23,8 +23,8 @@ export class CreateReportDialogComponent implements OnInit {
form = this.fb.group({
fromDate: [moment().startOf('month').format(), Validators.required],
fromTime: ['00:00:00', Validators.pattern(timePattern)],
toDate: [moment().endOf('month').format(), Validators.required],
toTime: ['23:59:59', Validators.pattern(timePattern)],
toDate: [moment().endOf('month').add(1).format(), Validators.required],
toTime: ['00:00:00', Validators.pattern(timePattern)],
shopID: null,
});

View File

@ -25,7 +25,7 @@
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>{{ t('time') }}</mat-label>
<input required dshFormatTimeInput formControlName="toTime" matInput placeholder="23:59:59" />
<input required dshFormatTimeInput formControlName="toTime" matInput placeholder="00:00:00" />
</mat-form-field>
</div>
<mat-form-field fxFill>