@tasenor/common-plugins 1.9.16

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 (114) hide show
  1. package/.eslintrc.js +4 -0
  2. package/.turbo/turbo-fix.log +4 -0
  3. package/.turbo/turbo-lint.log +4 -0
  4. package/.turbo/turbo-version.log +5 -0
  5. package/LICENSE +21 -0
  6. package/README.md +15 -0
  7. package/data/FinnishBalanceSheetReport.mjs +9 -0
  8. package/data/FinnishBalanceSheetReportInvestment.mjs +11 -0
  9. package/data/FinnishBalanceSheetReportLite.mjs +9 -0
  10. package/data/FinnishIncomeStatementReport.mjs +9 -0
  11. package/data/FinnishIncomeStatementReportInvestment.mjs +11 -0
  12. package/data/FinnishIncomeStatementReportLite.mjs +9 -0
  13. package/data/FinnishInvestmentCompany.mjs +5 -0
  14. package/data/FinnishLimitedCompanyComplete.mjs +5 -0
  15. package/data/FinnishLimitedCompanyLite.mjs +9 -0
  16. package/data/IncomeAndExpenses.mjs +64 -0
  17. package/data/README.md +8 -0
  18. package/data/VATFinland.mjs +22 -0
  19. package/data/bin/build_all +11 -0
  20. package/data/lib/utils.mjs +314 -0
  21. package/data/src/Assets Tree - Definitions.tsv +101 -0
  22. package/data/src/Expense Tree - Definitions.tsv +99 -0
  23. package/data/src/Finland VAT - Definitions.tsv +22 -0
  24. package/data/src/FinnishBalanceSheetReport - balance-sheet-detailed-fi.tsv +215 -0
  25. package/data/src/FinnishBalanceSheetReport - balance-sheet-fi.tsv +93 -0
  26. package/data/src/FinnishBalanceSheetReportInvestment - balance-sheet-detailed-fi.tsv +100 -0
  27. package/data/src/FinnishBalanceSheetReportInvestment - balance-sheet-fi.tsv +52 -0
  28. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-en.tsv +21 -0
  29. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-fi.tsv +21 -0
  30. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-lite-en.tsv +21 -0
  31. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-lite-fi.tsv +21 -0
  32. package/data/src/FinnishIncomeStatementReport - income-statement-detailed-fi.tsv +118 -0
  33. package/data/src/FinnishIncomeStatementReport - income-statement-fi.tsv +45 -0
  34. package/data/src/FinnishIncomeStatementReportInvestment - income-statement-detailed-fi.tsv +96 -0
  35. package/data/src/FinnishIncomeStatementReportInvestment - income-statement-fi.tsv +39 -0
  36. package/data/src/FinnishIncomeStatementReportLite - income-statement-lite-en.tsv +23 -0
  37. package/data/src/FinnishIncomeStatementReportLite - income-statement-lite-fi.tsv +23 -0
  38. package/data/src/FinnishInvestmentCompany - fi-EUR.tsv +722 -0
  39. package/data/src/FinnishLimitedCompanyComplete - fi-EUR.tsv +1086 -0
  40. package/data/src/FinnishLimitedCompanyLite - en-EUR.tsv +97 -0
  41. package/data/src/FinnishLimitedCompanyLite - fi-EUR.tsv +99 -0
  42. package/data/src/Income Tree - Definitions.tsv +60 -0
  43. package/data/src/Tax Types - Definitions.tsv +11 -0
  44. package/package.json +51 -0
  45. package/src/CoinAPI/backend/index.ts +102 -0
  46. package/src/CoinbaseImport/backend/CoinbaseHandler.ts +35 -0
  47. package/src/CoinbaseImport/backend/index.ts +24 -0
  48. package/src/CoinbaseImport/backend/rules.json +64 -0
  49. package/src/DocumentCleaner/ui/index.tsx +165 -0
  50. package/src/Euro/ui/index.tsx +27 -0
  51. package/src/Finnish/ui/finnish.json +341 -0
  52. package/src/Finnish/ui/index.tsx +54 -0
  53. package/src/FinnishBalanceSheetReport/backend/balance-sheet-detailed-fi.tsv +215 -0
  54. package/src/FinnishBalanceSheetReport/backend/balance-sheet-fi.tsv +93 -0
  55. package/src/FinnishBalanceSheetReport/backend/index.ts +107 -0
  56. package/src/FinnishBalanceSheetReportInvestment/backend/balance-sheet-investment-detailed-fi.tsv +100 -0
  57. package/src/FinnishBalanceSheetReportInvestment/backend/balance-sheet-investment-fi.tsv +52 -0
  58. package/src/FinnishBalanceSheetReportInvestment/backend/index.ts +107 -0
  59. package/src/FinnishBalanceSheetReportLite/backend/balance-sheet-lite-en.tsv +21 -0
  60. package/src/FinnishBalanceSheetReportLite/backend/balance-sheet-lite-fi.tsv +21 -0
  61. package/src/FinnishBalanceSheetReportLite/backend/index.ts +121 -0
  62. package/src/FinnishIncomeStatementReport/backend/income-statement-detailed-fi.tsv +118 -0
  63. package/src/FinnishIncomeStatementReport/backend/income-statement-fi.tsv +45 -0
  64. package/src/FinnishIncomeStatementReport/backend/index.ts +212 -0
  65. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-detailed-fi.tsv +118 -0
  66. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-fi.tsv +45 -0
  67. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-investment-detailed-fi.tsv +96 -0
  68. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-investment-fi.tsv +39 -0
  69. package/src/FinnishIncomeStatementReportInvestment/backend/index.ts +212 -0
  70. package/src/FinnishIncomeStatementReportLite/backend/income-statement-lite-en.tsv +23 -0
  71. package/src/FinnishIncomeStatementReportLite/backend/income-statement-lite-fi.tsv +23 -0
  72. package/src/FinnishIncomeStatementReportLite/backend/index.ts +210 -0
  73. package/src/FinnishInvestmentCompany/backend/fi-EUR.tsv +722 -0
  74. package/src/FinnishInvestmentCompany/backend/index.ts +46 -0
  75. package/src/FinnishInvestmentCompany/ui/index.tsx +26 -0
  76. package/src/FinnishLimitedCompanyComplete/backend/fi-EUR.tsv +1086 -0
  77. package/src/FinnishLimitedCompanyComplete/backend/index.ts +46 -0
  78. package/src/FinnishLimitedCompanyComplete/ui/index.tsx +26 -0
  79. package/src/FinnishLimitedCompanyLite/backend/en-EUR.tsv +97 -0
  80. package/src/FinnishLimitedCompanyLite/backend/fi-EUR.tsv +99 -0
  81. package/src/FinnishLimitedCompanyLite/backend/index.ts +53 -0
  82. package/src/FinnishLimitedCompanyLite/ui/index.tsx +28 -0
  83. package/src/GitBackup/backend/index.ts +109 -0
  84. package/src/GitBackup/ui/index.tsx +127 -0
  85. package/src/IncomeAndExpenses/backend/assetCodes.json +126 -0
  86. package/src/IncomeAndExpenses/backend/expense.json +190 -0
  87. package/src/IncomeAndExpenses/backend/income.json +120 -0
  88. package/src/IncomeAndExpenses/backend/index.ts +354 -0
  89. package/src/IncomeAndExpenses/backend/taxTypes.json +12 -0
  90. package/src/JournalReport/backend/index.ts +157 -0
  91. package/src/KrakenImport/backend/KrakenHandler.ts +88 -0
  92. package/src/KrakenImport/backend/index.ts +24 -0
  93. package/src/KrakenImport/backend/rules.json +52 -0
  94. package/src/LedgerReport/backend/index.ts +161 -0
  95. package/src/LynxImport/backend/LynxHandler.ts +389 -0
  96. package/src/LynxImport/backend/index.ts +24 -0
  97. package/src/LynxImport/backend/rules.json +412 -0
  98. package/src/NordeaImport/backend/NordeaHandler.ts +44 -0
  99. package/src/NordeaImport/backend/index.ts +24 -0
  100. package/src/NordeaImport/backend/rules.json +4 -0
  101. package/src/NordnetImport/backend/NordnetHandler.ts +78 -0
  102. package/src/NordnetImport/backend/index.ts +24 -0
  103. package/src/NordnetImport/backend/rules.json +271 -0
  104. package/src/Rand/ui/index.tsx +27 -0
  105. package/src/RapidAPI/backend/index.ts +133 -0
  106. package/src/TITOImport/backend/TITOHandler.ts +268 -0
  107. package/src/TITOImport/backend/index.ts +24 -0
  108. package/src/TITOImport/backend/rules.json +4 -0
  109. package/src/TagEditor/ui/index.tsx +510 -0
  110. package/src/USDollar/ui/index.tsx +27 -0
  111. package/src/VAT/ui/index.tsx +572 -0
  112. package/src/VATFinland/backend/index.ts +22 -0
  113. package/src/VATFinland/backend/vat.json +23 -0
  114. package/tsconfig.json +13 -0
@@ -0,0 +1,46 @@
1
+ import path from 'path'
2
+ import { SchemePlugin } from '@dataplug/tasenor-common-node'
3
+ import { Currency, Language, PluginCode, SchemeName, TsvFilePath, Version } from '@dataplug/tasenor-common'
4
+
5
+ class FinnishLimitedCompanyComplete extends SchemePlugin {
6
+
7
+ constructor() {
8
+ super('FinnishLimitedCompanyComplete' as SchemeName)
9
+
10
+ this.code = 'FinnishLimitedCompanyComplete' as PluginCode
11
+ this.title = 'Finnish Limited Company - Complete'
12
+ this.version = '1.0.35' as Version
13
+ this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M11.17 8l-.58-.59L9.17 6H4v12h16V8h-8z" opacity=".3"/><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l1.41 1.41.59.59H20v10z"/></svg>'
14
+ this.releaseDate = '2023-05-24'
15
+ this.use = 'both'
16
+ this.type = 'scheme'
17
+ this.description = 'Complete accounting scheme for Finnish limited company.'
18
+
19
+ this.languages = {
20
+ fi: {
21
+ }
22
+ }
23
+ }
24
+
25
+ getSchemePaths(code): TsvFilePath[] {
26
+ if (code === 'FinnishLimitedCompanyComplete') {
27
+ return [path.join(__dirname, 'fi-EUR.tsv') as TsvFilePath]
28
+ }
29
+ return []
30
+ }
31
+
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ getSchemeDefaults(code): Record<string, unknown> {
34
+ return {}
35
+ }
36
+
37
+ supportedCurrencies(): Currency[] {
38
+ return ['EUR']
39
+ }
40
+
41
+ supportedLanguages(): Language[] {
42
+ return ['fi']
43
+ }
44
+ }
45
+
46
+ export default FinnishLimitedCompanyComplete
@@ -0,0 +1,26 @@
1
+ import { SchemePlugin } from '@dataplug/tasenor-common-ui'
2
+
3
+ class FinnishLimitedCompanyComplete extends SchemePlugin {
4
+
5
+ static code = 'FinnishLimitedCompanyComplete'
6
+ static title = 'Finnish Limited Company - Complete'
7
+ static version = '1.0.35'
8
+ static icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M11.17 8l-.58-.59L9.17 6H4v12h16V8h-8z" opacity=".3"/><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l1.41 1.41.59.59H20v10z"/></svg>'
9
+ static releaseDate = '2023-05-24'
10
+ static use = 'both'
11
+ static type = 'scheme'
12
+ static description = 'Complete accounting scheme for Finnish limited company.'
13
+
14
+ constructor() {
15
+ super()
16
+ this.languages = {
17
+ fi: {}
18
+ }
19
+ }
20
+
21
+ getAccountingSchemes() {
22
+ return { FinnishLimitedCompanyComplete: 'Osakeyhtiö (Laaja tilikartta)' }
23
+ }
24
+ }
25
+
26
+ export default FinnishLimitedCompanyComplete
@@ -0,0 +1,97 @@
1
+ # number / title text type code data
2
+ ASSETS
3
+ __Current Assets
4
+ ___Short-term Receivables
5
+ _____Trade Receivables
6
+ 1701 Trade Receivables 1 ASSET
7
+ _____Other Current Assets
8
+ 1761 Tax Receivables ASSET
9
+ 1763 VAT Receivables ASSET
10
+ _____Accrued Income
11
+ 1849 Other Accrued Income ASSET
12
+ ___Cash & Bank Balance
13
+ ____Cash
14
+ 1900 Cash Asset ASSET
15
+ ____Bank Balances
16
+ 1910 Bank Account 1 ASSET
17
+ 1920 Bank Account 2 ASSET
18
+ CAPITAL, RESERVES & LIABILITIES
19
+ __Equity
20
+ ___Share Capital
21
+ 2001 Share Capital EQUITY
22
+ ___Retained Earning/Loss
23
+ 2251 Retained Earning/Loss PROFIT_PREV
24
+ __Creditors
25
+ ___Long-term Debt
26
+ ____Loans
27
+ 2621 Long-term Loan 1 LIABILITY
28
+ ___Short-term Debt
29
+ ____Loans (credit institutions)
30
+ 2825 Short-term Loan 1 LIABILITY
31
+ ____Unearned Income
32
+ 2861 Unearned Income LIABILITY
33
+ ____Account Payables
34
+ 2871 Account Payables 1 LIABILITY
35
+ ____Other Debts
36
+ 2921 Withholding Tax Liability LIABILITY
37
+ 2931 TyEL Contribution (employment pension insurance) LIABILITY
38
+ 2939 VAT Liability LIABILITY
39
+ 29391 VAT on Sales LIABILITY
40
+ 29392 VAT on Purchases LIABILITY
41
+ 29393 VAT payable on EU purchases LIABILITY
42
+ 29394 VAT deductible from EU purchases LIABILITY
43
+ 29395 VAT payable on Construction Services LIABILITY
44
+ 29396 VAT deductible from Construction Services LIABILITY
45
+ ____Accrued Expenses
46
+ 2979 Other Accrued Expenses LIABILITY
47
+ INCOME STATEMENT
48
+ _Revenue from Sales
49
+ __General Sales Account
50
+ 3000 Sales REVENUE ____FINLAND_SALES
51
+ _Other Operating Income
52
+ 3800 Grants Received REVENUE
53
+ 3990 Other Operating Income REVENUE __OTHER_OPERATING_INCOME
54
+ _Materials & Services
55
+ __Materials, supplies & goods
56
+ ___Purchases
57
+ ____Purchases of goods & services
58
+ 4000 Purchases EXPENSE 24
59
+ 4080 Purchases, buyer taxpayer EXPENSE 24
60
+ ____Import of Goods
61
+ 4110 Intercompany Acquisitions EXPENSE 24
62
+ 4140 Duties, Taxes & Custom Clearance Charges EXPENSE
63
+ ___Increase/Decrease in Stocks
64
+ 4400 Changes in stock of materials & supplies EXPENSE
65
+ __External Services
66
+ 4450 Subcontracting 1 EXPENSE 24
67
+ 4470 Purchase of Construction services (reversible tax liability) EXPENSE 24
68
+ 4475 Purchase of Services (EU-countries) EXPENSE 24
69
+ _Staffing Costs
70
+ __Wages & Salaries
71
+ ___Employees' Salaries & Wages
72
+ ____ [Normal] Wages & Salaries
73
+ 5000 Employees' Salaries EXPENSE
74
+ ____Remuneration/Commission
75
+ 5200 remuneration/commission EXPENSE
76
+ __Social Security Contributions
77
+ ___Pension Expenses
78
+ ____Pension Contributions
79
+ 6100 YEL (Pension Payment for the Self-Employed) EXPENSE
80
+ 6130 TyEL (Employees' Pension Contributions) EXPENSE
81
+ ____Accruals during the financial year
82
+ 6290 Accruals during the financial year EXPENSE
83
+ ___Other Social Security Expenses
84
+ ____Social Security Contributions
85
+ 6300 Social Security Contributions EXPENSE
86
+ ____Compulsory Insurance Premiums
87
+ 6400 Accident Insurance Contributions EXPENSE
88
+ 6410 Unemployment Insurance Contributions EXPENSE
89
+ _Other Operating Expenses
90
+ __Voluntary Social Security Contributions
91
+ 7170 Other Social Security Expenses EXPENSE 24
92
+ __Administrative Services
93
+ 8440 Government Fees EXPENSE 24
94
+ _Income Tax
95
+ __For the financial year & earlier
96
+ 9900 Anticipatory Tax EXPENSE
97
+ 9950 Tax Refund / Residual Tax EXPENSE
@@ -0,0 +1,99 @@
1
+ # number / title text type code data
2
+ Vastaavaa
3
+ __Vaihtuvat vastaavat
4
+ ___Lyhytaikaiset saamiset
5
+ _____Myyntisaamiset
6
+ 1701 Myyntisaamiset 1 ASSET
7
+ _____Muut saamiset
8
+ 1761 Verosaamiset ASSET
9
+ 1763 Arvonlisäverosaamiset ASSET
10
+ _____Siirtosaamiset
11
+ 1849 Muut siirtosaamiset ASSET
12
+ ___Rahat ja pankkisaamiset
13
+ ____Rahat
14
+ 1900 Käteisvarat ASSET
15
+ ____Pankkisaamiset
16
+ 1910 Pankkitili 1 ASSET
17
+ 1920 Pankkitili 2 ASSET
18
+ Vastattavaa
19
+ __Oma pääoma
20
+ ___Osakepääoma
21
+ 2001 Osakepääoma EQUITY
22
+ ___Edellisten tilikausien voitto (tappio)
23
+ 2251 Edellisten tilikausien voitto/tappio PROFIT_PREV
24
+ __Vieras pääoma
25
+ ___Pitkäaikainen vieras pääoma
26
+ ____Lainat rahoituslaitoksilta
27
+ 2621 Pitkäaikainen rahoituslaitoslaina 1 LIABILITY
28
+ ___Lyhytaikainen vieras pääoma
29
+ ____Lainat rahoituslaitoksilta
30
+ 2825 Lyhytaikainen rahoituslaitoslaina 1 LIABILITY
31
+ ____Saadut ennakot
32
+ 2861 Saadut ennakot LIABILITY
33
+ ____Ostovelat
34
+ 2871 Ostovelat 1 LIABILITY
35
+ ____Muut velat
36
+ 2921 Ennakonpidätysvelka LIABILITY
37
+ 2931 TyEL-velka LIABILITY
38
+ 2939 Arvonlisäverovelka LIABILITY
39
+ 29391 Alv myynnistä LIABILITY
40
+ 29392 Alv ostoista LIABILITY
41
+ 29393 Alv suoritettava EU-ostoista LIABILITY
42
+ 29394 Alv vähennettävä EU-ostoista LIABILITY
43
+ 29395 Alv suoritettava rak.palveluista LIABILITY
44
+ 29396 Alv vähennettävä rak.palveluista LIABILITY
45
+ ____Siirtovelat
46
+ 2979 Muut siirtovelat LIABILITY
47
+ Tuloslaskelma
48
+ _Myyntituotot
49
+ __Yleiset myyntitilit
50
+ 3000 Myynti REVENUE ____FINLAND_SALES
51
+ _Liiketoiminnan muut tuotot
52
+ 3800 Saadut avustukset REVENUE
53
+ 3990 Muut liiketoiminnan tuotot REVENUE __OTHER_OPERATING_INCOME
54
+ _Materiaalit ja palvelut
55
+ __Aineet, tarvikkeet ja tavarat
56
+ ___Ostot tilikauden aikana
57
+ ____Aine-, tarvike- ja tavaraostot
58
+ 4000 Ostot EXPENSE 24
59
+ 4080 Ostot, ostaja verovelvollinen EXPENSE 24
60
+ ____Tavaratuonti
61
+ 4110 Yhteisöhankinnat EXPENSE 24
62
+ 4140 Tullit, verot ja muut maksut tullattaessa EXPENSE
63
+ ___Varastojen lisäys tai vähennys
64
+ 4400 Aine- ja tarvikevaraston muutos EXPENSE
65
+ __Ulkopuoliset palvelut
66
+ 4450 Alihankinta 1 EXPENSE 24
67
+ 4470 Rakentamispalveluiden osto (käänn. verovelv.) EXPENSE 24
68
+ 4475 Palveluiden osto EU-maista EXPENSE 24
69
+ _Henkilöstökulut
70
+ __Palkat ja palkkiot
71
+ ___Työntekijöiden palkat ja palkkiot
72
+ ____Työssäoloajan normaalipalkat
73
+ 5000 Työntekijäpalkat EXPENSE
74
+ ____Palkkiot
75
+ 5200 Palkkiot EXPENSE
76
+ __Henkilösivukulut
77
+ ___Eläkekulut
78
+ ____Eläkevakuutusmaksut
79
+ 6100 YEL-maksut EXPENSE
80
+ 6130 TyEL-maksut EXPENSE
81
+ ____Tilikauden aikainen jaksotus
82
+ 6290 Tilikauden aikainen jaksotus EXPENSE
83
+ ___Muut henkilösivukulut
84
+ ____Sosiaaliturvamaksut
85
+ 6300 Sosiaaliturvamaksut EXPENSE
86
+ ____Pakolliset vakuutusmaksut
87
+ 6400 Tapaturmavakuutusmaksut EXPENSE
88
+ 6410 Työttömyysvakuutusmaksut EXPENSE
89
+ _Liiketoiminnan muut kulut
90
+ __Vapaaehtoiset henkilösivukulut
91
+ 7170 Muut henkilösivukulut EXPENSE 24
92
+ __Hallintopalvelut
93
+ 8440 Viranomaismaksut EXPENSE 24
94
+ _Tuloverot
95
+ __Tilikauden ja aikaisempien tilikausien verot
96
+ 9900 Ennakkoverot EXPENSE
97
+ 9950 Veronpalautukset / jäännösverot EXPENSE
98
+ _Erikoistilit
99
+ 9999 Selvittelyä vaativat tapahtumat EXPENSE SUSPENSE_ACCOUNT
@@ -0,0 +1,53 @@
1
+ import path from 'path'
2
+ import { SchemePlugin } from '@dataplug/tasenor-common-node'
3
+ import { Currency, Language, PluginCode, SchemeName, TsvFilePath, Version } from '@dataplug/tasenor-common'
4
+
5
+ class FinnishLimitedCompanyLite extends SchemePlugin {
6
+
7
+ constructor() {
8
+ super('FinnishLimitedCompanyLite' as SchemeName)
9
+
10
+ this.code = 'FinnishLimitedCompanyLite' as PluginCode
11
+ this.title = 'Finnish Limited Company - Lite'
12
+ this.version = '1.0.27' as Version
13
+ this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M11.17 8l-.58-.59L9.17 6H4v12h16V8h-8z" opacity=".3"/><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l1.41 1.41.59.59H20v10z"/></svg>'
14
+ this.releaseDate = '2023-05-24'
15
+ this.use = 'both'
16
+ this.type = 'scheme'
17
+ this.description = 'Small accounting scheme for Finnish limited company. English and Finnish version.'
18
+
19
+ this.languages = {
20
+ fi: {
21
+ }
22
+ }
23
+ }
24
+
25
+ getSchemePaths(code, language): TsvFilePath[] {
26
+ if (code === 'FinnishLimitedCompanyLite') {
27
+ if (language === 'en') {
28
+ return [
29
+ path.join(__dirname, 'en-EUR.tsv'),
30
+ ] as TsvFilePath[]
31
+ }
32
+ return [
33
+ path.join(__dirname, 'fi-EUR.tsv'),
34
+ ] as TsvFilePath[]
35
+ }
36
+ return []
37
+ }
38
+
39
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
+ getSchemeDefaults(code): Record<string, unknown> {
41
+ return {}
42
+ }
43
+
44
+ supportedCurrencies(): Currency[] {
45
+ return ['EUR']
46
+ }
47
+
48
+ supportedLanguages(): Language[] {
49
+ return ['fi', 'en']
50
+ }
51
+ }
52
+
53
+ export default FinnishLimitedCompanyLite
@@ -0,0 +1,28 @@
1
+ import { SchemePlugin } from '@dataplug/tasenor-common-ui'
2
+
3
+ class FinnishLimitedCompanyLite extends SchemePlugin {
4
+
5
+ static code = 'FinnishLimitedCompanyLite'
6
+ static title = 'Finnish Limited Company - Lite'
7
+ static version = '1.0.27'
8
+ static icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M11.17 8l-.58-.59L9.17 6H4v12h16V8h-8z" opacity=".3"/><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l1.41 1.41.59.59H20v10z"/></svg>'
9
+ static releaseDate = '2023-05-24'
10
+ static use = 'both'
11
+ static type = 'scheme'
12
+ static description = 'Small accounting scheme for Finnish limited company. English and Finnish version.'
13
+
14
+ constructor() {
15
+ super()
16
+ this.languages = {
17
+ fi: {
18
+ 'Limited company (Lite scheme)': 'Osakeyhtiö (Suppea tilikartta)'
19
+ }
20
+ }
21
+ }
22
+
23
+ getAccountingSchemes() {
24
+ return { FinnishLimitedCompanyLite: 'Limited company (Lite scheme)' }
25
+ }
26
+ }
27
+
28
+ export default FinnishLimitedCompanyLite
@@ -0,0 +1,109 @@
1
+ import { GitRepo, KnexDatabase, systemPiped, TasenorExporter, ToolPlugin } from '@dataplug/tasenor-common-node'
2
+ import { DirectoryPath, Email, error, log, note, PluginCode, Version } from '@dataplug/tasenor-common'
3
+ import fs from 'fs'
4
+ import path from 'path'
5
+
6
+ class GitBackup extends ToolPlugin {
7
+ constructor() {
8
+ super()
9
+
10
+ this.code = 'GitBackup'as PluginCode
11
+ this.title = 'Backup for Git'
12
+ this.version = '1.0.2' as Version
13
+ this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path></svg>'
14
+ this.releaseDate = '2022-12-12'
15
+ this.use = 'both'
16
+ this.type = 'tool'
17
+ this.description = 'Tool for backing up database to the git repository.'
18
+
19
+ this.languages = {
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Check if the resulting concatenation of paths points to the allowed working area of file system.
25
+ */
26
+ isValidWritePath(db: KnexDatabase, ...parts: string[]) {
27
+ const resolved = path.resolve(...parts)
28
+ const dir = path.resolve(this.getWorkSpace(db))
29
+
30
+ return resolved.substring(0, dir.length) === dir
31
+ }
32
+
33
+ /**
34
+ * Create backup every night.
35
+ */
36
+ async nightly(db: KnexDatabase) {
37
+ await this.makeBackup(db, `Automatic nightly backup by ${this.code} ${this.version}`)
38
+ }
39
+
40
+ /**
41
+ * Create manual dump.
42
+ */
43
+ async POST(db: KnexDatabase, data): Promise<unknown> {
44
+ if (typeof data === 'object' && data !== null && data.makeBackup) {
45
+ const success = await this.makeBackup(db, `${data.makeBackup}`)
46
+ return { success }
47
+ }
48
+ return { success: false }
49
+ }
50
+
51
+ /**
52
+ * Execute backup making for a database.
53
+ */
54
+ async makeBackup(db: KnexDatabase, message: string): Promise<boolean> {
55
+ const workDir = this.getWorkSpace(db)
56
+ const repository = await this.getSetting(db, 'repository')
57
+ const subDirectory = await this.getSetting(db, 'subDirectory')
58
+
59
+ // Skip if not configured for use.
60
+ if (repository === undefined || subDirectory === undefined) {
61
+ return false
62
+ }
63
+
64
+ const repoName = GitRepo.defaultName(repository)
65
+
66
+ if (!this.isValidWritePath(db, workDir, repoName, subDirectory)) {
67
+
68
+ error(`A sub directory '${subDirectory}' does not produce valide allowed work directory for backup in DB '${db.client.config.connection.database}'.`)
69
+ return false
70
+
71
+ } else {
72
+
73
+ log(`Making a backup into '${subDirectory}' of DB '${db.client.config.connection.database}'.`)
74
+ const repo = await GitRepo.get(repository, workDir)
75
+ if (repo) {
76
+ repo.configure('Tasenor', 'tasenor@gmail.com' as Email)
77
+ const backupDir = path.join(workDir, repoName, subDirectory) as DirectoryPath
78
+ await this.dump(db, backupDir)
79
+ await repo.put(message, subDirectory)
80
+ return true
81
+ }
82
+ return false
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Write the data from the database to the directory.
88
+ */
89
+ async dump(db: KnexDatabase, dir: DirectoryPath) {
90
+
91
+ note(`Creating backup into '${dir}'.`)
92
+
93
+ if (fs.existsSync(dir)) {
94
+ log(`Removing old data from '${dir}'.`)
95
+ fs.rmSync(dir, { recursive: true })
96
+ }
97
+ const exportDir = path.join(dir, 'export') as DirectoryPath
98
+ fs.mkdirSync(exportDir, { recursive: true })
99
+ // TODO: Check for pg_dump crash. What if that happens?
100
+ const { host, port, database, user, password } = db.client.config.connection
101
+ const url = `postgresql://${user}:${password}@${host}:${port}/${database}`
102
+ await systemPiped(`pg_dump -c ${url} > "${dir}/dump.sql"`)
103
+
104
+ const exporter = new TasenorExporter()
105
+ await exporter.dump(db, exportDir)
106
+ }
107
+ }
108
+
109
+ export default GitBackup
@@ -0,0 +1,127 @@
1
+ import React from 'react'
2
+ import { Note, IconButton, SubPanel, ToolPlugin } from '@dataplug/tasenor-common-ui'
3
+ import { makeObservable, observable, runInAction } from 'mobx'
4
+ import { Trans } from 'react-i18next'
5
+
6
+ class GitBackup extends ToolPlugin {
7
+
8
+ busy = false
9
+
10
+ static code = 'GitBackup'
11
+ static title = 'Backup for Git'
12
+ static version = '1.0.2'
13
+ static icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path></svg>'
14
+ static releaseDate = '2022-12-12'
15
+ static use = 'both'
16
+ static type = 'tool'
17
+ static description = 'Tool for backing up database to the git repository.'
18
+
19
+ constructor() {
20
+ super()
21
+
22
+ makeObservable(this, {
23
+ busy: observable
24
+ })
25
+
26
+ this.languages = {
27
+ // TODO: This is too simple labeling. Need to add plugin code as well.
28
+ en: {
29
+ 'label-repository': 'Repository URL',
30
+ 'label-subDirectory': 'Subdirectory inside the repository',
31
+ 'summarize-make-backup': 'Make a backup'
32
+ },
33
+ fi: {
34
+ 'label-repository': 'Git-säilön URL',
35
+ 'label-subDirectory': 'Alihakemisotn nimi säilön sisällä',
36
+ 'summarize-make-backup': 'Tee varmuuskopio',
37
+
38
+ 'Backup for Git': 'Git-pohjainen Varmuuskopiointi',
39
+ 'Manual backup by GitBackup {version}': 'Ylimääräinen varmuuskopio GitBackup {version}',
40
+ 'Backup created successfully.': 'Varmuuskopion luominen onnistui.',
41
+ 'Creating backup failed.': 'Varmuuskopion luominen ei onnistunut.'
42
+ }
43
+ }
44
+
45
+ }
46
+
47
+ toolMenu() {
48
+ return [{ title: 'Backup for Git', disabled: !this.store.database }]
49
+ }
50
+
51
+ toolTitle() {
52
+ return 'Backup for Git'
53
+ }
54
+
55
+ async onMakeBackup() {
56
+ runInAction(() => (this.busy = true))
57
+ const { success } = await this.POST({ makeBackup: this.t('Manual backup by GitBackup {version}').replace('{version}', GitBackup.version) }) as { success: boolean }
58
+ runInAction(() => {
59
+ this.busy = false
60
+ if (success) {
61
+ this.store.addMessage(this.t('Backup created successfully.'))
62
+ } else {
63
+ this.store.addError(this.t('Creating backup failed.'))
64
+ }
65
+ })
66
+ }
67
+
68
+ toolTopPanel() {
69
+ const repo = this.getSetting('repository')
70
+ return <>
71
+ <IconButton id="Make Backup" disabled={this.busy || !repo} onClick={() => this.onMakeBackup()} title="summarize-make-backup" icon="save" />
72
+ </>
73
+ }
74
+
75
+ toolMainPanel() {
76
+ // TODO: We could use here some link utility that keeps selected dbs and ids intact but changes URL parts.
77
+ const repo = this.getSetting('repository')
78
+ if (!repo) {
79
+ return <>
80
+ <Note><Trans>You need to configure this tool first from the configuration page.</Trans></Note>
81
+ </>
82
+ }
83
+ return <>
84
+ <SubPanel>
85
+ <Trans>This tool takes every night automatically one backup.</Trans><> </>
86
+ <Trans>You can also make immediately backup from the icon above.</Trans><> </>
87
+ <Trans>Setting up SSH keys is not yet supported.</Trans><> </>
88
+ <Trans>Please contact the support for the server SSH keys to get access to your repository.</Trans>
89
+ </SubPanel>
90
+ <SubPanel>
91
+ <Trans>Currently restore is not yet implemented.</Trans><> </>
92
+ <Trans>In order to restore from the backup, you must ensure to get the wanted version as the latest commit in the Git.</Trans><> </>
93
+ <Trans>Then you need to contact support to let them know that DB needs to be loaded from Git.</Trans>
94
+ </SubPanel>
95
+ </>
96
+ }
97
+
98
+ // TODO: Add button to create backup right now. Maybe with comments?
99
+ // TODO: Communicating with backend counterpart needs URL passing all requests to plugin.
100
+
101
+ getSettings() {
102
+ return {
103
+ type: 'flat',
104
+ elements: [
105
+ {
106
+ type: 'text',
107
+ name: 'repository',
108
+ actions: {}
109
+ },
110
+ {
111
+ type: 'text',
112
+ name: 'subDirectory',
113
+ actions: {}
114
+ },
115
+ {
116
+ type: 'button',
117
+ label: 'Save',
118
+ actions: {
119
+ onClick: { type: 'saveSettings', plugin: 'GitBackup' }
120
+ }
121
+ }
122
+ ]
123
+ }
124
+ }
125
+ }
126
+
127
+ export default GitBackup