medusa-invoice 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. package/.yarnrc.yml +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +177 -0
  4. package/dist/admin/_virtual_entry.js +15246 -0
  5. package/dist/api/admin/document-invoice-settings/forced-number/route.d.ts +2 -0
  6. package/dist/api/admin/document-invoice-settings/forced-number/route.js +39 -0
  7. package/dist/api/admin/document-invoice-settings/format-number/route.d.ts +2 -0
  8. package/dist/api/admin/document-invoice-settings/format-number/route.js +39 -0
  9. package/dist/api/admin/document-invoice-settings/invoice-template/route.d.ts +2 -0
  10. package/dist/api/admin/document-invoice-settings/invoice-template/route.js +39 -0
  11. package/dist/api/admin/document-invoice-settings/route.d.ts +3 -0
  12. package/dist/api/admin/document-invoice-settings/route.js +56 -0
  13. package/dist/api/admin/document-packing-slip-settings/route.d.ts +3 -0
  14. package/dist/api/admin/document-packing-slip-settings/route.js +56 -0
  15. package/dist/api/admin/document-packing-slip-settings/template/route.d.ts +2 -0
  16. package/dist/api/admin/document-packing-slip-settings/template/route.js +39 -0
  17. package/dist/api/admin/document-settings/document-address/route.d.ts +2 -0
  18. package/dist/api/admin/document-settings/document-address/route.js +46 -0
  19. package/dist/api/admin/document-settings/logo/route.d.ts +3 -0
  20. package/dist/api/admin/document-settings/logo/route.js +61 -0
  21. package/dist/api/admin/document-settings/route.d.ts +2 -0
  22. package/dist/api/admin/document-settings/route.js +30 -0
  23. package/dist/api/admin/invoice/display-number/route.d.ts +2 -0
  24. package/dist/api/admin/invoice/display-number/route.js +32 -0
  25. package/dist/api/admin/invoice/generate/route.d.ts +2 -0
  26. package/dist/api/admin/invoice/generate/route.js +29 -0
  27. package/dist/api/admin/invoice/route.d.ts +3 -0
  28. package/dist/api/admin/invoice/route.js +44 -0
  29. package/dist/api/admin/packing-slip/preview/route.d.ts +2 -0
  30. package/dist/api/admin/packing-slip/preview/route.js +29 -0
  31. package/dist/api/admin/packing-slip/route.d.ts +3 -0
  32. package/dist/api/admin/packing-slip/route.js +44 -0
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +29 -0
  35. package/dist/loaders/i18next.d.ts +3 -0
  36. package/dist/loaders/i18next.js +72 -0
  37. package/dist/migrations/1711700828113-DocumentSettings.d.ts +6 -0
  38. package/dist/migrations/1711700828113-DocumentSettings.js +47 -0
  39. package/dist/migrations/1711701185935-Invoice.d.ts +5 -0
  40. package/dist/migrations/1711701185935-Invoice.js +50 -0
  41. package/dist/migrations/1712753213091-DocumentInvoiceSettings.d.ts +5 -0
  42. package/dist/migrations/1712753213091-DocumentInvoiceSettings.js +46 -0
  43. package/dist/migrations/1712754851678-Invoice.d.ts +5 -0
  44. package/dist/migrations/1712754851678-Invoice.js +23 -0
  45. package/dist/migrations/1714903066794-DocumentPackingSlipSettings.d.ts +5 -0
  46. package/dist/migrations/1714903066794-DocumentPackingSlipSettings.js +25 -0
  47. package/dist/migrations/1714903539447-PackingSlip.d.ts +5 -0
  48. package/dist/migrations/1714903539447-PackingSlip.js +45 -0
  49. package/dist/models/document-invoice-settings.d.ts +11 -0
  50. package/dist/models/document-invoice-settings.js +61 -0
  51. package/dist/models/document-packing-slip-settings.d.ts +11 -0
  52. package/dist/models/document-packing-slip-settings.js +61 -0
  53. package/dist/models/document-settings.d.ts +12 -0
  54. package/dist/models/document-settings.js +66 -0
  55. package/dist/models/invoice.d.ts +15 -0
  56. package/dist/models/invoice.js +74 -0
  57. package/dist/models/packing-slip.d.ts +15 -0
  58. package/dist/models/packing-slip.js +74 -0
  59. package/dist/services/document-invoice-settings.d.ts +14 -0
  60. package/dist/services/document-invoice-settings.js +110 -0
  61. package/dist/services/document-packing-slip-settings.d.ts +14 -0
  62. package/dist/services/document-packing-slip-settings.js +110 -0
  63. package/dist/services/generators/invoice-generator.d.ts +8 -0
  64. package/dist/services/generators/invoice-generator.js +64 -0
  65. package/dist/services/generators/packing-slip-generator.d.ts +8 -0
  66. package/dist/services/generators/packing-slip-generator.js +64 -0
  67. package/dist/services/invoice.d.ts +22 -0
  68. package/dist/services/invoice.js +277 -0
  69. package/dist/services/packing-slip.d.ts +16 -0
  70. package/dist/services/packing-slip.js +187 -0
  71. package/dist/services/templates/invoices/basic/basic-logo.d.ts +8 -0
  72. package/dist/services/templates/invoices/basic/basic-logo.js +56 -0
  73. package/dist/services/templates/invoices/basic/basic.d.ts +8 -0
  74. package/dist/services/templates/invoices/basic/basic.js +53 -0
  75. package/dist/services/templates/invoices/basic/parts/customer-info.d.ts +2 -0
  76. package/dist/services/templates/invoices/basic/parts/customer-info.js +70 -0
  77. package/dist/services/templates/invoices/basic/parts/header-for-logo.d.ts +2 -0
  78. package/dist/services/templates/invoices/basic/parts/header-for-logo.js +33 -0
  79. package/dist/services/templates/invoices/basic/parts/header-logo.d.ts +1 -0
  80. package/dist/services/templates/invoices/basic/parts/header-logo.js +30 -0
  81. package/dist/services/templates/invoices/basic/parts/header.d.ts +2 -0
  82. package/dist/services/templates/invoices/basic/parts/header.js +36 -0
  83. package/dist/services/templates/invoices/basic/parts/hr.d.ts +1 -0
  84. package/dist/services/templates/invoices/basic/parts/hr.js +24 -0
  85. package/dist/services/templates/invoices/basic/parts/invoice-info.d.ts +2 -0
  86. package/dist/services/templates/invoices/basic/parts/invoice-info.js +36 -0
  87. package/dist/services/templates/invoices/basic/parts/table.d.ts +2 -0
  88. package/dist/services/templates/invoices/basic/parts/table.js +54 -0
  89. package/dist/services/templates/packing-slips/basic/basic.d.ts +8 -0
  90. package/dist/services/templates/packing-slips/basic/basic.js +53 -0
  91. package/dist/services/templates/packing-slips/basic/parts/customer-info-small.d.ts +2 -0
  92. package/dist/services/templates/packing-slips/basic/parts/customer-info-small.js +70 -0
  93. package/dist/services/templates/packing-slips/basic/parts/customer-info.d.ts +2 -0
  94. package/dist/services/templates/packing-slips/basic/parts/customer-info.js +66 -0
  95. package/dist/services/templates/packing-slips/basic/parts/header-small.d.ts +2 -0
  96. package/dist/services/templates/packing-slips/basic/parts/header-small.js +38 -0
  97. package/dist/services/templates/packing-slips/basic/parts/header.d.ts +2 -0
  98. package/dist/services/templates/packing-slips/basic/parts/header.js +38 -0
  99. package/dist/services/templates/packing-slips/basic/parts/hr.d.ts +2 -0
  100. package/dist/services/templates/packing-slips/basic/parts/hr.js +33 -0
  101. package/dist/services/templates/packing-slips/basic/parts/table-items-small.d.ts +2 -0
  102. package/dist/services/templates/packing-slips/basic/parts/table-items-small.js +45 -0
  103. package/dist/services/templates/packing-slips/basic/parts/table-items.d.ts +2 -0
  104. package/dist/services/templates/packing-slips/basic/parts/table-items.js +45 -0
  105. package/dist/services/templates/packing-slips/basic/parts/table-order-info-small.d.ts +2 -0
  106. package/dist/services/templates/packing-slips/basic/parts/table-order-info-small.js +36 -0
  107. package/dist/services/templates/packing-slips/basic/parts/table-order-info.d.ts +2 -0
  108. package/dist/services/templates/packing-slips/basic/parts/table-order-info.js +37 -0
  109. package/dist/services/templates/packing-slips/basic/small.d.ts +8 -0
  110. package/dist/services/templates/packing-slips/basic/small.js +54 -0
  111. package/dist/services/types/api.d.ts +14 -0
  112. package/dist/services/types/api.js +14 -0
  113. package/dist/services/types/constants.d.ts +2 -0
  114. package/dist/services/types/constants.js +17 -0
  115. package/dist/services/types/template-kind.d.ts +8 -0
  116. package/dist/services/types/template-kind.js +25 -0
  117. package/dist/services/utils/currency.d.ts +1 -0
  118. package/dist/services/utils/currency.js +19 -0
  119. package/dist/ui-components/actions-dropdown/actions-dropdown.d.ts +4 -0
  120. package/dist/ui-components/actions-dropdown/actions-dropdown.js +18 -0
  121. package/dist/ui-components/actions-dropdown/invoice/button-generate-invoice.d.ts +5 -0
  122. package/dist/ui-components/actions-dropdown/invoice/button-generate-invoice.js +56 -0
  123. package/dist/ui-components/actions-dropdown/invoice/button-view-invoice.d.ts +5 -0
  124. package/dist/ui-components/actions-dropdown/invoice/button-view-invoice.js +64 -0
  125. package/dist/ui-components/actions-dropdown/packing-slip/button-generate-packing-slip.d.ts +5 -0
  126. package/dist/ui-components/actions-dropdown/packing-slip/button-generate-packing-slip.js +56 -0
  127. package/dist/ui-components/actions-dropdown/packing-slip/button-view-packing-slip.d.ts +5 -0
  128. package/dist/ui-components/actions-dropdown/packing-slip/button-view-packing-slip.js +64 -0
  129. package/dist/ui-components/index.d.ts +3 -0
  130. package/dist/ui-components/index.js +21 -0
  131. package/dist/ui-components/orders/order-table/invoice-number-from-order.d.ts +4 -0
  132. package/dist/ui-components/orders/order-table/invoice-number-from-order.js +30 -0
  133. package/dist/ui-components/orders/order-table/packing-slip-number.d.ts +4 -0
  134. package/dist/ui-components/orders/order-table/packing-slip-number.js +30 -0
  135. package/dist/ui-components/orders/order-table/use-columns.d.ts +45 -0
  136. package/dist/ui-components/orders/order-table/use-columns.js +186 -0
  137. package/dist/ui-components/orders/order-table/use-orders.d.ts +9 -0
  138. package/dist/ui-components/orders/order-table/use-orders.js +146 -0
  139. package/dist/ui-components/orders/order-table/utils/currencies.d.ts +14 -0
  140. package/dist/ui-components/orders/order-table/utils/currencies.js +1077 -0
  141. package/dist/ui-components/orders/order-table/utils/time.d.ts +10 -0
  142. package/dist/ui-components/orders/order-table/utils/time.js +54 -0
  143. package/dist/ui-components/orders/order-table.d.ts +8 -0
  144. package/dist/ui-components/orders/order-table.js +92 -0
  145. package/dist/ui-components/settings/settings-address.d.ts +2 -0
  146. package/dist/ui-components/settings/settings-address.js +66 -0
  147. package/dist/ui-components/settings/settings-invoice-display-number.d.ts +5 -0
  148. package/dist/ui-components/settings/settings-invoice-display-number.js +29 -0
  149. package/dist/ui-components/settings/settings-invoice.d.ts +2 -0
  150. package/dist/ui-components/settings/settings-invoice.js +116 -0
  151. package/dist/ui-components/settings/settings-logo.d.ts +2 -0
  152. package/dist/ui-components/settings/settings-logo.js +86 -0
  153. package/dist/ui-components/tabs/orders-tab.d.ts +1 -0
  154. package/dist/ui-components/tabs/orders-tab.js +28 -0
  155. package/dist/ui-components/tabs/pro-tab.d.ts +1 -0
  156. package/dist/ui-components/tabs/pro-tab.js +23 -0
  157. package/dist/ui-components/tabs/settings-tab.d.ts +1 -0
  158. package/dist/ui-components/tabs/settings-tab.js +28 -0
  159. package/dist/ui-components/tabs/templates-tab/templates-invoice-tab.d.ts +1 -0
  160. package/dist/ui-components/tabs/templates-tab/templates-invoice-tab.js +92 -0
  161. package/dist/ui-components/tabs/templates-tab/templates-packing-slip-tab.d.ts +1 -0
  162. package/dist/ui-components/tabs/templates-tab/templates-packing-slip-tab.js +92 -0
  163. package/dist/ui-components/tabs/templates-tab/templates-tab.d.ts +1 -0
  164. package/dist/ui-components/tabs/templates-tab/templates-tab.js +24 -0
  165. package/dist/ui-components/types/api.d.ts +54 -0
  166. package/dist/ui-components/types/api.js +14 -0
  167. package/dist/ui-components/types/invoice.d.ts +8 -0
  168. package/dist/ui-components/types/invoice.js +14 -0
  169. package/dist/ui-components/types/packing-slip.d.ts +8 -0
  170. package/dist/ui-components/types/packing-slip.js +14 -0
  171. package/dist/ui-components/types/template-kind.d.ts +8 -0
  172. package/dist/ui-components/types/template-kind.js +25 -0
  173. package/index.js +50 -0
  174. package/package.json +94 -0
  175. package/tsconfig.admin.json +8 -0
  176. package/tsconfig.json +32 -0
  177. package/tsconfig.server.json +8 -0
  178. package/tsconfig.spec.json +5 -0
package/.yarnrc.yml ADDED
@@ -0,0 +1 @@
1
+ nodeLinker: node-modules
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 RSC-Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ <p align="center">
2
+ <picture>
3
+ <img alt="Medusa documents logo" src="https://raw.githubusercontent.com/RSC-Labs/medusa-documents/d41b6dadafc1a01094b1db976676eee048709f2e/docs/medusa-documents-logo.png">
4
+ </picture>
5
+ </p>
6
+
7
+ # Medusa documents
8
+
9
+ ## What is it?
10
+
11
+ Medusa documents is a plugin which provides you ability to generate various documents in PDF format. For supported documents, go to [Supported documents](#supported-documents)
12
+
13
+ ## How to install?
14
+
15
+ 1. Install the package with `yarn add @rsc-labs/medusa-documents` or `npm i @rsc-labs/medusa-documents`.
16
+ 2. In `medusa-config.js`, add the plugin to the `plugins` array and set `enableUI`
17
+
18
+ ```js
19
+ const plugins = [
20
+ // ... other plugins
21
+ {
22
+ resolve: `@rsc-labs/medusa-documents`,
23
+ options: {
24
+ enableUI: true
25
+ }
26
+ }
27
+ ]
28
+ ```
29
+
30
+ 3. Run migrations, e.g. `npx medusa migrations run` (see: https://docs.medusajs.com/development/entities/migrations/overview) as plugin uses new tables.
31
+
32
+ ## Getting started
33
+
34
+ After installation of a plugin, you will see new option on the sidebar named `Documents`. This will lead you to such view:
35
+
36
+ <p align="center">
37
+ <picture>
38
+ <img alt="Medusa documents orders" src="https://raw.githubusercontent.com/RSC-Labs/medusa-documents/main/docs/medusa-documents-orders.PNG">
39
+ </picture>
40
+ </p>
41
+
42
+
43
+ **_NOTE:_** This README describes `Invoice` as an example of document.
44
+
45
+ This is a view of your orders. You can notice that it is very similar to `Orders` view. The important difference is in the last column, when you can see `Actions`. `Actions` can handle different documents.
46
+
47
+ Before you can generate `Invoice` you need to be familiar with two things - `Templates` and `Settings`. Let's go firstly to `Settings`.
48
+
49
+ ### Settings
50
+
51
+ This tab contains settings which are used to generate documents. The most important setting which needs to be set is address. Address reflects information about your company or store, which will be inserted in documents. Go to `Change adddress` to set it.
52
+
53
+ Depends on the used template, you may want to change a logo or adjust invoice number. Let's just jump now to `Templates`.
54
+
55
+ ### Templates
56
+
57
+ This tab contains supported templates which are used to generate documents. You may see there very basic templates which will be extended in the future. If you set your `Address` correctly and you have at least one `Order`, you may see a preview how invoice will look like.
58
+
59
+ <p align="center">
60
+ <picture>
61
+ <img alt="Medusa documents template" src="https://raw.githubusercontent.com/RSC-Labs/medusa-documents/main/docs/medusa-documents-template.PNG">
62
+ </picture>
63
+ </p>
64
+
65
+
66
+ <b>Note:</b> In preview mode, invoice number is set to 1.
67
+
68
+ <b>Note:</b> If you have picture of template which you would like to have supported, please raise [issue](https://github.com/RSC-Labs/medusa-documents/issues).
69
+
70
+
71
+ ### Supported documents
72
+
73
+ | Name | Status |
74
+ | --- | --- |
75
+ | Invoice | :white_check_mark: |
76
+ | Packing slip | :white_check_mark: |
77
+
78
+ ### Generating invoice
79
+
80
+ If you have your `Template` chosen and `Address` set, then you are able to generate invoice. Go to `Orders`, click on `...` and choose `Generate invoice`. You will see new card opened with your invoice.
81
+
82
+ <b>Note: [We do not store documents, see what it means](#what-means-we-do-not-store-documents)</b>
83
+
84
+ After invoice generation, you will see assigned number in the column `Last generated invoice`. This is useful, if you want to download your invoice again or decide to generate new one.
85
+
86
+ ### View invoice
87
+
88
+ If you forgot download your invoice, you may click on `View invoice` to regenerate invoice with the same invoice number.
89
+
90
+ ### Invoice number
91
+
92
+ By default, invoice number is generated based on the last assigned invoice number. In other words - plugin takes the last generated invoice and takes its number to increment it.
93
+
94
+ We know that your businesss may require different numbering. In such case - go to `Settings` tab and click `Change settings` in `Invoice`. You will see that you can change how your invoice number will look like. For instance, you can make something like `ABC123{invoice_number}`. If your last invoice has base number `10`, then you will get `ABC12311` as your next invoice number.
95
+
96
+ Sometimes you may want to set your next invoice number (for instance when you have many different clients). You can do it by setting `Forced number` in `Settings`. Please remember that this setting will be applied for newly generated invoice and the incrementation will start over from this new number.
97
+
98
+ <b>Protip:</b> After setting change, you can always go to `Templates` to see a preview with your next invoice number.
99
+
100
+ ## Translation
101
+
102
+ With version 0.8.0 we introduced translations for documents. You can now configure language for generated documents.
103
+
104
+ **_NOTE:_** We do not support (yet) translations of frontend.
105
+
106
+ You can configure language of documents using `medusa-config.js` file. Here is the example of Polish language:
107
+ ```js
108
+ const plugins = [
109
+ // ... other plugins
110
+ {
111
+ resolve: `@rsc-labs/medusa-documents`,
112
+ options: {
113
+ enableUI: true,
114
+ documentLanguage: 'pl'
115
+ }
116
+ }
117
+ ]
118
+ ```
119
+
120
+ Available translations can be found here: https://github.com/RSC-Labs/medusa-documents/tree/main/src/assets/i18n/locales.
121
+
122
+ ### How to add my own translations?
123
+
124
+ You have two options:
125
+
126
+ - create `translation.json` under `/assets/i18n/locales/{your-language}` and create a pull requests - we will be more than happy to merge it
127
+
128
+ - create `translation.json` only for local purposes. Then you need to go to `node_modules/@rsc-labs/medusa-documents/assets/i18n/locales/{your-language}` and paste there your translation file.
129
+
130
+ Please remember that `documentLanguage` in `medusa-config.js` needs to be equal to `{your-language}`.
131
+
132
+ ## Q&A
133
+
134
+ ### What means "We do not store documents"?
135
+
136
+ It is simple - every time when you click `Generate invoice` we are taking an `Order` and based on that we generate invoice. The same happens with `View invoice`. It means that if you click generate invoice and your `Order` will change (e.g. line items changed, customer address changed etc.), then `View invoice` will show you the <b>last</b> state of your `Order`. <b>We do not remember Order's state</b>.
137
+
138
+ However, we remember such things like: invoice number, address or logo, so everything which you set in `Settings`.
139
+
140
+ Anyway, we encourage you to save your invoice when you generate.
141
+
142
+ ### I clicked generate invoice, invoice number has been assigned, but I want to go back to previous number
143
+
144
+ Now you can do it! Just got to `Settings` tab and click `Change settings` in `Invoice`. Use `Forced number` field to put your next invoice number.
145
+
146
+ ### Provided templates are not enough for me, I want more of them, I want customization, I want hide some information etc.
147
+
148
+ We also see here endless possibilities.. :) Unfortunately, this is a very basic version, but for sure in the future there will be more functionalities.
149
+
150
+ ## Proposals, bugs, improvements
151
+
152
+ If you have an idea, what could be the next highest priority functionality, do not hesistate raise issue here: [Github issues](https://github.com/RSC-Labs/medusa-documents/issues)
153
+
154
+ ## License
155
+
156
+ MIT
157
+
158
+ ## Pro version
159
+
160
+ The Pro version of medusa-documents expands on the features of the free version with more advanced capabilities such as:
161
+ - automatically send invoices to customers
162
+ - new premium templates
163
+ - additional options for configurations, e.g. setting different addresses for various document type
164
+ - and a lot more.
165
+
166
+ The Pro version is available under commercial licence - contact labs@rsoftcon.com for more information.
167
+
168
+ ### Hide Pro version tab
169
+
170
+ We show what advanced features we offer in "Pro version" tab. We try to keep it non-intruisive, but if you feel it differently, you can always hide this tab by setting following environment variable:
171
+ `MEDUSA_ADMIN_MEDUSA_DOCUMENTS_HIDE_PRO=true`
172
+
173
+ After restarting your admin application, you shall have this tab hidden.
174
+
175
+ ---
176
+
177
+ © 2024 RSC https://rsoftcon.com/