@hed-hog/finance 0.0.239 → 0.0.244

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.
Files changed (34) hide show
  1. package/README.md +1 -22
  2. package/dist/finance-installments.controller.d.ts +132 -0
  3. package/dist/finance-installments.controller.d.ts.map +1 -1
  4. package/dist/finance-installments.controller.js +52 -0
  5. package/dist/finance-installments.controller.js.map +1 -1
  6. package/dist/finance-statements.controller.d.ts +8 -0
  7. package/dist/finance-statements.controller.d.ts.map +1 -1
  8. package/dist/finance-statements.controller.js +40 -0
  9. package/dist/finance-statements.controller.js.map +1 -1
  10. package/dist/finance.module.d.ts.map +1 -1
  11. package/dist/finance.module.js +1 -0
  12. package/dist/finance.module.js.map +1 -1
  13. package/dist/finance.service.d.ts +160 -2
  14. package/dist/finance.service.d.ts.map +1 -1
  15. package/dist/finance.service.js +626 -8
  16. package/dist/finance.service.js.map +1 -1
  17. package/hedhog/data/route.yaml +54 -0
  18. package/hedhog/frontend/app/accounts-payable/installments/[id]/page.tsx.ejs +80 -4
  19. package/hedhog/frontend/app/accounts-payable/installments/page.tsx.ejs +736 -13
  20. package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +1 -1
  21. package/hedhog/frontend/app/accounts-receivable/installments/page.tsx.ejs +1 -3
  22. package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +212 -60
  23. package/hedhog/frontend/messages/en.json +1 -0
  24. package/hedhog/frontend/messages/pt.json +1 -0
  25. package/hedhog/query/constraints.sql +86 -0
  26. package/hedhog/table/bank_account.yaml +0 -8
  27. package/hedhog/table/financial_title.yaml +1 -9
  28. package/hedhog/table/settlement.yaml +0 -8
  29. package/package.json +6 -6
  30. package/src/finance-installments.controller.ts +70 -10
  31. package/src/finance-statements.controller.ts +61 -2
  32. package/src/finance.module.ts +2 -1
  33. package/src/finance.service.ts +868 -12
  34. package/hedhog/table/branch.yaml +0 -18
@@ -1,5 +1,18 @@
1
- import { Role } from '@hed-hog/api';
2
- import { Controller, Get, Query } from '@nestjs/common';
1
+ import { Role, User } from '@hed-hog/api';
2
+ import { Locale } from '@hed-hog/api-locale';
3
+ import {
4
+ BadRequestException,
5
+ Body,
6
+ Controller,
7
+ Get,
8
+ Post,
9
+ Query,
10
+ Res,
11
+ UploadedFile,
12
+ UseInterceptors,
13
+ } from '@nestjs/common';
14
+ import { FileInterceptor } from '@nestjs/platform-express';
15
+ import { Response } from 'express';
3
16
  import { FinanceService } from './finance.service';
4
17
 
5
18
  @Role()
@@ -17,4 +30,50 @@ export class FinanceStatementsController {
17
30
  Number.isNaN(parsedBankAccountId) ? undefined : parsedBankAccountId,
18
31
  );
19
32
  }
33
+
34
+ @Get('statements/export')
35
+ async exportBankStatementsCsv(
36
+ @Query('bank_account_id') bankAccountId: string,
37
+ @Res({ passthrough: true }) response: Response,
38
+ ) {
39
+ const parsedBankAccountId = Number.parseInt(bankAccountId, 10);
40
+
41
+ if (Number.isNaN(parsedBankAccountId) || parsedBankAccountId <= 0) {
42
+ throw new BadRequestException('bank_account_id is required');
43
+ }
44
+
45
+ const { csv, fileName } = await this.financeService.exportBankStatementsCsv(
46
+ parsedBankAccountId,
47
+ );
48
+
49
+ response.setHeader('Content-Type', 'text/csv; charset=utf-8');
50
+ response.setHeader(
51
+ 'Content-Disposition',
52
+ `attachment; filename="${fileName}"`,
53
+ );
54
+
55
+ return csv;
56
+ }
57
+
58
+ @Post('statements/import')
59
+ @UseInterceptors(FileInterceptor('file'))
60
+ async importBankStatements(
61
+ @UploadedFile() file: MulterFile,
62
+ @Body('bank_account_id') bankAccountId: string,
63
+ @Locale() locale: string,
64
+ @User() user,
65
+ ) {
66
+ const parsedBankAccountId = Number.parseInt(bankAccountId, 10);
67
+
68
+ if (Number.isNaN(parsedBankAccountId) || parsedBankAccountId <= 0) {
69
+ throw new BadRequestException('bank_account_id is required');
70
+ }
71
+
72
+ return this.financeService.importBankStatements(
73
+ parsedBankAccountId,
74
+ file,
75
+ locale,
76
+ user?.id,
77
+ );
78
+ }
20
79
  }
@@ -1,7 +1,7 @@
1
1
  import { LocaleModule } from '@hed-hog/api-locale';
2
2
  import { PaginationModule } from '@hed-hog/api-pagination';
3
3
  import { PrismaModule } from '@hed-hog/api-prisma';
4
- import { AiModule } from '@hed-hog/core';
4
+ import { AiModule, FileModule } from '@hed-hog/core';
5
5
  import { forwardRef, Module } from '@nestjs/common';
6
6
  import { ConfigModule } from '@nestjs/config';
7
7
  import { FinanceAuditLogsController } from './finance-audit-logs.controller';
@@ -21,6 +21,7 @@ import { FinanceService } from './finance.service';
21
21
  forwardRef(() => PrismaModule),
22
22
  forwardRef(() => LocaleModule),
23
23
  forwardRef(() => AiModule),
24
+ forwardRef(() => FileModule),
24
25
  ],
25
26
  controllers: [
26
27
  FinanceAuditLogsController,