@hed-hog/finance 0.0.318 → 0.0.319
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dto/create-bank-account.dto.d.ts +1 -0
- package/dist/dto/create-bank-account.dto.d.ts.map +1 -1
- package/dist/dto/create-bank-account.dto.js +7 -0
- package/dist/dto/create-bank-account.dto.js.map +1 -1
- package/dist/dto/create-bank-statement-entry.dto.d.ts +8 -0
- package/dist/dto/create-bank-statement-entry.dto.d.ts.map +1 -0
- package/dist/dto/create-bank-statement-entry.dto.js +54 -0
- package/dist/dto/create-bank-statement-entry.dto.js.map +1 -0
- package/dist/dto/update-bank-account.dto.d.ts +1 -0
- package/dist/dto/update-bank-account.dto.d.ts.map +1 -1
- package/dist/dto/update-bank-account.dto.js +7 -0
- package/dist/dto/update-bank-account.dto.js.map +1 -1
- package/dist/dto/update-bank-statement-entry.dto.d.ts +6 -0
- package/dist/dto/update-bank-statement-entry.dto.d.ts.map +1 -0
- package/dist/dto/update-bank-statement-entry.dto.js +42 -0
- package/dist/dto/update-bank-statement-entry.dto.js.map +1 -0
- package/dist/finance-bank-accounts.controller.d.ts +25 -13
- package/dist/finance-bank-accounts.controller.d.ts.map +1 -1
- package/dist/finance-bank-accounts.controller.js +5 -3
- package/dist/finance-bank-accounts.controller.js.map +1 -1
- package/dist/finance-data.controller.d.ts +4 -0
- package/dist/finance-data.controller.d.ts.map +1 -1
- package/dist/finance-installments.controller.d.ts +3 -2
- package/dist/finance-installments.controller.d.ts.map +1 -1
- package/dist/finance-installments.controller.js +10 -6
- package/dist/finance-installments.controller.js.map +1 -1
- package/dist/finance-statements.controller.d.ts +61 -12
- package/dist/finance-statements.controller.d.ts.map +1 -1
- package/dist/finance-statements.controller.js +50 -8
- package/dist/finance-statements.controller.js.map +1 -1
- package/dist/finance-transfers.controller.d.ts +13 -8
- package/dist/finance-transfers.controller.d.ts.map +1 -1
- package/dist/finance-transfers.controller.js +11 -5
- package/dist/finance-transfers.controller.js.map +1 -1
- package/dist/finance.service.d.ts +124 -35
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +389 -55
- package/dist/finance.service.js.map +1 -1
- package/hedhog/data/role.yaml +9 -1
- package/hedhog/data/route.yaml +42 -0
- package/hedhog/frontend/app/accounts-payable/approvals/page.tsx.ejs +87 -72
- package/hedhog/frontend/app/accounts-payable/installments/page.tsx.ejs +53 -25
- package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +8 -0
- package/hedhog/frontend/app/accounts-receivable/installments/page.tsx.ejs +60 -24
- package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +114 -31
- package/hedhog/frontend/app/cash-and-banks/bank-reconciliation/page.tsx.ejs +25 -3
- package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +732 -61
- package/hedhog/frontend/app/cash-and-banks/transfers/page.tsx.ejs +101 -15
- package/hedhog/table/bank_statement_line.yaml +1 -1
- package/hedhog/table/cashflow_projection.yaml +1 -1
- package/hedhog/table/financial_installment.yaml +2 -2
- package/hedhog/table/financial_title.yaml +1 -1
- package/hedhog/table/installment_allocation.yaml +1 -1
- package/hedhog/table/receivable_schedule.yaml +1 -1
- package/hedhog/table/settlement.yaml +1 -1
- package/hedhog/table/settlement_allocation.yaml +5 -5
- package/package.json +7 -7
- package/src/dto/create-bank-account.dto.ts +18 -1
- package/src/dto/create-bank-statement-entry.dto.ts +50 -0
- package/src/dto/update-bank-account.dto.ts +11 -1
- package/src/dto/update-bank-statement-entry.dto.ts +31 -0
- package/src/finance-bank-accounts.controller.ts +3 -2
- package/src/finance-installments.controller.ts +9 -3
- package/src/finance-statements.controller.ts +40 -0
- package/src/finance-transfers.controller.ts +7 -1
- package/src/finance.service.ts +543 -61
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { FinancePageSection } from '@/app/(app)/(libraries)/finance/_components/finance-layout';
|
|
4
|
-
import { Page, PageHeader } from '@/components/entity-list';
|
|
4
|
+
import { Page, PageHeader, PaginationFooter } from '@/components/entity-list';
|
|
5
5
|
import { Button } from '@/components/ui/button';
|
|
6
|
+
import { DateRangePicker } from '@/components/ui/date-range-picker';
|
|
6
7
|
import { FilterBar } from '@/components/ui/filter-bar';
|
|
7
8
|
import {
|
|
8
9
|
Form,
|
|
@@ -68,6 +69,19 @@ type Transfer = {
|
|
|
68
69
|
descricao: string;
|
|
69
70
|
};
|
|
70
71
|
|
|
72
|
+
type PaginatedTransfersResponse = {
|
|
73
|
+
data: Transfer[];
|
|
74
|
+
total: number;
|
|
75
|
+
page: number;
|
|
76
|
+
pageSize: number;
|
|
77
|
+
prev: number | null;
|
|
78
|
+
next: number | null;
|
|
79
|
+
lastPage: number;
|
|
80
|
+
summary?: {
|
|
81
|
+
totalTransferido?: number;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
71
85
|
type TransferDraftPayload = {
|
|
72
86
|
values: TransferFormValues;
|
|
73
87
|
};
|
|
@@ -244,7 +258,7 @@ function NovaTransferenciaSheet({
|
|
|
244
258
|
<FormLabel>{t('fields.sourceAccount')}</FormLabel>
|
|
245
259
|
<Select value={field.value} onValueChange={field.onChange}>
|
|
246
260
|
<FormControl>
|
|
247
|
-
<SelectTrigger>
|
|
261
|
+
<SelectTrigger className="w-full">
|
|
248
262
|
<SelectValue placeholder={t('common.select')} />
|
|
249
263
|
</SelectTrigger>
|
|
250
264
|
</FormControl>
|
|
@@ -269,7 +283,7 @@ function NovaTransferenciaSheet({
|
|
|
269
283
|
<FormLabel>{t('fields.destinationAccount')}</FormLabel>
|
|
270
284
|
<Select value={field.value} onValueChange={field.onChange}>
|
|
271
285
|
<FormControl>
|
|
272
|
-
<SelectTrigger>
|
|
286
|
+
<SelectTrigger className="w-full">
|
|
273
287
|
<SelectValue placeholder={t('common.select')} />
|
|
274
288
|
</SelectTrigger>
|
|
275
289
|
</FormControl>
|
|
@@ -373,6 +387,10 @@ export default function TransferenciasPage() {
|
|
|
373
387
|
const [search, setSearch] = useState('');
|
|
374
388
|
const [debouncedSearch, setDebouncedSearch] = useState('');
|
|
375
389
|
const [accountFilter, setAccountFilter] = useState('all');
|
|
390
|
+
const [fromDate, setFromDate] = useState('');
|
|
391
|
+
const [toDate, setToDate] = useState('');
|
|
392
|
+
const [page, setPage] = useState(1);
|
|
393
|
+
const pageSize = 10;
|
|
376
394
|
|
|
377
395
|
useEffect(() => {
|
|
378
396
|
const timeoutId = window.setTimeout(() => {
|
|
@@ -391,48 +409,98 @@ export default function TransferenciasPage() {
|
|
|
391
409
|
const response = await request({
|
|
392
410
|
url: '/finance/bank-accounts',
|
|
393
411
|
method: 'GET',
|
|
412
|
+
params: {
|
|
413
|
+
page: 1,
|
|
414
|
+
pageSize: 100,
|
|
415
|
+
},
|
|
394
416
|
});
|
|
395
417
|
|
|
396
|
-
|
|
418
|
+
const payload = response?.data as
|
|
419
|
+
| { data?: BankAccount[] }
|
|
420
|
+
| BankAccount[]
|
|
421
|
+
| undefined;
|
|
422
|
+
|
|
423
|
+
return (
|
|
424
|
+
Array.isArray(payload) ? payload : payload?.data || []
|
|
425
|
+
) as BankAccount[];
|
|
397
426
|
},
|
|
398
427
|
});
|
|
399
428
|
|
|
400
|
-
const { data:
|
|
401
|
-
useQuery<
|
|
402
|
-
queryKey: [
|
|
429
|
+
const { data: transferenciasResponse, refetch: refetchTransferencias } =
|
|
430
|
+
useQuery<PaginatedTransfersResponse>({
|
|
431
|
+
queryKey: [
|
|
432
|
+
'finance-transfers',
|
|
433
|
+
debouncedSearch,
|
|
434
|
+
accountFilter,
|
|
435
|
+
fromDate,
|
|
436
|
+
toDate,
|
|
437
|
+
page,
|
|
438
|
+
pageSize,
|
|
439
|
+
],
|
|
403
440
|
queryFn: async () => {
|
|
404
|
-
const params =
|
|
441
|
+
const params: Record<string, string | number> = {
|
|
442
|
+
page,
|
|
443
|
+
pageSize,
|
|
444
|
+
};
|
|
405
445
|
|
|
406
446
|
const trimmedSearch = debouncedSearch.trim();
|
|
407
447
|
if (trimmedSearch) {
|
|
408
|
-
params.
|
|
448
|
+
params.search = trimmedSearch;
|
|
409
449
|
}
|
|
410
450
|
|
|
411
451
|
if (accountFilter !== 'all') {
|
|
412
|
-
params.
|
|
452
|
+
params.bank_account_id = accountFilter;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (fromDate) {
|
|
456
|
+
params.from = fromDate;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if (toDate) {
|
|
460
|
+
params.to = toDate;
|
|
413
461
|
}
|
|
414
462
|
|
|
415
|
-
const query = params.toString();
|
|
416
463
|
const response = await request({
|
|
417
|
-
url:
|
|
464
|
+
url: '/finance/transfers',
|
|
418
465
|
method: 'GET',
|
|
466
|
+
params,
|
|
419
467
|
});
|
|
420
468
|
|
|
421
|
-
return (response?.data ||
|
|
469
|
+
return (response?.data || {
|
|
470
|
+
data: [],
|
|
471
|
+
total: 0,
|
|
472
|
+
page,
|
|
473
|
+
pageSize,
|
|
474
|
+
prev: null,
|
|
475
|
+
next: null,
|
|
476
|
+
lastPage: 1,
|
|
477
|
+
summary: {
|
|
478
|
+
totalTransferido: 0,
|
|
479
|
+
},
|
|
480
|
+
}) as PaginatedTransfersResponse;
|
|
422
481
|
},
|
|
482
|
+
placeholderData: (old) => old,
|
|
423
483
|
});
|
|
424
484
|
|
|
485
|
+
useEffect(() => {
|
|
486
|
+
setPage(1);
|
|
487
|
+
}, [debouncedSearch, accountFilter, fromDate, toDate]);
|
|
488
|
+
|
|
425
489
|
const handleTransferCreated = async () => {
|
|
426
490
|
await Promise.all([refetchTransferencias(), refetchContasBancarias()]);
|
|
427
491
|
};
|
|
428
492
|
|
|
429
|
-
const
|
|
493
|
+
const transferencias = transferenciasResponse?.data ?? [];
|
|
494
|
+
const totalTransferencias = transferenciasResponse?.total ?? 0;
|
|
495
|
+
const totalTransferido =
|
|
496
|
+
transferenciasResponse?.summary?.totalTransferido ??
|
|
497
|
+
transferencias.reduce((acc, transfer) => acc + transfer.valor, 0);
|
|
430
498
|
const summaryCards = [
|
|
431
499
|
{
|
|
432
500
|
key: 'transferred',
|
|
433
501
|
title: t('cards.totalTransferred'),
|
|
434
502
|
value: <Money value={totalTransferido} />,
|
|
435
|
-
description: t('cards.transferCount', { count:
|
|
503
|
+
description: t('cards.transferCount', { count: totalTransferencias }),
|
|
436
504
|
icon: ArrowRight,
|
|
437
505
|
layout: 'compact' as const,
|
|
438
506
|
iconContainerClassName: 'bg-blue-500/10 text-blue-700',
|
|
@@ -488,6 +556,14 @@ export default function TransferenciasPage() {
|
|
|
488
556
|
onSearchChange={setSearch}
|
|
489
557
|
/>
|
|
490
558
|
</div>
|
|
559
|
+
|
|
560
|
+
<DateRangePicker
|
|
561
|
+
fromDate={fromDate}
|
|
562
|
+
toDate={toDate}
|
|
563
|
+
onFromDateChange={setFromDate}
|
|
564
|
+
onToDateChange={setToDate}
|
|
565
|
+
defaultPreset="thisMonth"
|
|
566
|
+
/>
|
|
491
567
|
</div>
|
|
492
568
|
|
|
493
569
|
<KpiCardsGrid items={summaryCards} columns={2} />
|
|
@@ -550,6 +626,16 @@ export default function TransferenciasPage() {
|
|
|
550
626
|
</TableBody>
|
|
551
627
|
</Table>
|
|
552
628
|
</div>
|
|
629
|
+
<div className="border-t border-border/50 px-4 py-4 sm:px-6">
|
|
630
|
+
<PaginationFooter
|
|
631
|
+
currentPage={page}
|
|
632
|
+
pageSize={pageSize}
|
|
633
|
+
totalItems={totalTransferencias}
|
|
634
|
+
onPageChange={setPage}
|
|
635
|
+
onPageSizeChange={() => undefined}
|
|
636
|
+
pageSizeOptions={[10]}
|
|
637
|
+
/>
|
|
638
|
+
</div>
|
|
553
639
|
</FinancePageSection>
|
|
554
640
|
</Page>
|
|
555
641
|
);
|
|
@@ -15,18 +15,18 @@ columns:
|
|
|
15
15
|
onDelete: RESTRICT
|
|
16
16
|
onUpdate: CASCADE
|
|
17
17
|
- name: allocated_amount_cents
|
|
18
|
-
type:
|
|
18
|
+
type: bigint
|
|
19
19
|
- name: amount_cents
|
|
20
|
-
type:
|
|
20
|
+
type: bigint
|
|
21
21
|
isNullable: true
|
|
22
22
|
- name: discount_cents
|
|
23
|
-
type:
|
|
23
|
+
type: bigint
|
|
24
24
|
default: 0
|
|
25
25
|
- name: interest_cents
|
|
26
|
-
type:
|
|
26
|
+
type: bigint
|
|
27
27
|
default: 0
|
|
28
28
|
- name: penalty_cents
|
|
29
|
-
type:
|
|
29
|
+
type: bigint
|
|
30
30
|
default: 0
|
|
31
31
|
- type: created_at
|
|
32
32
|
- type: updated_at
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hed-hog/finance",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.319",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"@nestjs/core": "^11",
|
|
10
10
|
"@nestjs/jwt": "^11",
|
|
11
11
|
"@nestjs/mapped-types": "*",
|
|
12
|
-
"@hed-hog/
|
|
13
|
-
"@hed-hog/api-locale": "0.0.14",
|
|
14
|
-
"@hed-hog/tag": "0.0.318",
|
|
12
|
+
"@hed-hog/api": "0.0.8",
|
|
15
13
|
"@hed-hog/api-prisma": "0.0.6",
|
|
14
|
+
"@hed-hog/contact": "0.0.319",
|
|
15
|
+
"@hed-hog/api-locale": "0.0.14",
|
|
16
|
+
"@hed-hog/tag": "0.0.319",
|
|
16
17
|
"@hed-hog/api-pagination": "0.0.7",
|
|
17
|
-
"@hed-hog/
|
|
18
|
-
"@hed-hog/api-types": "0.0.1"
|
|
19
|
-
"@hed-hog/core": "0.0.318"
|
|
18
|
+
"@hed-hog/core": "0.0.319",
|
|
19
|
+
"@hed-hog/api-types": "0.0.1"
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
IsDateString,
|
|
4
|
+
IsInt,
|
|
5
|
+
IsNumber,
|
|
6
|
+
IsOptional,
|
|
7
|
+
IsString,
|
|
8
|
+
Min,
|
|
9
|
+
} from 'class-validator';
|
|
3
10
|
|
|
4
11
|
export class CreateBankAccountDto {
|
|
5
12
|
@IsString({
|
|
@@ -52,4 +59,14 @@ export class CreateBankAccountDto {
|
|
|
52
59
|
message: (args) => getLocaleText('validation.initialBalanceMin', args.value),
|
|
53
60
|
})
|
|
54
61
|
initial_balance?: number;
|
|
62
|
+
|
|
63
|
+
@IsOptional()
|
|
64
|
+
@IsDateString(
|
|
65
|
+
{},
|
|
66
|
+
{
|
|
67
|
+
message: (args) =>
|
|
68
|
+
getLocaleText('validation.dateMustBeDateString', args.value),
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
start_date?: string;
|
|
55
72
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import {
|
|
3
|
+
IsDateString,
|
|
4
|
+
IsIn,
|
|
5
|
+
IsInt,
|
|
6
|
+
IsNumber,
|
|
7
|
+
IsString,
|
|
8
|
+
Min,
|
|
9
|
+
} from 'class-validator';
|
|
10
|
+
|
|
11
|
+
export class CreateBankStatementEntryDto {
|
|
12
|
+
@IsInt({
|
|
13
|
+
message: (args) => getLocaleText('validation.idMustBeInteger', args.value),
|
|
14
|
+
})
|
|
15
|
+
bank_account_id: number;
|
|
16
|
+
|
|
17
|
+
@IsDateString(
|
|
18
|
+
{},
|
|
19
|
+
{
|
|
20
|
+
message: (args) =>
|
|
21
|
+
getLocaleText('validation.dateMustBeDateString', args.value),
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
date: string;
|
|
25
|
+
|
|
26
|
+
@IsString({
|
|
27
|
+
message: (args) =>
|
|
28
|
+
getLocaleText('validation.descriptionMustBeString', args.value),
|
|
29
|
+
})
|
|
30
|
+
description: string;
|
|
31
|
+
|
|
32
|
+
@IsNumber(
|
|
33
|
+
{},
|
|
34
|
+
{
|
|
35
|
+
message: (args) => getLocaleText('validation.amountMustBeNumber', args.value),
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
@Min(0.01, {
|
|
39
|
+
message: (args) => getLocaleText('validation.amountGreaterThanZero', args.value),
|
|
40
|
+
})
|
|
41
|
+
amount: number;
|
|
42
|
+
|
|
43
|
+
@IsString({
|
|
44
|
+
message: (args) => getLocaleText('validation.typeMustBeString', args.value),
|
|
45
|
+
})
|
|
46
|
+
@IsIn(['entrada', 'saida'], {
|
|
47
|
+
message: (args) => getLocaleText('validation.typeIsNotValid', args.value),
|
|
48
|
+
})
|
|
49
|
+
type: 'entrada' | 'saida';
|
|
50
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
-
import { IsInt, IsOptional, IsString } from 'class-validator';
|
|
2
|
+
import { IsDateString, IsInt, IsOptional, IsString } from 'class-validator';
|
|
3
3
|
|
|
4
4
|
export class UpdateBankAccountDto {
|
|
5
5
|
@IsOptional()
|
|
@@ -48,4 +48,14 @@ export class UpdateBankAccountDto {
|
|
|
48
48
|
getLocaleText('validation.statusMustBeString', args.value),
|
|
49
49
|
})
|
|
50
50
|
status?: 'active' | 'inactive';
|
|
51
|
+
|
|
52
|
+
@IsOptional()
|
|
53
|
+
@IsDateString(
|
|
54
|
+
{},
|
|
55
|
+
{
|
|
56
|
+
message: (args) =>
|
|
57
|
+
getLocaleText('validation.dateMustBeDateString', args.value),
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
start_date?: string;
|
|
51
61
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import { IsDateString, IsNumber, IsOptional, IsString, Min } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class UpdateBankStatementEntryDto {
|
|
5
|
+
@IsOptional()
|
|
6
|
+
@IsNumber(
|
|
7
|
+
{},
|
|
8
|
+
{
|
|
9
|
+
message: (args) => getLocaleText('validation.amountMustBeNumber', args.value),
|
|
10
|
+
},
|
|
11
|
+
)
|
|
12
|
+
@Min(0.01, {
|
|
13
|
+
message: (args) => getLocaleText('validation.amountGreaterThanZero', args.value),
|
|
14
|
+
})
|
|
15
|
+
amount?: number;
|
|
16
|
+
|
|
17
|
+
@IsOptional()
|
|
18
|
+
@IsString({
|
|
19
|
+
message: (args) => getLocaleText('validation.descriptionMustBeString', args.value),
|
|
20
|
+
})
|
|
21
|
+
description?: string;
|
|
22
|
+
|
|
23
|
+
@IsOptional()
|
|
24
|
+
@IsDateString(
|
|
25
|
+
{},
|
|
26
|
+
{
|
|
27
|
+
message: (args) => getLocaleText('validation.dateMustBeDateString', args.value),
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
date?: string;
|
|
31
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Role, User } from '@hed-hog/api';
|
|
2
|
+
import { Pagination, PaginationDTO } from '@hed-hog/api-pagination';
|
|
2
3
|
import {
|
|
3
4
|
Body,
|
|
4
5
|
Controller,
|
|
@@ -19,8 +20,8 @@ export class FinanceBankAccountsController {
|
|
|
19
20
|
constructor(private readonly financeService: FinanceService) {}
|
|
20
21
|
|
|
21
22
|
@Get('bank-accounts')
|
|
22
|
-
async listBankAccounts() {
|
|
23
|
-
return this.financeService.listBankAccounts();
|
|
23
|
+
async listBankAccounts(@Pagination() paginationParams: PaginationDTO) {
|
|
24
|
+
return this.financeService.listBankAccounts(paginationParams);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
@Post('bank-accounts')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Role, User } from '@hed-hog/api';
|
|
2
2
|
import { Locale } from '@hed-hog/api-locale';
|
|
3
|
-
import { Pagination } from '@hed-hog/api-pagination';
|
|
3
|
+
import { Pagination, PaginationDTO } from '@hed-hog/api-pagination';
|
|
4
4
|
import {
|
|
5
5
|
Body,
|
|
6
6
|
Controller,
|
|
@@ -30,12 +30,15 @@ export class FinanceInstallmentsController {
|
|
|
30
30
|
|
|
31
31
|
@Get('accounts-payable/installments')
|
|
32
32
|
async listAccountsPayableInstallments(
|
|
33
|
-
@Pagination() paginationParams,
|
|
33
|
+
@Pagination() paginationParams: PaginationDTO,
|
|
34
34
|
@Query('status') status?: string,
|
|
35
|
+
@Query('from') from?: string,
|
|
36
|
+
@Query('to') to?: string,
|
|
35
37
|
) {
|
|
36
38
|
return this.financeService.listAccountsPayableInstallments(
|
|
37
39
|
paginationParams,
|
|
38
40
|
status,
|
|
41
|
+
{ from, to },
|
|
39
42
|
);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -201,12 +204,15 @@ export class FinanceInstallmentsController {
|
|
|
201
204
|
|
|
202
205
|
@Get('accounts-receivable/installments')
|
|
203
206
|
async listAccountsReceivableInstallments(
|
|
204
|
-
@Pagination() paginationParams,
|
|
207
|
+
@Pagination() paginationParams: PaginationDTO,
|
|
205
208
|
@Query('status') status?: string,
|
|
209
|
+
@Query('from') from?: string,
|
|
210
|
+
@Query('to') to?: string,
|
|
206
211
|
) {
|
|
207
212
|
return this.financeService.listAccountsReceivableInstallments(
|
|
208
213
|
paginationParams,
|
|
209
214
|
status,
|
|
215
|
+
{ from, to },
|
|
210
216
|
);
|
|
211
217
|
}
|
|
212
218
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { Role, User } from '@hed-hog/api';
|
|
2
2
|
import { Locale } from '@hed-hog/api-locale';
|
|
3
|
+
import { Pagination, PaginationDTO } from '@hed-hog/api-pagination';
|
|
3
4
|
import {
|
|
4
5
|
BadRequestException,
|
|
5
6
|
Body,
|
|
6
7
|
Controller,
|
|
8
|
+
Delete,
|
|
7
9
|
Get,
|
|
10
|
+
Param,
|
|
11
|
+
ParseIntPipe,
|
|
12
|
+
Patch,
|
|
8
13
|
Post,
|
|
9
14
|
Query,
|
|
10
15
|
Res,
|
|
@@ -15,6 +20,8 @@ import { FileInterceptor } from '@nestjs/platform-express';
|
|
|
15
20
|
import { Response } from 'express';
|
|
16
21
|
import { CreateBankReconciliationDto } from './dto/create-bank-reconciliation.dto';
|
|
17
22
|
import { CreateBankStatementAdjustmentDto } from './dto/create-bank-statement-adjustment.dto';
|
|
23
|
+
import { CreateBankStatementEntryDto } from './dto/create-bank-statement-entry.dto';
|
|
24
|
+
import { UpdateBankStatementEntryDto } from './dto/update-bank-statement-entry.dto';
|
|
18
25
|
import { FinanceService } from './finance.service';
|
|
19
26
|
|
|
20
27
|
@Role()
|
|
@@ -24,16 +31,21 @@ export class FinanceStatementsController {
|
|
|
24
31
|
|
|
25
32
|
@Get('statements')
|
|
26
33
|
async listBankStatements(
|
|
34
|
+
@Pagination() paginationParams: PaginationDTO,
|
|
27
35
|
@Query('bank_account_id') bankAccountId?: string,
|
|
28
36
|
@Query('search') search?: string,
|
|
37
|
+
@Query('from') from?: string,
|
|
38
|
+
@Query('to') to?: string,
|
|
29
39
|
) {
|
|
30
40
|
const parsedBankAccountId = bankAccountId
|
|
31
41
|
? Number.parseInt(bankAccountId, 10)
|
|
32
42
|
: undefined;
|
|
33
43
|
|
|
34
44
|
return this.financeService.listBankStatements(
|
|
45
|
+
paginationParams,
|
|
35
46
|
Number.isNaN(parsedBankAccountId) ? undefined : parsedBankAccountId,
|
|
36
47
|
search,
|
|
48
|
+
{ from, to },
|
|
37
49
|
);
|
|
38
50
|
}
|
|
39
51
|
|
|
@@ -68,6 +80,8 @@ export class FinanceStatementsController {
|
|
|
68
80
|
@Query('bank_account_id') bankAccountId: string,
|
|
69
81
|
@Res({ passthrough: true }) response: Response,
|
|
70
82
|
@Query('search') search?: string,
|
|
83
|
+
@Query('from') from?: string,
|
|
84
|
+
@Query('to') to?: string,
|
|
71
85
|
) {
|
|
72
86
|
const parsedBankAccountId = Number.parseInt(bankAccountId, 10);
|
|
73
87
|
|
|
@@ -78,6 +92,7 @@ export class FinanceStatementsController {
|
|
|
78
92
|
const { csv, fileName } = await this.financeService.exportBankStatementsCsv(
|
|
79
93
|
parsedBankAccountId,
|
|
80
94
|
search,
|
|
95
|
+
{ from, to },
|
|
81
96
|
);
|
|
82
97
|
|
|
83
98
|
response.setHeader('Content-Type', 'text/csv; charset=utf-8');
|
|
@@ -118,4 +133,29 @@ export class FinanceStatementsController {
|
|
|
118
133
|
) {
|
|
119
134
|
return this.financeService.createBankStatementAdjustment(data, user?.id);
|
|
120
135
|
}
|
|
136
|
+
|
|
137
|
+
@Post('statements')
|
|
138
|
+
async createBankStatementEntry(
|
|
139
|
+
@Body() data: CreateBankStatementEntryDto,
|
|
140
|
+
@User() user,
|
|
141
|
+
) {
|
|
142
|
+
return this.financeService.createBankStatementEntry(data, user?.id);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Patch('statements/:id')
|
|
146
|
+
async updateBankStatementEntry(
|
|
147
|
+
@Param('id', ParseIntPipe) id: number,
|
|
148
|
+
@Body() data: UpdateBankStatementEntryDto,
|
|
149
|
+
@User() user,
|
|
150
|
+
) {
|
|
151
|
+
return this.financeService.updateBankStatementEntry(id, data, user?.id);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@Delete('statements/:id')
|
|
155
|
+
async deleteBankStatementEntry(
|
|
156
|
+
@Param('id', ParseIntPipe) id: number,
|
|
157
|
+
@User() user,
|
|
158
|
+
) {
|
|
159
|
+
return this.financeService.deleteBankStatementEntry(id, user?.id);
|
|
160
|
+
}
|
|
121
161
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Role, User } from '@hed-hog/api';
|
|
2
|
+
import { Pagination, PaginationDTO } from '@hed-hog/api-pagination';
|
|
2
3
|
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
|
3
4
|
import { CreateTransferDto } from './dto/create-transfer.dto';
|
|
4
5
|
import { FinanceService } from './finance.service';
|
|
@@ -10,12 +11,17 @@ export class FinanceTransfersController {
|
|
|
10
11
|
|
|
11
12
|
@Get('transfers')
|
|
12
13
|
async listTransfers(
|
|
14
|
+
@Pagination() paginationParams: PaginationDTO,
|
|
13
15
|
@Query('search') search?: string,
|
|
14
16
|
@Query('bank_account_id') bankAccountId?: string,
|
|
17
|
+
@Query('from') from?: string,
|
|
18
|
+
@Query('to') to?: string,
|
|
15
19
|
) {
|
|
16
|
-
return this.financeService.listTransfers({
|
|
20
|
+
return this.financeService.listTransfers(paginationParams, {
|
|
17
21
|
search,
|
|
18
22
|
bank_account_id: bankAccountId,
|
|
23
|
+
from,
|
|
24
|
+
to,
|
|
19
25
|
});
|
|
20
26
|
}
|
|
21
27
|
|