Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 1x 1x 1x 1x 1x 1x 1x 142x 148x 148x 148x 148x 148x 148x 148x 148x 148x 148x 148x 148x 148x 148x 72x 72x 72x 70x 70x 70x 74x 6x | import { dayjs } from '@amalia/ext/dayjs';
import { PeriodFrequencyEnum } from '@amalia/payout-definition/periods/types';
import { useCurrentCompany } from '../queries';
import { useCompanyCustomization } from './useCompanyCustomization';
export const useCompanyDefaultDate = ({
dateFormat = 'YYYY-MM-DD',
periodFrequency,
}: {
periodFrequency?: PeriodFrequencyEnum;
dateFormat?: string;
} = {}) => {
const {
data: { statementFrequency },
} = useCurrentCompany();
const { defaultPeriod } = useCompanyCustomization();
const frequency = periodFrequency ?? statementFrequency;
return defaultPeriod === 'current'
? dayjs()
.startOf(frequency === PeriodFrequencyEnum.quarter ? 'quarter' : 'month')
.format(dateFormat)
: dayjs()
.startOf(frequency === PeriodFrequencyEnum.quarter ? 'quarter' : 'month')
.subtract(1, frequency === PeriodFrequencyEnum.quarter ? 'quarter' : 'month')
.format(dateFormat);
};
|