@hed-hog/finance 0.0.319 → 0.0.321
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-currency.dto.d.ts +6 -0
- package/dist/dto/create-currency.dto.d.ts.map +1 -0
- package/dist/dto/create-currency.dto.js +37 -0
- package/dist/dto/create-currency.dto.js.map +1 -0
- package/dist/dto/update-currency.dto.d.ts +7 -0
- package/dist/dto/update-currency.dto.d.ts.map +1 -0
- package/dist/dto/update-currency.dto.js +47 -0
- package/dist/dto/update-currency.dto.js.map +1 -0
- package/dist/finance-currencies.controller.d.ts +36 -0
- package/dist/finance-currencies.controller.d.ts.map +1 -0
- package/dist/finance-currencies.controller.js +74 -0
- package/dist/finance-currencies.controller.js.map +1 -0
- package/dist/finance.module.d.ts.map +1 -1
- package/dist/finance.module.js +2 -0
- package/dist/finance.module.js.map +1 -1
- package/dist/finance.service.d.ts +29 -0
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +79 -0
- package/dist/finance.service.js.map +1 -1
- package/hedhog/data/currency.yaml +14 -0
- package/hedhog/data/menu.yaml +16 -0
- package/hedhog/data/route.yaml +36 -0
- package/hedhog/frontend/app/administration/currencies/page.tsx.ejs +490 -0
- package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +143 -48
- package/hedhog/frontend/messages/en.json +58 -0
- package/hedhog/frontend/messages/pt.json +58 -0
- package/hedhog/table/bank_account.yaml +8 -0
- package/hedhog/table/currency.yaml +21 -0
- package/package.json +6 -6
- package/src/dto/create-currency.dto.ts +21 -0
- package/src/dto/update-currency.dto.ts +31 -0
- package/src/finance-currencies.controller.ts +44 -0
- package/src/finance.module.ts +2 -0
- package/src/finance.service.ts +127 -31
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
CardHeader,
|
|
26
26
|
CardTitle,
|
|
27
27
|
} from '@/components/ui/card';
|
|
28
|
+
import { EntityPicker } from '@/components/ui/entity-picker';
|
|
28
29
|
import {
|
|
29
30
|
Form,
|
|
30
31
|
FormControl,
|
|
@@ -89,12 +90,21 @@ const bankAccountFormSchema = z.object({
|
|
|
89
90
|
tipo: z.string().min(1, 'Tipo é obrigatório'),
|
|
90
91
|
descricao: z.string().optional(),
|
|
91
92
|
logoFileId: z.number().int().nullable().optional(),
|
|
93
|
+
currencyId: z.number().int().nullable().optional(),
|
|
92
94
|
dataInicial: z.string().optional(),
|
|
93
95
|
saldoInicial: z.number().min(0, 'Saldo inicial inválido'),
|
|
94
96
|
});
|
|
95
97
|
|
|
96
98
|
type BankAccountFormValues = z.infer<typeof bankAccountFormSchema>;
|
|
97
99
|
|
|
100
|
+
type Currency = {
|
|
101
|
+
id: string;
|
|
102
|
+
code: string;
|
|
103
|
+
name: string;
|
|
104
|
+
symbol: string;
|
|
105
|
+
ativo: boolean;
|
|
106
|
+
};
|
|
107
|
+
|
|
98
108
|
type BankAccount = {
|
|
99
109
|
id: string;
|
|
100
110
|
codigo: string;
|
|
@@ -104,6 +114,8 @@ type BankAccount = {
|
|
|
104
114
|
conta: string;
|
|
105
115
|
tipo: 'corrente' | 'poupanca' | 'investimento' | 'caixa';
|
|
106
116
|
logoFileId: number | null;
|
|
117
|
+
currencyId: number | null;
|
|
118
|
+
currency: Currency | null;
|
|
107
119
|
saldoAtual: number;
|
|
108
120
|
saldoConciliado: number;
|
|
109
121
|
ativo: boolean;
|
|
@@ -130,6 +142,7 @@ type BankAccountDraftPayload = {
|
|
|
130
142
|
values: BankAccountFormValues;
|
|
131
143
|
logoFileId: number | null;
|
|
132
144
|
logoPreviewUrl: string | null;
|
|
145
|
+
currencyId: number | null;
|
|
133
146
|
};
|
|
134
147
|
|
|
135
148
|
const BANK_ACCOUNT_FORM_DRAFT_STORAGE_KEY = 'finance-bank-account-form-draft';
|
|
@@ -184,6 +197,21 @@ function NovaContaSheet({
|
|
|
184
197
|
const { request, showToastHandler, currentLocaleCode, getSettingValue } =
|
|
185
198
|
useApp();
|
|
186
199
|
|
|
200
|
+
const { data: currenciesData, refetch: refetchCurrencies } = useQuery<
|
|
201
|
+
Currency[]
|
|
202
|
+
>({
|
|
203
|
+
queryKey: ['finance-currencies-for-select'],
|
|
204
|
+
queryFn: async () => {
|
|
205
|
+
const response = await request({
|
|
206
|
+
url: '/finance/currencies',
|
|
207
|
+
method: 'GET',
|
|
208
|
+
});
|
|
209
|
+
return (response.data || []) as Currency[];
|
|
210
|
+
},
|
|
211
|
+
placeholderData: [],
|
|
212
|
+
});
|
|
213
|
+
const currencies = currenciesData || [];
|
|
214
|
+
|
|
187
215
|
const createSuccessMessage = t.has('messages.createSuccess')
|
|
188
216
|
? t('messages.createSuccess')
|
|
189
217
|
: 'Conta bancária cadastrada com sucesso';
|
|
@@ -221,6 +249,7 @@ function NovaContaSheet({
|
|
|
221
249
|
tipo: '',
|
|
222
250
|
descricao: '',
|
|
223
251
|
logoFileId: null,
|
|
252
|
+
currencyId: null,
|
|
224
253
|
dataInicial: new Date().toISOString().slice(0, 10),
|
|
225
254
|
saldoInicial: 0,
|
|
226
255
|
},
|
|
@@ -269,9 +298,11 @@ function NovaContaSheet({
|
|
|
269
298
|
watchedFormValues.dataInicial ||
|
|
270
299
|
new Date().toISOString().slice(0, 10),
|
|
271
300
|
saldoInicial: watchedFormValues.saldoInicial ?? 0,
|
|
301
|
+
currencyId: watchedFormValues.currencyId ?? null,
|
|
272
302
|
},
|
|
273
303
|
logoFileId: logoFileId ?? null,
|
|
274
304
|
logoPreviewUrl,
|
|
305
|
+
currencyId: watchedFormValues.currencyId ?? null,
|
|
275
306
|
}),
|
|
276
307
|
[editingAccount, logoFileId, logoPreviewUrl, watchedFormValues]
|
|
277
308
|
);
|
|
@@ -449,6 +480,15 @@ function NovaContaSheet({
|
|
|
449
480
|
showToastHandler?.('success', logoRemoveSuccessMessage);
|
|
450
481
|
};
|
|
451
482
|
|
|
483
|
+
useEffect(() => {
|
|
484
|
+
if (!open || !editingAccount) {
|
|
485
|
+
const brlCurrency = currencies.find((c) => c.code === 'BRL');
|
|
486
|
+
if (brlCurrency && open) {
|
|
487
|
+
form.setValue('currencyId', Number(brlCurrency.id));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}, [currencies, open, editingAccount, form]);
|
|
491
|
+
|
|
452
492
|
useEffect(() => {
|
|
453
493
|
if (!open) {
|
|
454
494
|
return;
|
|
@@ -486,6 +526,7 @@ function NovaContaSheet({
|
|
|
486
526
|
tipo: editingAccount.tipo,
|
|
487
527
|
descricao: editingAccount.descricao,
|
|
488
528
|
logoFileId: currentLogoFileId,
|
|
529
|
+
currencyId: editingAccount.currencyId ?? null,
|
|
489
530
|
dataInicial:
|
|
490
531
|
editingAccount.dataInicial ??
|
|
491
532
|
new Date().toISOString().slice(0, 10),
|
|
@@ -514,6 +555,7 @@ function NovaContaSheet({
|
|
|
514
555
|
tipo: '',
|
|
515
556
|
descricao: '',
|
|
516
557
|
logoFileId: null,
|
|
558
|
+
currencyId: null,
|
|
517
559
|
dataInicial: new Date().toISOString().slice(0, 10),
|
|
518
560
|
saldoInicial: 0,
|
|
519
561
|
}
|
|
@@ -536,6 +578,7 @@ function NovaContaSheet({
|
|
|
536
578
|
type: values.tipo,
|
|
537
579
|
description: values.descricao?.trim() || undefined,
|
|
538
580
|
logo_file_id: nextLogoFileId,
|
|
581
|
+
currency_id: values.currencyId ?? null,
|
|
539
582
|
start_date: values.dataInicial || undefined,
|
|
540
583
|
},
|
|
541
584
|
});
|
|
@@ -550,6 +593,7 @@ function NovaContaSheet({
|
|
|
550
593
|
type: values.tipo,
|
|
551
594
|
description: values.descricao?.trim() || undefined,
|
|
552
595
|
logo_file_id: nextLogoFileId,
|
|
596
|
+
currency_id: values.currencyId ?? null,
|
|
553
597
|
start_date: values.dataInicial || undefined,
|
|
554
598
|
initial_balance: values.saldoInicial,
|
|
555
599
|
},
|
|
@@ -579,6 +623,7 @@ function NovaContaSheet({
|
|
|
579
623
|
tipo: '',
|
|
580
624
|
descricao: '',
|
|
581
625
|
logoFileId: null,
|
|
626
|
+
currencyId: null,
|
|
582
627
|
dataInicial: new Date().toISOString().slice(0, 10),
|
|
583
628
|
saldoInicial: 0,
|
|
584
629
|
});
|
|
@@ -691,37 +736,61 @@ function NovaContaSheet({
|
|
|
691
736
|
/>
|
|
692
737
|
</div>
|
|
693
738
|
|
|
739
|
+
<FormField
|
|
740
|
+
control={form.control}
|
|
741
|
+
name="tipo"
|
|
742
|
+
render={({ field }) => (
|
|
743
|
+
<FormItem>
|
|
744
|
+
<FormLabel>{t('fields.type')}</FormLabel>
|
|
745
|
+
<Select
|
|
746
|
+
value={field.value}
|
|
747
|
+
onValueChange={field.onChange}
|
|
748
|
+
>
|
|
749
|
+
<FormControl>
|
|
750
|
+
<SelectTrigger className="w-full">
|
|
751
|
+
<SelectValue placeholder={t('common.select')} />
|
|
752
|
+
</SelectTrigger>
|
|
753
|
+
</FormControl>
|
|
754
|
+
<SelectContent>
|
|
755
|
+
<SelectItem value="corrente">
|
|
756
|
+
{t('types.corrente')}
|
|
757
|
+
</SelectItem>
|
|
758
|
+
<SelectItem value="poupanca">
|
|
759
|
+
{t('types.poupanca')}
|
|
760
|
+
</SelectItem>
|
|
761
|
+
<SelectItem value="investimento">
|
|
762
|
+
{t('types.investimento')}
|
|
763
|
+
</SelectItem>
|
|
764
|
+
<SelectItem value="caixa">
|
|
765
|
+
{t('types.caixa')}
|
|
766
|
+
</SelectItem>
|
|
767
|
+
</SelectContent>
|
|
768
|
+
</Select>
|
|
769
|
+
<FormMessage />
|
|
770
|
+
</FormItem>
|
|
771
|
+
)}
|
|
772
|
+
/>
|
|
773
|
+
|
|
694
774
|
<div className="grid gap-4 md:grid-cols-2">
|
|
695
775
|
<FormField
|
|
696
776
|
control={form.control}
|
|
697
|
-
name="
|
|
777
|
+
name="saldoInicial"
|
|
698
778
|
render={({ field }) => (
|
|
699
779
|
<FormItem>
|
|
700
|
-
<FormLabel>{t('fields.
|
|
701
|
-
<
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
<SelectItem value="poupanca">
|
|
715
|
-
{t('types.poupanca')}
|
|
716
|
-
</SelectItem>
|
|
717
|
-
<SelectItem value="investimento">
|
|
718
|
-
{t('types.investimento')}
|
|
719
|
-
</SelectItem>
|
|
720
|
-
<SelectItem value="caixa">
|
|
721
|
-
{t('types.caixa')}
|
|
722
|
-
</SelectItem>
|
|
723
|
-
</SelectContent>
|
|
724
|
-
</Select>
|
|
780
|
+
<FormLabel>{t('fields.initialBalance')}</FormLabel>
|
|
781
|
+
<FormControl>
|
|
782
|
+
<InputMoney
|
|
783
|
+
ref={field.ref}
|
|
784
|
+
name={field.name}
|
|
785
|
+
value={field.value}
|
|
786
|
+
onBlur={field.onBlur}
|
|
787
|
+
onValueChange={(value) =>
|
|
788
|
+
field.onChange(value ?? 0)
|
|
789
|
+
}
|
|
790
|
+
placeholder="0,00"
|
|
791
|
+
disabled={!!editingAccount}
|
|
792
|
+
/>
|
|
793
|
+
</FormControl>
|
|
725
794
|
<FormMessage />
|
|
726
795
|
</FormItem>
|
|
727
796
|
)}
|
|
@@ -753,28 +822,54 @@ function NovaContaSheet({
|
|
|
753
822
|
</div>
|
|
754
823
|
|
|
755
824
|
<div className="grid gap-4 md:grid-cols-2">
|
|
756
|
-
<
|
|
757
|
-
|
|
758
|
-
name="
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
825
|
+
<EntityPicker<Currency>
|
|
826
|
+
form={form as never}
|
|
827
|
+
name="currencyId"
|
|
828
|
+
label="Moeda"
|
|
829
|
+
placeholder="Selecione uma moeda"
|
|
830
|
+
searchPlaceholder="Buscar moeda..."
|
|
831
|
+
entityLabel="moeda"
|
|
832
|
+
valueType="number"
|
|
833
|
+
clearable
|
|
834
|
+
options={currencies}
|
|
835
|
+
getOptionValue={(c) => c.id}
|
|
836
|
+
getOptionLabel={(c) => `${c.symbol} ${c.code} — ${c.name}`}
|
|
837
|
+
createTitle="Nova moeda"
|
|
838
|
+
createDescription="Cadastre uma nova moeda para usar nas contas bancárias."
|
|
839
|
+
mapSearchToCreateValues={(s) => ({ code: s.toUpperCase() })}
|
|
840
|
+
createFields={[
|
|
841
|
+
{
|
|
842
|
+
name: 'code',
|
|
843
|
+
label: 'Código ISO',
|
|
844
|
+
placeholder: 'Ex.: BRL',
|
|
845
|
+
required: true,
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
name: 'name',
|
|
849
|
+
label: 'Nome',
|
|
850
|
+
placeholder: 'Ex.: Real Brasileiro',
|
|
851
|
+
required: true,
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
name: 'symbol',
|
|
855
|
+
label: 'Símbolo',
|
|
856
|
+
placeholder: 'Ex.: R$',
|
|
857
|
+
required: true,
|
|
858
|
+
},
|
|
859
|
+
]}
|
|
860
|
+
onCreate={async (values) => {
|
|
861
|
+
const response = await request({
|
|
862
|
+
url: '/finance/currencies',
|
|
863
|
+
method: 'POST',
|
|
864
|
+
data: {
|
|
865
|
+
code: (values.code ?? '').toUpperCase(),
|
|
866
|
+
name: values.name,
|
|
867
|
+
symbol: values.symbol,
|
|
868
|
+
},
|
|
869
|
+
});
|
|
870
|
+
void refetchCurrencies();
|
|
871
|
+
return response.data as Currency;
|
|
872
|
+
}}
|
|
778
873
|
/>
|
|
779
874
|
|
|
780
875
|
<FormField
|
|
@@ -1868,5 +1868,63 @@
|
|
|
1868
1868
|
},
|
|
1869
1869
|
"empty": "No expenses found for selected filters"
|
|
1870
1870
|
}
|
|
1871
|
+
},
|
|
1872
|
+
"AdminCurrenciesPage": {
|
|
1873
|
+
"common": {
|
|
1874
|
+
"cancel": "Cancel",
|
|
1875
|
+
"save": "Save"
|
|
1876
|
+
},
|
|
1877
|
+
"messages": {
|
|
1878
|
+
"createSuccess": "Currency created successfully",
|
|
1879
|
+
"createError": "Error creating currency",
|
|
1880
|
+
"updateSuccess": "Currency updated successfully",
|
|
1881
|
+
"updateError": "Error updating currency",
|
|
1882
|
+
"deleteSuccess": "Currency deactivated successfully",
|
|
1883
|
+
"deleteError": "Error deactivating currency"
|
|
1884
|
+
},
|
|
1885
|
+
"header": {
|
|
1886
|
+
"title": "Currencies",
|
|
1887
|
+
"description": "Manage currencies used in bank accounts and financial transactions"
|
|
1888
|
+
},
|
|
1889
|
+
"breadcrumbs": {
|
|
1890
|
+
"finance": "Finance",
|
|
1891
|
+
"administration": "Administration",
|
|
1892
|
+
"current": "Currencies"
|
|
1893
|
+
},
|
|
1894
|
+
"actions": {
|
|
1895
|
+
"newCurrency": "New currency"
|
|
1896
|
+
},
|
|
1897
|
+
"sheet": {
|
|
1898
|
+
"newTitle": "New currency",
|
|
1899
|
+
"editTitle": "Edit currency",
|
|
1900
|
+
"newDescription": "Register a new currency with its ISO code and symbol.",
|
|
1901
|
+
"editDescription": "Update the currency information.",
|
|
1902
|
+
"fields": {
|
|
1903
|
+
"code": "ISO Code",
|
|
1904
|
+
"codePlaceholder": "Ex.: BRL",
|
|
1905
|
+
"name": "Name",
|
|
1906
|
+
"namePlaceholder": "Ex.: Brazilian Real",
|
|
1907
|
+
"symbol": "Symbol",
|
|
1908
|
+
"symbolPlaceholder": "Ex.: R$"
|
|
1909
|
+
},
|
|
1910
|
+
"validation": {
|
|
1911
|
+
"codeRequired": "ISO code is required",
|
|
1912
|
+
"codeMaxLength": "ISO code must have at most 3 characters",
|
|
1913
|
+
"nameRequired": "Name is required",
|
|
1914
|
+
"symbolRequired": "Symbol is required"
|
|
1915
|
+
}
|
|
1916
|
+
},
|
|
1917
|
+
"table": {
|
|
1918
|
+
"empty": "No currencies found.",
|
|
1919
|
+
"status": {
|
|
1920
|
+
"active": "Active",
|
|
1921
|
+
"inactive": "Inactive"
|
|
1922
|
+
}
|
|
1923
|
+
},
|
|
1924
|
+
"deleteDialog": {
|
|
1925
|
+
"title": "Deactivate currency",
|
|
1926
|
+
"description": "Do you really want to deactivate this currency?",
|
|
1927
|
+
"confirm": "Deactivate"
|
|
1928
|
+
}
|
|
1871
1929
|
}
|
|
1872
1930
|
}
|
|
@@ -1868,5 +1868,63 @@
|
|
|
1868
1868
|
},
|
|
1869
1869
|
"empty": "Nenhum gasto encontrado para os filtros selecionados"
|
|
1870
1870
|
}
|
|
1871
|
+
},
|
|
1872
|
+
"AdminCurrenciesPage": {
|
|
1873
|
+
"common": {
|
|
1874
|
+
"cancel": "Cancelar",
|
|
1875
|
+
"save": "Salvar"
|
|
1876
|
+
},
|
|
1877
|
+
"messages": {
|
|
1878
|
+
"createSuccess": "Moeda cadastrada com sucesso",
|
|
1879
|
+
"createError": "Erro ao cadastrar moeda",
|
|
1880
|
+
"updateSuccess": "Moeda atualizada com sucesso",
|
|
1881
|
+
"updateError": "Erro ao atualizar moeda",
|
|
1882
|
+
"deleteSuccess": "Moeda inativada com sucesso",
|
|
1883
|
+
"deleteError": "Erro ao inativar moeda"
|
|
1884
|
+
},
|
|
1885
|
+
"header": {
|
|
1886
|
+
"title": "Moedas",
|
|
1887
|
+
"description": "Gerencie as moedas utilizadas em contas bancárias e transações financeiras"
|
|
1888
|
+
},
|
|
1889
|
+
"breadcrumbs": {
|
|
1890
|
+
"finance": "Financeiro",
|
|
1891
|
+
"administration": "Administração",
|
|
1892
|
+
"current": "Moedas"
|
|
1893
|
+
},
|
|
1894
|
+
"actions": {
|
|
1895
|
+
"newCurrency": "Nova moeda"
|
|
1896
|
+
},
|
|
1897
|
+
"sheet": {
|
|
1898
|
+
"newTitle": "Nova moeda",
|
|
1899
|
+
"editTitle": "Editar moeda",
|
|
1900
|
+
"newDescription": "Cadastre uma nova moeda com seu código ISO e símbolo.",
|
|
1901
|
+
"editDescription": "Atualize as informações da moeda.",
|
|
1902
|
+
"fields": {
|
|
1903
|
+
"code": "Código ISO",
|
|
1904
|
+
"codePlaceholder": "Ex.: BRL",
|
|
1905
|
+
"name": "Nome",
|
|
1906
|
+
"namePlaceholder": "Ex.: Real Brasileiro",
|
|
1907
|
+
"symbol": "Símbolo",
|
|
1908
|
+
"symbolPlaceholder": "Ex.: R$"
|
|
1909
|
+
},
|
|
1910
|
+
"validation": {
|
|
1911
|
+
"codeRequired": "Código ISO é obrigatório",
|
|
1912
|
+
"codeMaxLength": "Código ISO deve ter no máximo 3 caracteres",
|
|
1913
|
+
"nameRequired": "Nome é obrigatório",
|
|
1914
|
+
"symbolRequired": "Símbolo é obrigatório"
|
|
1915
|
+
}
|
|
1916
|
+
},
|
|
1917
|
+
"table": {
|
|
1918
|
+
"empty": "Nenhuma moeda encontrada.",
|
|
1919
|
+
"status": {
|
|
1920
|
+
"active": "Ativa",
|
|
1921
|
+
"inactive": "Inativa"
|
|
1922
|
+
}
|
|
1923
|
+
},
|
|
1924
|
+
"deleteDialog": {
|
|
1925
|
+
"title": "Inativar moeda",
|
|
1926
|
+
"description": "Deseja realmente inativar esta moeda?",
|
|
1927
|
+
"confirm": "Inativar"
|
|
1928
|
+
}
|
|
1871
1929
|
}
|
|
1872
1930
|
}
|
|
@@ -22,6 +22,13 @@ columns:
|
|
|
22
22
|
type: varchar
|
|
23
23
|
length: 34
|
|
24
24
|
isNullable: true
|
|
25
|
+
- name: currency_id
|
|
26
|
+
type: fk
|
|
27
|
+
isNullable: true
|
|
28
|
+
references:
|
|
29
|
+
table: currency
|
|
30
|
+
column: id
|
|
31
|
+
onDelete: SET NULL
|
|
25
32
|
- name: account_type
|
|
26
33
|
type: enum
|
|
27
34
|
values: [checking, savings, investment, cash, other]
|
|
@@ -42,4 +49,5 @@ indices:
|
|
|
42
49
|
- columns: [code]
|
|
43
50
|
isUnique: true
|
|
44
51
|
- columns: [logo_file_id]
|
|
52
|
+
- columns: [currency_id]
|
|
45
53
|
- columns: [status]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
columns:
|
|
2
|
+
- type: pk
|
|
3
|
+
- name: code
|
|
4
|
+
type: varchar
|
|
5
|
+
length: 3
|
|
6
|
+
- name: name
|
|
7
|
+
type: varchar
|
|
8
|
+
length: 100
|
|
9
|
+
- name: symbol
|
|
10
|
+
type: varchar
|
|
11
|
+
length: 10
|
|
12
|
+
- name: status
|
|
13
|
+
type: enum
|
|
14
|
+
values: [active, inactive]
|
|
15
|
+
- type: created_at
|
|
16
|
+
- type: updated_at
|
|
17
|
+
|
|
18
|
+
indices:
|
|
19
|
+
- columns: [code]
|
|
20
|
+
isUnique: true
|
|
21
|
+
- columns: [status]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hed-hog/finance",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.321",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"@nestjs/jwt": "^11",
|
|
11
11
|
"@nestjs/mapped-types": "*",
|
|
12
12
|
"@hed-hog/api": "0.0.8",
|
|
13
|
-
"@hed-hog/api-prisma": "0.0.6",
|
|
14
|
-
"@hed-hog/contact": "0.0.319",
|
|
15
13
|
"@hed-hog/api-locale": "0.0.14",
|
|
16
|
-
"@hed-hog/
|
|
14
|
+
"@hed-hog/contact": "0.0.321",
|
|
17
15
|
"@hed-hog/api-pagination": "0.0.7",
|
|
18
|
-
"@hed-hog/
|
|
19
|
-
"@hed-hog/api-types": "0.0.1"
|
|
16
|
+
"@hed-hog/api-prisma": "0.0.6",
|
|
17
|
+
"@hed-hog/api-types": "0.0.1",
|
|
18
|
+
"@hed-hog/tag": "0.0.321",
|
|
19
|
+
"@hed-hog/core": "0.0.321"
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import { IsString, Length } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class CreateCurrencyDto {
|
|
5
|
+
@IsString({
|
|
6
|
+
message: (args) => getLocaleText('validation.codeMustBeString', args.value),
|
|
7
|
+
})
|
|
8
|
+
@Length(1, 3)
|
|
9
|
+
code: string;
|
|
10
|
+
|
|
11
|
+
@IsString({
|
|
12
|
+
message: (args) => getLocaleText('validation.nameMustBeString', args.value),
|
|
13
|
+
})
|
|
14
|
+
name: string;
|
|
15
|
+
|
|
16
|
+
@IsString({
|
|
17
|
+
message: (args) =>
|
|
18
|
+
getLocaleText('validation.symbolMustBeString', args.value),
|
|
19
|
+
})
|
|
20
|
+
symbol: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import { IsOptional, IsString, Length } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class UpdateCurrencyDto {
|
|
5
|
+
@IsOptional()
|
|
6
|
+
@IsString({
|
|
7
|
+
message: (args) => getLocaleText('validation.codeMustBeString', args.value),
|
|
8
|
+
})
|
|
9
|
+
@Length(1, 3)
|
|
10
|
+
code?: string;
|
|
11
|
+
|
|
12
|
+
@IsOptional()
|
|
13
|
+
@IsString({
|
|
14
|
+
message: (args) => getLocaleText('validation.nameMustBeString', args.value),
|
|
15
|
+
})
|
|
16
|
+
name?: string;
|
|
17
|
+
|
|
18
|
+
@IsOptional()
|
|
19
|
+
@IsString({
|
|
20
|
+
message: (args) =>
|
|
21
|
+
getLocaleText('validation.symbolMustBeString', args.value),
|
|
22
|
+
})
|
|
23
|
+
symbol?: string;
|
|
24
|
+
|
|
25
|
+
@IsOptional()
|
|
26
|
+
@IsString({
|
|
27
|
+
message: (args) =>
|
|
28
|
+
getLocaleText('validation.statusMustBeString', args.value),
|
|
29
|
+
})
|
|
30
|
+
status?: 'active' | 'inactive';
|
|
31
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Role } from '@hed-hog/api';
|
|
2
|
+
import { Pagination, PaginationDTO } from '@hed-hog/api-pagination';
|
|
3
|
+
import {
|
|
4
|
+
Body,
|
|
5
|
+
Controller,
|
|
6
|
+
Delete,
|
|
7
|
+
Get,
|
|
8
|
+
Param,
|
|
9
|
+
ParseIntPipe,
|
|
10
|
+
Patch,
|
|
11
|
+
Post,
|
|
12
|
+
} from '@nestjs/common';
|
|
13
|
+
import { CreateCurrencyDto } from './dto/create-currency.dto';
|
|
14
|
+
import { UpdateCurrencyDto } from './dto/update-currency.dto';
|
|
15
|
+
import { FinanceService } from './finance.service';
|
|
16
|
+
|
|
17
|
+
@Role()
|
|
18
|
+
@Controller('finance')
|
|
19
|
+
export class FinanceCurrenciesController {
|
|
20
|
+
constructor(private readonly financeService: FinanceService) {}
|
|
21
|
+
|
|
22
|
+
@Get('currencies')
|
|
23
|
+
async listCurrencies(@Pagination() paginationParams: PaginationDTO) {
|
|
24
|
+
return this.financeService.listCurrencies(paginationParams);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Post('currencies')
|
|
28
|
+
async createCurrency(@Body() data: CreateCurrencyDto) {
|
|
29
|
+
return this.financeService.createCurrency(data);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Patch('currencies/:id')
|
|
33
|
+
async updateCurrency(
|
|
34
|
+
@Param('id', ParseIntPipe) id: number,
|
|
35
|
+
@Body() data: UpdateCurrencyDto,
|
|
36
|
+
) {
|
|
37
|
+
return this.financeService.updateCurrency(id, data);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Delete('currencies/:id')
|
|
41
|
+
async deleteCurrency(@Param('id', ParseIntPipe) id: number) {
|
|
42
|
+
return this.financeService.deleteCurrency(id);
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/finance.module.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { FinanceBankAccountsController } from './finance-bank-accounts.controlle
|
|
|
9
9
|
import { FinanceCategoriesController } from './finance-categories.controller';
|
|
10
10
|
import { FinanceCollectionsController } from './finance-collections.controller';
|
|
11
11
|
import { FinanceCostCentersController } from './finance-cost-centers.controller';
|
|
12
|
+
import { FinanceCurrenciesController } from './finance-currencies.controller';
|
|
12
13
|
import { FinanceDataController } from './finance-data.controller';
|
|
13
14
|
import { FinanceInstallmentsController } from './finance-installments.controller';
|
|
14
15
|
import { FinancePeriodCloseController } from './finance-period-close.controller';
|
|
@@ -38,6 +39,7 @@ import { FinanceService } from './finance.service';
|
|
|
38
39
|
FinanceCategoriesController,
|
|
39
40
|
FinanceCollectionsController,
|
|
40
41
|
FinanceCostCentersController,
|
|
42
|
+
FinanceCurrenciesController,
|
|
41
43
|
FinancePeriodCloseController,
|
|
42
44
|
FinanceStatementsController,
|
|
43
45
|
FinanceTransfersController,
|