mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
Compare commits
221 Commits
upload-com
...
add-mail-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0517b3e430 | ||
|
|
d668d60ed5 | ||
|
|
a34b7a2106 | ||
|
|
6f12127095 | ||
|
|
b4e5bbf376 | ||
|
|
a11530d190 | ||
|
|
43d4425da5 | ||
|
|
4c1909cb73 | ||
|
|
a7b6b7a03e | ||
|
|
1f46275bde | ||
|
|
aa7e5d4ae9 | ||
|
|
bb482df3ce | ||
|
|
f878786646 | ||
|
|
652851a1a9 | ||
|
|
850f4956cb | ||
|
|
94223b6ebf | ||
|
|
e9d34e19ad | ||
|
|
4c67d2e321 | ||
|
|
107532fe26 | ||
|
|
c32aff82ee | ||
|
|
de8a867d33 | ||
|
|
17a8aba23f | ||
|
|
04b601626b | ||
|
|
802775c118 | ||
|
|
b6baa80134 | ||
|
|
b2d0f2ed3c | ||
|
|
d23f33bae4 | ||
|
|
22ea557337 | ||
|
|
b3ebbb429c | ||
|
|
51218797af | ||
|
|
2d18a6573e | ||
|
|
2646ad5bc4 | ||
|
|
51aec8d8b3 | ||
|
|
638bd95d6f | ||
|
|
f2fcc3a649 | ||
|
|
48795748d8 | ||
|
|
6ba54a994a | ||
|
|
6687db4085 | ||
|
|
ba1d9b3f28 | ||
|
|
51905825fd | ||
|
|
bd5e33855a | ||
|
|
f7fbc0e31c | ||
|
|
cb06fa342c | ||
|
|
581229053a | ||
|
|
209da69b8f | ||
|
|
d09aebcebb | ||
|
|
0cc80bc179 | ||
|
|
79dcc592bc | ||
|
|
687111851a | ||
|
|
dbbaa387bd | ||
|
|
470bfd32f7 | ||
|
|
5fddd080fd | ||
|
|
e10c530b4b | ||
|
|
12189f018d | ||
|
|
0111b0e6ff | ||
|
|
0930b0428d | ||
|
|
289f40014e | ||
|
|
01cc0568f9 | ||
|
|
42ee8ed9fa | ||
|
|
1dae65cb74 | ||
|
|
ce40d67ea2 | ||
|
|
26088a71ee | ||
|
|
cadf6b81a0 | ||
|
|
728b4cacd9 | ||
|
|
b4d3ac2f96 | ||
|
|
bc8e440814 | ||
|
|
4c0f9a0aef | ||
|
|
c321d90575 | ||
|
|
03e6372f14 | ||
|
|
c0481f67ad | ||
|
|
b7f316d25a | ||
|
|
dffd818396 | ||
|
|
bbc19df6b4 | ||
|
|
c8c2786893 | ||
|
|
d79f26f1b5 | ||
|
|
32ba6f9a6c | ||
|
|
ccbb399685 | ||
|
|
f381d433ec | ||
|
|
2ee49f7496 | ||
|
|
bb299aa595 | ||
|
|
a66867463e | ||
|
|
de50b89e5c | ||
|
|
c4ee143354 | ||
|
|
a2227016e5 | ||
|
|
4d6f65b179 | ||
|
|
758ebbe261 | ||
|
|
279890e922 | ||
|
|
44fae36b82 | ||
|
|
fc2fac80af | ||
|
|
5ad9a9654b | ||
|
|
8a4034cc5d | ||
|
|
5649657bf0 | ||
|
|
c929a7cb27 | ||
|
|
eeedb789a9 | ||
|
|
321af8c271 | ||
|
|
fd4d86e797 | ||
|
|
49988e27a2 | ||
|
|
8c94ee5982 | ||
|
|
2e73a34fef | ||
|
|
ea7f987fe3 | ||
|
|
d55503f0c7 | ||
|
|
f59b8166b6 | ||
|
|
2c735d7edf | ||
|
|
5b5ab9fe1e | ||
|
|
28ac9b2d90 | ||
|
|
3300a6a499 | ||
|
|
152a22baa0 | ||
|
|
e873198238 | ||
|
|
68a0db91ee | ||
|
|
ddea7be24a | ||
|
|
b7b86bb0c5 | ||
|
|
817ef906dc | ||
|
|
863c7693fa | ||
|
|
cf78255220 | ||
|
|
f9aa6abdd7 | ||
|
|
0a5e40a0d8 | ||
|
|
4aa445fe35 | ||
|
|
1a1095c99b | ||
|
|
d92b46aa7b | ||
|
|
682d40cbf8 | ||
|
|
b62f3b3fa6 | ||
|
|
e76d3b15ce | ||
|
|
9edfb83221 | ||
|
|
bbdfe00c7a | ||
|
|
e3942551cd | ||
|
|
a0c1a21983 | ||
|
|
3358ce58bc | ||
|
|
3cd54653a8 | ||
|
|
6cad929738 | ||
|
|
184648040c | ||
|
|
df9d277e66 | ||
|
|
75ec315de2 | ||
|
|
c89b2367e6 | ||
|
|
bca5b3481c | ||
|
|
59996e7a40 | ||
|
|
af5726c48c | ||
|
|
90f08c5d51 | ||
|
|
a0a9f4a768 | ||
|
|
2649f1c326 | ||
|
|
c5ff1e4d4a | ||
|
|
c74c8e896a | ||
|
|
55fdc47ff0 | ||
|
|
126eb221d0 | ||
|
|
3c7e22be43 | ||
|
|
b23112bc92 | ||
|
|
cbc60b3c73 | ||
|
|
6caa1311fd | ||
|
|
cd0bbd11c3 | ||
|
|
2a944f8507 | ||
|
|
8a2754d9ce | ||
|
|
ace75f2dfa | ||
|
|
7ceb785c1b | ||
|
|
904a52f5a1 | ||
|
|
04fe65b176 | ||
|
|
7ac6e0d349 | ||
|
|
4ec3586173 | ||
|
|
4b6ab7035e | ||
|
|
3fe7babe00 | ||
|
|
f21570982e | ||
|
|
ad8fe52b84 | ||
|
|
15ce6ac710 | ||
|
|
783387dce6 | ||
|
|
863c7ad99f | ||
|
|
776b69475c | ||
|
|
6b6027a588 | ||
|
|
d465ee15bd | ||
|
|
be2049ca6e | ||
|
|
9b63c176cd | ||
|
|
e506a7ba35 | ||
|
|
2191ad0d40 | ||
|
|
ca162206a3 | ||
|
|
c5d7a2bfd8 | ||
|
|
b9506424d1 | ||
|
|
46a145ae58 | ||
|
|
e4044ef563 | ||
|
|
1cc71eb368 | ||
|
|
323b95de7b | ||
|
|
b0658be041 | ||
|
|
b222d56148 | ||
|
|
946872204b | ||
|
|
2f9adfd908 | ||
|
|
1c8e19378f | ||
|
|
7aed3d9c8c | ||
|
|
b125e3e58b | ||
|
|
65788e344a | ||
|
|
abc242d117 | ||
|
|
6dd4968327 | ||
|
|
70bba4a6ed | ||
|
|
1570995021 | ||
|
|
8109236e72 | ||
|
|
9ba651decb | ||
|
|
eb5fdbf4ee | ||
|
|
9827a84857 | ||
|
|
3308133736 | ||
|
|
3129c76c30 | ||
|
|
c0a4c965f0 | ||
|
|
e04f5d26a3 | ||
|
|
ad74007d58 | ||
|
|
6271d6c268 | ||
|
|
7756b5b304 | ||
|
|
8de8695b25 | ||
|
|
11c56c75a4 | ||
|
|
f5a1d68c52 | ||
|
|
0ae7a25c27 | ||
|
|
16eaacd4bc | ||
|
|
809973730f | ||
|
|
2ebb4595a8 | ||
|
|
77f628509c | ||
|
|
d2cd32a735 | ||
|
|
4665f529e6 | ||
|
|
df706d2573 | ||
|
|
5270e99de8 | ||
|
|
eb48f66f6e | ||
|
|
2b42215381 | ||
|
|
18d6ec7b59 | ||
|
|
430cf19533 | ||
|
|
542e61dbfc | ||
|
|
9517b4e279 | ||
|
|
162b92ce84 | ||
|
|
a183666df6 | ||
|
|
d805703c08 |
@@ -159,6 +159,15 @@
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "nklmantey",
|
||||
"name": "Mantey",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/90279429?v=4",
|
||||
"profile": "https://nklmantey.com/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
||||
@@ -92,4 +92,11 @@ S3_BUCKET=
|
||||
|
||||
# PostHog
|
||||
POSTHOG_API_KEY=
|
||||
POSTHOG_HOST=
|
||||
POSTHOG_HOST=
|
||||
|
||||
# Stripe Payment
|
||||
STRIPE_PAYMENT_SECRET_KEY=
|
||||
STRIPE_PAYMENT_PUBLISHABLE_KEY=
|
||||
STRIPE_PAYMENT_CLIENT_ID=
|
||||
STRIPE_PAYMENT_WEBHOOKS_SECRET=
|
||||
STRIPE_PAYMENT_REDIRECT_URL=
|
||||
54
CHANGELOG.md
54
CHANGELOG.md
@@ -2,6 +2,60 @@
|
||||
|
||||
All notable changes to Bigcapital server-side will be in this file.
|
||||
|
||||
# [0.20.5]
|
||||
|
||||
* fix: Disable tabs of the pdf customization if the first field not filed up by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/701
|
||||
* fix: Invoice form layout by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/705
|
||||
* refactor: Invoice, estimate, receipt, credit note and payment received date input fields by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/707
|
||||
* feat: Add customize templates button to edit forms by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/708
|
||||
* feat: Track account, invoice and item viewed events by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/709
|
||||
|
||||
# [0.20.4]
|
||||
|
||||
* fix: Delete company logo from the PDF template by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/699
|
||||
* fix: Set max width/height to company logo of pdf templates by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/700
|
||||
|
||||
# [0.20.3]
|
||||
|
||||
* feat: Assign default PDF template automatically by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/687
|
||||
* fix: pdf template addresses controlling by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/688
|
||||
* fix: Remove empty lines from address formats by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/690
|
||||
* fix: Pdf templates layout by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/691
|
||||
* feat: Download invoice pdf of the payment link by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/689
|
||||
* fix: Display country name by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/693
|
||||
* feat: Add shared packages to Docker container by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/694
|
||||
|
||||
# [0.20.2]
|
||||
|
||||
* feat: Assign default PDF template automatically by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/687
|
||||
* fix: pdf template addresses controlling by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/688
|
||||
* fix: Remove empty lines from address formats by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/690
|
||||
* fix: Pdf templates layout by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/691
|
||||
* feat: Download invoice pdf of the payment link by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/689
|
||||
* fix: Display country name by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/693
|
||||
* feat: Add shared packages to Docker container by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/694
|
||||
|
||||
# [0.20.1]
|
||||
|
||||
* fix: Getting uploaded object uri by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/684
|
||||
|
||||
# [0.20.0]
|
||||
|
||||
* feat: Customize pdf templates by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/667
|
||||
* feat: Onboard accounts to Stripe Connect by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/668
|
||||
* feat: Upload company logo to invoice templates by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/670
|
||||
* fix: Invoice pdf customize by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/672
|
||||
* fix: Invoice customize bugs by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/673
|
||||
* feat: Clean up payment links endpoints by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/674
|
||||
* feat: Hook up company logo to server-side pdf templates by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/675
|
||||
* feat: Company branding preferences by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/677
|
||||
* feat: Pdf templates customer/company addresses by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/678
|
||||
* fix: Listen to Stripe session completed event by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/679
|
||||
* feat: Track pdf templates Posthog events by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/680
|
||||
* fix: Branding customize content by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/681
|
||||
* feat: Listen to Stripe integration events by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/682
|
||||
* feat: Hook up customer/company address to invoice preview of payment page by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/683
|
||||
|
||||
# [0.19.17]
|
||||
|
||||
* fix: Un-categorize bank transactions by @abouolia in https://github.com/bigcapitalhq/bigcapital/pull/663
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<a href="https://github.com/bigcapitalhq/bigcapital/commits/develop">
|
||||
<img src="https://img.shields.io/github/commit-activity/m/bigcapitalhq/bigcapital/develop" />
|
||||
</a>
|
||||
<a href="https://hub.docker.com/u/bigcapitalhq">
|
||||
<img src="https://img.shields.io/docker/pulls/bigcapitalhq/webapp" />
|
||||
</a>
|
||||
<a href="https://discord.com/invite/c8nPBJafeb">
|
||||
<img src="https://img.shields.io/discord/1066514716752625725?label=Discord" alt="" />
|
||||
</a>
|
||||
@@ -130,6 +133,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oleynikd"><img src="https://avatars.githubusercontent.com/u/3976868?v=4?s=100" width="100px;" alt="Denis"/><br /><sub><b>Denis</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Aoleynikd" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://myself.vercel.app/"><img src="https://avatars.githubusercontent.com/u/42431274?v=4?s=100" width="100px;" alt="Sachin Mittal"/><br /><sub><b>Sachin Mittal</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Amittalsam98" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://www.camilooviedo.com/"><img src="https://avatars.githubusercontent.com/u/64604272?v=4?s=100" width="100px;" alt="Camilo Oviedo"/><br /><sub><b>Camilo Oviedo</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/commits?author=Champetaman" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://nklmantey.com/"><img src="https://avatars.githubusercontent.com/u/90279429?v=4?s=100" width="100px;" alt="Mantey"/><br /><sub><b>Mantey</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Anklmantey" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"version": "independent",
|
||||
"npmClient": "pnpm",
|
||||
"packages": [
|
||||
"packages/*"
|
||||
"packages/*",
|
||||
"shared/*"
|
||||
]
|
||||
}
|
||||
|
||||
13
package.json
13
package.json
@@ -4,11 +4,11 @@
|
||||
"scripts": {
|
||||
"dev": "lerna run dev",
|
||||
"build": "lerna run build",
|
||||
"dev:webapp": "lerna run dev --scope \"@bigcapital/webapp\"",
|
||||
"build:webapp": "lerna run build --scope \"@bigcapital/webapp\"",
|
||||
"dev:server": "lerna run dev --scope \"@bigcapital/server\"",
|
||||
"build:server": "lerna run build --scope \"@bigcapital/server\"",
|
||||
"serve:server": "lerna run serve --scope \"@bigcapital/server\"",
|
||||
"dev:webapp": "lerna run dev --scope \"@bigcapital/webapp\" --scope \"@bigcapital/utils\" --scope \"@bigcapital/pdf-templates\"",
|
||||
"build:webapp": "lerna run build --scope \"@bigcapital/webapp\" --scope \"@bigcapital/utils\" --scope \"@bigcapital/pdf-templates\"",
|
||||
"dev:server": "lerna run dev --scope \"@bigcapital/server\" --scope \"@bigcapital/utils\" --scope \"@bigcapital/pdf-templates\" --scope \"@bigcapital/email-components\"",
|
||||
"build:server": "lerna run build --scope \"@bigcapital/server\" --scope \"@bigcapital/utils\" --scope \"@bigcapital/pdf-templates\" --scope \"@bigcapital/email-components\"",
|
||||
"serve:server": "lerna run serve --scope \"@bigcapital/server\" --scope \"@bigcapital/utils\"",
|
||||
"test:e2e": "playwright test",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
@@ -29,5 +29,8 @@
|
||||
"hooks": {
|
||||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"tsup": "^8.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,11 +90,7 @@ RUN chown node:node /
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Copy application dependency manifests to the container image.
|
||||
COPY ./package*.json ./
|
||||
COPY ./pnpm-lock.yaml ./pnpm-lock.yaml
|
||||
COPY ./lerna.json ./lerna.json
|
||||
COPY ./pnpm-workspace.yaml ./pnpm-workspace.yaml
|
||||
COPY ./packages/server/package*.json ./packages/server/
|
||||
COPY --chown=node:node ./ ./
|
||||
|
||||
# Install application dependencies
|
||||
RUN apk update
|
||||
@@ -109,6 +105,6 @@ RUN pnpm install
|
||||
COPY --chown=node:node ./packages/server ./packages/server
|
||||
|
||||
# # Creates a "dist" folder with the production build
|
||||
RUN npm run build:server --skip-nx-cache
|
||||
RUN pnpm run build:server --skip-nx-cache
|
||||
|
||||
CMD [ "node", "./packages/server/build/index.js" ]
|
||||
@@ -20,6 +20,9 @@
|
||||
"bigcapital": "./bin/bigcapital.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bigcapital/utils": "*",
|
||||
"@bigcapital/email-components": "*",
|
||||
"@bigcapital/pdf-templates": "*",
|
||||
"@aws-sdk/client-s3": "^3.576.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.583.0",
|
||||
"@casl/ability": "^5.4.3",
|
||||
@@ -109,11 +112,13 @@
|
||||
"rtl-detect": "^1.0.4",
|
||||
"socket.io": "^4.7.4",
|
||||
"source-map-loader": "^4.0.1",
|
||||
"stripe": "^16.10.0",
|
||||
"tmp-promise": "^3.0.3",
|
||||
"ts-transformer-keys": "^0.4.2",
|
||||
"tsyringe": "^4.3.0",
|
||||
"typedi": "^0.8.0",
|
||||
"uniqid": "^5.2.0",
|
||||
"uuid": "^10.0.0",
|
||||
"winston": "^3.2.1",
|
||||
"xlsx": "^0.18.5",
|
||||
"yup": "^0.28.1"
|
||||
|
||||
@@ -10,21 +10,37 @@ block head
|
||||
position: relative;
|
||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
||||
}
|
||||
.#{prefix}-header{
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
flex: 0 0 auto;
|
||||
-webkit-box-align: start;
|
||||
align-items: start;
|
||||
-webkit-box-pack: start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
.#{prefix}-header-details{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 20px;
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
.#{prefix}-big-title {
|
||||
font-size: 60px;
|
||||
font-size: 30px;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
margin-bottom: 25px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
.#{prefix}-logo-wrap {
|
||||
height: 120px;
|
||||
width: 120px;
|
||||
position: absolute;
|
||||
right: 26px;
|
||||
top: 26px;
|
||||
overflow: hidden;
|
||||
.#{prefix}-logo-wrap img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 260px;
|
||||
max-height: 100px;
|
||||
}
|
||||
.#{prefix}-terms-list {
|
||||
display: flex;
|
||||
@@ -48,8 +64,8 @@ block head
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
-webkit-box-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-align: flex-start;
|
||||
align-items: flex-start;
|
||||
-webkit-box-pack: start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
@@ -92,7 +108,14 @@ block head
|
||||
.#{prefix}-table__cell--right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.#{prefix}-table__cell--item .item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.#{prefix}-table__cell--item .item .item__description{
|
||||
color: #5f6b7c;
|
||||
}
|
||||
.#{prefix}-totals {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -127,54 +150,60 @@ block head
|
||||
color: #666;
|
||||
}
|
||||
.#{prefix}-statement__value {
|
||||
/* Styles for statement value */
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
block content
|
||||
div(class=`${prefix}-root`)
|
||||
div(class=`${prefix}-big-title`) Credit Note
|
||||
|
||||
if showCompanyLogo
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(src=companyLogo alt=`Company Logo`)
|
||||
|
||||
div(class=`${prefix}-terms-list`)
|
||||
if showCreditNoteNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{creditNoteNumberLabel}:
|
||||
div(class=`${prefix}-terms-item__value`) #{creditNoteNumebr}
|
||||
//- Header (includes big title, details and logo)
|
||||
div(class=`${prefix}-header`)
|
||||
//- Header details (includes big title and details)
|
||||
div(class=`${prefix}-header-details`)
|
||||
div(class=`${prefix}-big-title`) Credit Note
|
||||
|
||||
if showCreditNoteDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{creditNoteDateLabel}:
|
||||
div(class=`${prefix}-terms-item__value`) #{creditNoteDate}
|
||||
div(class=`${prefix}-terms-list`)
|
||||
if showCreditNoteNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{creditNoteNumberLabel}:
|
||||
div(class=`${prefix}-terms-item__value`) #{creditNoteNumebr}
|
||||
|
||||
if showCreditNoteDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{creditNoteDateLabel}:
|
||||
div(class=`${prefix}-terms-item__value`) #{creditNoteDate}
|
||||
|
||||
if showCompanyLogo && companyLogoUri
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(src=companyLogoUri alt=`Company Logo`)
|
||||
|
||||
div(class=`${prefix}-address-section`)
|
||||
if showBilledFromAddress
|
||||
div(class=`${prefix}-address`)
|
||||
strong #{companyName}
|
||||
each address in billedFromAddress
|
||||
div #{address}
|
||||
if showBilledToAddress
|
||||
div(class=`${prefix}-address`)
|
||||
if showCompanyAddress
|
||||
div(class=`${prefix}-address-from`)
|
||||
div !{companyAddress}
|
||||
|
||||
if showCustomerAddress
|
||||
div(class=`${prefix}-address-to`)
|
||||
strong #{billedToLabel}
|
||||
each address in billedToAddress
|
||||
div #{address}
|
||||
div !{customerAddress}
|
||||
|
||||
table(class=`${prefix}-table`)
|
||||
thead
|
||||
tr
|
||||
th(class=`${prefix}-table__header`) #{'Item'}
|
||||
th(class=`${prefix}-table__header`) #{'Description'}
|
||||
th(class=`${prefix}-table__header`) #{'Rate'}
|
||||
th(class=`${prefix}-table__header`) #{'Total'}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--item`) #{'Item'}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--quantity ${prefix}-table__header--right`) #{'Quantity'}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--rate ${prefix}-table__header--right`) #{'Rate'}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--total ${prefix}-table__header--right`) #{'Total'}
|
||||
tbody
|
||||
each line in lines
|
||||
tr(class=`${prefix}-table__row`)
|
||||
td(class=`${prefix}-table__cell`) #{line.item}
|
||||
td(class=`${prefix}-table__cell`) #{line.description}
|
||||
td(class=`${prefix}-table__cell--right`) #{line.rate}
|
||||
td(class=`${prefix}-table__cell--right`) #{line.total}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--item ${prefix}-table__cell--item`)
|
||||
div.item
|
||||
div.item__label #{line.item}
|
||||
div.item__description #{line.description}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--quantity ${prefix}-table__cell--right`) #{line.quantity}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--rate ${prefix}-table__cell--right`) #{line.rate}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--total ${prefix}-table__cell--right`) #{line.total}
|
||||
|
||||
div(class=`${prefix}-totals`)
|
||||
if showSubtotal
|
||||
@@ -187,12 +216,12 @@ block content
|
||||
div(class=`${prefix}-totals__item-amount`) #{totalLabel}:
|
||||
div(class=`${prefix}-totals__item-label`) #{total}
|
||||
|
||||
if showCustomerNote
|
||||
if showCustomerNote && customerNote
|
||||
div(class=`${prefix}-statement`)
|
||||
div(class=`${prefix}-statement__label`) #{customerNoteLabel}:
|
||||
div(class=`${prefix}-statement__value`) #{customerNote}
|
||||
|
||||
if showTermsConditions
|
||||
if showTermsConditions && termsConditions
|
||||
div(class=`${prefix}-statement`)
|
||||
div(class=`${prefix}-statement__label`) #{termsConditionsLabel}:
|
||||
div(class=`${prefix}-statement__value`) #{termsConditions}
|
||||
|
||||
@@ -10,21 +10,37 @@ block head
|
||||
position: relative;
|
||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
||||
}
|
||||
.#{prefix}-header {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
flex: 0 0 auto;
|
||||
-webkit-box-align: start;
|
||||
align-items: start;
|
||||
-webkit-box-pack: start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
.#{prefix}-header-details {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 20px;
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
.#{prefix}-big-title {
|
||||
font-size: 60px;
|
||||
font-size: 30px;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
margin-bottom: 25px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
.#{prefix}-logo-wrap {
|
||||
height: 120px;
|
||||
width: 120px;
|
||||
position: absolute;
|
||||
right: 26px;
|
||||
top: 26px;
|
||||
overflow: hidden;
|
||||
.#{prefix}-logo-wrap img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 260px;
|
||||
max-height: 100px;
|
||||
}
|
||||
.#{prefix}-terms {
|
||||
display: flex;
|
||||
@@ -47,9 +63,7 @@ block head
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
-webkit-box-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: start;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
margin-bottom: 24px;
|
||||
@@ -82,6 +96,9 @@ block head
|
||||
.#{prefix}-table__header--right {
|
||||
text-align: right;
|
||||
}
|
||||
.#{prefix}-table__header--item{
|
||||
width: 50%;
|
||||
}
|
||||
.#{prefix}-table__cell {
|
||||
border-bottom: 1px solid #F6F6F6;
|
||||
padding: 12px 10px;
|
||||
@@ -95,6 +112,14 @@ block head
|
||||
.#{prefix}-table__cell:last-of-type {
|
||||
padding-right: 0;
|
||||
}
|
||||
.#{prefix}-table__cell--item .item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.#{prefix}-table__cell--item .item .item__description{
|
||||
color: #5f6b7c;
|
||||
}
|
||||
.#{prefix}-totals {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -129,60 +154,70 @@ block head
|
||||
color: #666;
|
||||
}
|
||||
.#{prefix}-statement__value {
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
block content
|
||||
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
||||
h1(class=`${prefix}-big-title`) Estimate
|
||||
|
||||
if showCompanyLogo
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(alt="", src=companyLogo)
|
||||
//- Header (invluces big title, details and logo)
|
||||
div(class=`${prefix}-header`)
|
||||
|
||||
//- Terms List
|
||||
div(class=`${prefix}-terms`)
|
||||
if showEstimateNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{estimateNumberLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{estimateNumebr}
|
||||
if showEstimateDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{estimateDateLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{estimateDate}
|
||||
if showExpirationDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{expirationDateLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{expirationDate}
|
||||
//- Header details (includes big title and details )
|
||||
div(class=`${prefix}-header-details`)
|
||||
h1(class=`${prefix}-big-title`) Estimate
|
||||
|
||||
//- Terms List
|
||||
div(class=`${prefix}-terms`)
|
||||
if showEstimateNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{estimateNumberLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{estimateNumebr}
|
||||
|
||||
if showEstimateDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{estimateDateLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{estimateDate}
|
||||
|
||||
if showExpirationDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{expirationDateLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{expirationDate}
|
||||
|
||||
//- Company logo
|
||||
if showCompanyLogo && companyLogoUri
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(alt="Company logo", src=companyLogoUri)
|
||||
|
||||
//- Addresses (Group section)
|
||||
div(class=`${prefix}-addresses`)
|
||||
if showBilledFromAddress
|
||||
div(class=`${prefix}-address`)
|
||||
strong #{companyName}
|
||||
each item in billedFromAddress
|
||||
div(class=`${prefix}-address__item`) #{item}
|
||||
if showCompanyAddress
|
||||
div(class=`${prefix}-address-from`)
|
||||
div !{companyAddress}
|
||||
|
||||
if showBilledToAddress
|
||||
div(class=`${prefix}-address`)
|
||||
if showCustomerAddress
|
||||
div(class=`${prefix}-address-to`)
|
||||
strong #{billedToLabel}
|
||||
each item in billedToAddress
|
||||
div(class=`${prefix}-address__item`) #{item}
|
||||
div !{customerAddress}
|
||||
|
||||
//- Table section (Line items)
|
||||
table(class=`${prefix}-table`)
|
||||
thead
|
||||
tr
|
||||
th(class=`${prefix}-table__header`) Item
|
||||
th(class=`${prefix}-table__header`) Description
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--right`) Rate
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--right`) Total
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--item`) Item
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--quantity ${prefix}-table__header--right`) Qty
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--rate ${prefix}-table__header--right`) Rate
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--total ${prefix}-table__header--right`) Total
|
||||
tbody
|
||||
each line in lines
|
||||
tr
|
||||
td(class=`${prefix}-table__cell`) #{line.item}
|
||||
td(class=`${prefix}-table__cell`) #{line.description}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.rate}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.total}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--item`)
|
||||
div.item
|
||||
div.item__label #{line.item}
|
||||
div.item__description #{line.description}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--quantity ${prefix}-table__cell--right`) #{line.quantity}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--rate ${prefix}-table__cell--right`) #{line.rate}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--total ${prefix}-table__cell--right`) #{line.total}
|
||||
|
||||
//- Totals section
|
||||
div(class=`${prefix}-totals`)
|
||||
@@ -196,12 +231,12 @@ block content
|
||||
div(class=`${prefix}-totals__item-amount`) #{total}
|
||||
|
||||
//- Statements section
|
||||
if showTermsConditions && termsConditions
|
||||
div(class=`${prefix}-statement`)
|
||||
div(class=`${prefix}-statement__label`) #{termsConditionsLabel}
|
||||
div(class=`${prefix}-statement__value`) #{termsConditions}
|
||||
|
||||
if showCustomerNote && customerNote
|
||||
div(class=`${prefix}-statement`)
|
||||
div(class=`${prefix}-statement__label`) #{customerNoteLabel}
|
||||
div(class=`${prefix}-statement__value`) #{customerNote}
|
||||
|
||||
if showTermsConditions && termsConditions
|
||||
div(class=`${prefix}-statement`)
|
||||
div(class=`${prefix}-statement__label`) #{termsConditionsLabel}
|
||||
div(class=`${prefix}-statement__value`) #{termsConditions}
|
||||
@@ -10,21 +10,37 @@ block head
|
||||
position: relative;
|
||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
||||
}
|
||||
.#{prefix}-header{
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
flex: 0 0 auto;
|
||||
-webkit-box-align: start;
|
||||
align-items: start;
|
||||
-webkit-box-pack: start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
.#{prefix}-header-details{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 20px;
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
.#{prefix}-big-title {
|
||||
font-size: 60px;
|
||||
font-size: 30px;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
margin-bottom: 25px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
.#{prefix}-logo-wrap {
|
||||
height: 120px;
|
||||
width: 120px;
|
||||
position: absolute;
|
||||
right: 26px;
|
||||
top: 26px;
|
||||
overflow: hidden;
|
||||
.#{prefix}-logo-wrap img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 260px;
|
||||
max-height: 100px;
|
||||
}
|
||||
.#{prefix}-details {
|
||||
display: flex;
|
||||
@@ -48,9 +64,7 @@ block head
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
-webkit-box-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: start;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
margin-bottom: 24px;
|
||||
@@ -88,6 +102,9 @@ block head
|
||||
.#{prefix}-table__header--right {
|
||||
text-align: right;
|
||||
}
|
||||
.#{prefix}-table__header--item {
|
||||
width: 50%;
|
||||
}
|
||||
.#{prefix}-table__cell {
|
||||
border-bottom: 1px solid #F6F6F6;
|
||||
padding: 12px 10px;
|
||||
@@ -101,6 +118,14 @@ block head
|
||||
.#{prefix}-table__cell--right {
|
||||
text-align: right;
|
||||
}
|
||||
.#{prefix}-table__cell--item .item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.#{prefix}-table__cell--item .item__description {
|
||||
color: #5f6b7c;
|
||||
}
|
||||
.#{prefix}-totals {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -135,63 +160,68 @@ block head
|
||||
color: #666;
|
||||
}
|
||||
.#{prefix}-paragraph__value {
|
||||
/* Styles for values within the paragraph section */
|
||||
white-space: pre-line;
|
||||
}
|
||||
block content
|
||||
//- block head
|
||||
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
||||
|
||||
//- Title and company logo
|
||||
h1(class=`${prefix}-big-title`) Invoice
|
||||
|
||||
if showCompanyLogo
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(alt="", src=companyLogo)
|
||||
//- Header (includes big title, details and logo )
|
||||
div(class=`${prefix}-header`)
|
||||
//- Header details (includes big title and details )
|
||||
div(class=`${prefix}-header-details`)
|
||||
//- Title and company logo
|
||||
h1(class=`${prefix}-big-title`) Invoice
|
||||
|
||||
//- Invoice details
|
||||
div(class=`${prefix}-details`)
|
||||
if showInvoiceNumber
|
||||
div(class=`${prefix}-detail`)
|
||||
div(class=`${prefix}-detail__label`) #{invoiceNumberLabel}
|
||||
div(class=`${prefix}-detail__value`) #{invoiceNumber}
|
||||
//- Invoice details
|
||||
div(class=`${prefix}-details`)
|
||||
if showInvoiceNumber
|
||||
div(class=`${prefix}-detail`)
|
||||
div(class=`${prefix}-detail__label`) #{invoiceNumberLabel}
|
||||
div(class=`${prefix}-detail__value`) #{invoiceNumber}
|
||||
|
||||
if showDateIssue
|
||||
div(class=`${prefix}-detail`)
|
||||
div(class=`${prefix}-detail__label`) #{dateIssueLabel}
|
||||
div(class=`${prefix}-detail__value`) #{dateIssue}
|
||||
if showDateIssue
|
||||
div(class=`${prefix}-detail`)
|
||||
div(class=`${prefix}-detail__label`) #{dateIssueLabel}
|
||||
div(class=`${prefix}-detail__value`) #{dateIssue}
|
||||
|
||||
if showDueDate
|
||||
div(class=`${prefix}-detail`)
|
||||
div(class=`${prefix}-detail__label`) #{dueDateLabel}
|
||||
div(class=`${prefix}-detail__value`) #{dueDate}
|
||||
if showDueDate
|
||||
div(class=`${prefix}-detail`)
|
||||
div(class=`${prefix}-detail__label`) #{dueDateLabel}
|
||||
div(class=`${prefix}-detail__value`) #{dueDate}
|
||||
|
||||
//- Company logo
|
||||
if showCompanyLogo && companyLogoUri
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(alt="Company logo", src=companyLogoUri)
|
||||
|
||||
//- Address section
|
||||
div(class=`${prefix}-address-root`)
|
||||
if showBilledFromAddress
|
||||
if showCompanyAddress
|
||||
div(class=`${prefix}-address-from`)
|
||||
strong #{companyName}
|
||||
each item in billedFromAddres
|
||||
div(class=`${prefix}-address-from__item`) #{item}
|
||||
div !{companyAddress}
|
||||
|
||||
if showBillingToAddress
|
||||
if showCustomerAddress
|
||||
div(class=`${prefix}-address-to`)
|
||||
strong #{billedToLabel}
|
||||
each item in billedToAddress
|
||||
div(class=`${prefix}-address-to__item`) #{item}
|
||||
div !{customerAddress}
|
||||
|
||||
//- Invoice table
|
||||
table(class=`${prefix}-table`)
|
||||
thead
|
||||
tr
|
||||
th(class=`${prefix}-table__header`) #{lineItemLabel}
|
||||
th(class=`${prefix}-table__header`) #{lineDescriptionLabel}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--right`) #{lineRateLabel}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--right`) #{lineTotalLabel}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--item`) #{lineItemLabel}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--quantity ${prefix}-table__header--right`) #{lineQuantityLabel}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--rate ${prefix}-table__header--right`) #{lineRateLabel}
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--total ${prefix}-table__header--right`) #{lineTotalLabel}
|
||||
tbody
|
||||
each line in lines
|
||||
tr
|
||||
td(class=`${prefix}-table__cell`) #{line.item}
|
||||
td(class=`${prefix}-table__cell`) #{line.description}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--item`)
|
||||
div.item
|
||||
div.item__label #{line.item}
|
||||
div.item__description #{line.description}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.quantity}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.rate}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.total}
|
||||
|
||||
|
||||
@@ -10,22 +10,38 @@ block head
|
||||
font-size: 12px;
|
||||
position: relative;
|
||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
||||
}
|
||||
.#{prefix}-header{
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
flex: 0 0 auto;
|
||||
-webkit-box-align: start;
|
||||
align-items: start;
|
||||
-webkit-box-pack: start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
.#{prefix}-header-details{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 20px;
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
.#{prefix}-big-title{
|
||||
font-size: 60px;
|
||||
font-size: 30px;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
margin-bottom: 25px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
.#{prefix}-logo-wrap{
|
||||
height: 120px;
|
||||
width: 120px;
|
||||
position: absolute;
|
||||
right: 26px;
|
||||
top: 26px;
|
||||
overflow: hidden;
|
||||
.#{prefix}-logo-wrap img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 260px;
|
||||
max-height: 100px;
|
||||
}
|
||||
.#{prefix}-terms-list{
|
||||
display: flex;
|
||||
@@ -46,9 +62,7 @@ block head
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
-webkit-box-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: start;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
margin-bottom: 24px;
|
||||
@@ -122,35 +136,35 @@ block head
|
||||
}
|
||||
block content
|
||||
div(class=`${prefix}-root`)
|
||||
div(class=`${prefix}-big-title`) Payment
|
||||
//- Header (includes big title, details and logo )
|
||||
div(class=`${prefix}-header`)
|
||||
//- Header details (includes big title and details )
|
||||
div(class=`${prefix}-header-details`)
|
||||
div(class=`${prefix}-big-title`) Payment
|
||||
div(class=`${prefix}-terms-list`)
|
||||
if showPaymentReceivedNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{paymentReceivedNumberLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{paymentReceivedNumebr}
|
||||
|
||||
if showCompanyLogo
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(src=companyLogo alt="Company Logo")
|
||||
|
||||
div(class=`${prefix}-terms-list`)
|
||||
if showPaymentReceivedNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{paymentReceivedNumberLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{paymentReceivedNumebr}
|
||||
if showPaymentReceivedDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{paymentReceivedDateLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{paymentReceivedDate}
|
||||
|
||||
if showPaymentReceivedDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
div(class=`${prefix}-terms-item__label`) #{paymentReceivedDateLabel}
|
||||
div(class=`${prefix}-terms-item__value`) #{paymentReceivedDate}
|
||||
|
||||
if showCompanyLogo && companyLogoUri
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(src=companyLogoUri alt="Company Logo")
|
||||
|
||||
div(class=`${prefix}-addresses`)
|
||||
if showBilledFromAddress
|
||||
div(class=`${prefix}-address`)
|
||||
strong(class=`${prefix}-address__item`) #{companyName}
|
||||
each addressLine in billedFromAddress
|
||||
div(class=`${prefix}-address__item`) #{addressLine}
|
||||
if showCompanyAddress
|
||||
div(class=`${prefix}-address-from`)
|
||||
div !{companyAddress}
|
||||
|
||||
if showBillingToAddress
|
||||
div(class=`${prefix}-address`)
|
||||
strong(class=`${prefix}-address__item`) #{billedToLabel}
|
||||
each addressLine in billedToAddress
|
||||
div(class=`${prefix}-address__item`) #{addressLine}
|
||||
if showCustomerAddress
|
||||
div(class=`${prefix}-address-to`)
|
||||
strong #{billedToLabel}
|
||||
div !{customerAddress}
|
||||
|
||||
table(class=`${prefix}-table`)
|
||||
thead
|
||||
|
||||
@@ -10,19 +10,33 @@ block head
|
||||
position: relative;
|
||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
||||
}
|
||||
.#{prefix}-logo-wrap {
|
||||
height: 120px;
|
||||
width: 120px;
|
||||
position: absolute;
|
||||
right: 26px;
|
||||
top: 26px;
|
||||
overflow: hidden;
|
||||
.#{prefix}-header{
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
flex: 0 0 auto;
|
||||
align-items: start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
.#{prefix}-header-details{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 20px;
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
.#{prefix}-logo-wrap img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 260px;
|
||||
max-height: 100px;
|
||||
}
|
||||
.#{prefix}-big-title {
|
||||
font-size: 60px;
|
||||
font-size: 30px;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
margin-bottom: 25px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
@@ -46,8 +60,8 @@ block head
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-flow: wrap;
|
||||
-webkit-box-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-align: flex-start;
|
||||
align-items: flex-start;
|
||||
-webkit-box-pack: start;
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
@@ -78,6 +92,9 @@ block head
|
||||
.#{prefix}-table__header--right {
|
||||
text-align: right;
|
||||
}
|
||||
.#{prefix}-table__header--item{
|
||||
width: 50%;
|
||||
}
|
||||
.#{prefix}-table__cell {
|
||||
border-bottom: 1px solid #F6F6F6;
|
||||
padding: 12px 10px;
|
||||
@@ -91,6 +108,14 @@ block head
|
||||
.#{prefix}-table__cell--right {
|
||||
text-align: right;
|
||||
}
|
||||
.#{prefix}-table__cell--item .item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.#{prefix}-table__cell--item .item .item__description{
|
||||
color: #5f6b7c;
|
||||
}
|
||||
.#{prefix}-totals {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -119,59 +144,67 @@ block head
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.#{prefix}-statement__label {}
|
||||
.#{prefix}-statement__value {}
|
||||
.#{prefix}-statement__value {
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
block content
|
||||
//- block head
|
||||
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
||||
|
||||
//- Title and company logo
|
||||
h1(class=`${prefix}-big-title`) Receipt
|
||||
|
||||
if showCompanyLogo
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(src=companyLogo alt=`Company Logo`)
|
||||
//- Header (includes big title, details and logo )
|
||||
div(class=`${prefix}-header`)
|
||||
//- Header details (includes big title and details )
|
||||
div(class=`${prefix}-header-details`)
|
||||
//- Title and company logo
|
||||
h1(class=`${prefix}-big-title`) Receipt
|
||||
|
||||
//- Terms List
|
||||
div(class=`${prefix}-terms-list`)
|
||||
if showReceiptNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
span(class=`${prefix}-terms-item__label`)= receiptNumberLabel
|
||||
span(class=`${prefix}-terms-item__value`)= receiptNumber
|
||||
if showReceiptDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
span(class=`${prefix}-terms-item__label`)= receiptDateLabel
|
||||
span(class=`${prefix}-terms-item__value`)= receiptDate
|
||||
//- Terms List
|
||||
div(class=`${prefix}-terms-list`)
|
||||
if showReceiptNumber
|
||||
div(class=`${prefix}-terms-item`)
|
||||
span(class=`${prefix}-terms-item__label`)= receiptNumberLabel
|
||||
span(class=`${prefix}-terms-item__value`)= receiptNumber
|
||||
|
||||
if showReceiptDate
|
||||
div(class=`${prefix}-terms-item`)
|
||||
span(class=`${prefix}-terms-item__label`)= receiptDateLabel
|
||||
span(class=`${prefix}-terms-item__value`)= receiptDate
|
||||
|
||||
//- Company logo
|
||||
if showCompanyLogo && companyLogoUri
|
||||
div(class=`${prefix}-logo-wrap`)
|
||||
img(src=companyLogoUri alt=`Company Logo`)
|
||||
|
||||
//- Address Section
|
||||
div(class=`${prefix}-address-section`)
|
||||
if showBilledFromAddress
|
||||
div(class=`${prefix}-address`)
|
||||
strong= companyName
|
||||
each addressLine in billedFromAddress
|
||||
div= addressLine
|
||||
if showCompanyAddress
|
||||
div(class=`${prefix}-address-from`)
|
||||
div !{companyAddress}
|
||||
|
||||
if showBilledToAddress
|
||||
div(class=`${prefix}-address`)
|
||||
strong= billedToLabel
|
||||
each addressLine in billedToAddress
|
||||
div= addressLine
|
||||
if showCustomerAddress
|
||||
div(class=`${prefix}-address-to`)
|
||||
strong #{billedToLabel}
|
||||
div !{customerAddress}
|
||||
|
||||
//- Table Section
|
||||
table(class=`${prefix}-table`)
|
||||
thead(class=`${prefix}-table__header`)
|
||||
tr
|
||||
th(class=`${prefix}-table__header`) Item
|
||||
th(class=`${prefix}-table__header`) Description
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--right`) Rate
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--right`) Total
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--item`) Item
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--quantity ${prefix}-table__header--right`) Qty
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--rate ${prefix}-table__header--right`) Rate
|
||||
th(class=`${prefix}-table__header ${prefix}-table__header--total ${prefix}-table__header--right`) Total
|
||||
tbody
|
||||
each line in lines
|
||||
tr(class=`${prefix}-table__row`)
|
||||
td(class=`${prefix}-table__cell`)= line.item
|
||||
td(class=`${prefix}-table__cell`)= line.description
|
||||
td(class=`${prefix}-table__cell${prefix}-table__cell--right`)= line.rate
|
||||
td(class=`${prefix}-table__cell${prefix}-table__cell--right`)= line.total
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--item`)
|
||||
div.item
|
||||
div.item__label #{line.item}
|
||||
div.item__description #{line.description}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.quantity}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.rate}
|
||||
td(class=`${prefix}-table__cell ${prefix}-table__cell--right`) #{line.total}
|
||||
|
||||
//- Totals Section
|
||||
div(class=`${prefix}-totals`)
|
||||
@@ -186,13 +219,13 @@ block content
|
||||
span(class=`${prefix}-totals__line__amount`)= total
|
||||
|
||||
//- Customer Note Section
|
||||
if showCustomerNote
|
||||
if showCustomerNote && customerNote
|
||||
div(class=`${prefix}-statement`)
|
||||
div(class=`${prefix}-statement__label`)= customerNoteLabel
|
||||
div(class=`${prefix}-statement__value`)= customerNote
|
||||
|
||||
//- Terms & Conditions Section
|
||||
if showTermsConditions
|
||||
if showTermsConditions && termsConditions
|
||||
div(class=`${prefix}-statement`)
|
||||
div(class=`${prefix}-statement__label`)= termsConditionsLabel
|
||||
div(class=`${prefix}-statement__value`)= termsConditions
|
||||
|
||||
@@ -18,7 +18,7 @@ import BaseController from '@/api/controllers/BaseController';
|
||||
@Service()
|
||||
export default class OrganizationController extends BaseController {
|
||||
@Inject()
|
||||
organizationService: OrganizationService;
|
||||
private organizationService: OrganizationService;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
@@ -56,10 +56,10 @@ export default class OrganizationController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Organization setup schema.
|
||||
* @return {ValidationChain[]}
|
||||
* Build organization validation schema.
|
||||
* @returns {ValidationChain[]}
|
||||
*/
|
||||
private get commonOrganizationValidationSchema(): ValidationChain[] {
|
||||
private get buildOrganizationValidationSchema(): ValidationChain[] {
|
||||
return [
|
||||
check('name').exists().trim(),
|
||||
check('industry').optional({ nullable: true }).isString().trim(),
|
||||
@@ -72,21 +72,34 @@ export default class OrganizationController extends BaseController {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build organization validation schema.
|
||||
* @returns {ValidationChain[]}
|
||||
*/
|
||||
private get buildOrganizationValidationSchema(): ValidationChain[] {
|
||||
return [...this.commonOrganizationValidationSchema];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update organization validation schema.
|
||||
* @returns {ValidationChain[]}
|
||||
*/
|
||||
private get updateOrganizationValidationSchema(): ValidationChain[] {
|
||||
return [
|
||||
...this.commonOrganizationValidationSchema,
|
||||
// # Profile
|
||||
check('name').optional().trim(),
|
||||
check('industry').optional({ nullable: true }).isString().trim(),
|
||||
check('location').optional().isString().isISO31661Alpha2(),
|
||||
check('base_currency').optional().isISO4217(),
|
||||
check('timezone').optional().isIn(moment.tz.names()),
|
||||
check('fiscal_year').optional().isIn(MONTHS),
|
||||
check('language').optional().isString().isIn(ACCEPTED_LOCALES),
|
||||
check('date_format').optional().isIn(DATE_FORMATS),
|
||||
|
||||
// # Address
|
||||
check('address.address_1').optional().isString().trim(),
|
||||
check('address.address_2').optional().isString().trim(),
|
||||
check('address.postal_code').optional().isString().trim(),
|
||||
check('address.city').optional().isString().trim(),
|
||||
check('address.state_province').optional().isString().trim(),
|
||||
check('address.phone').optional().isString().trim(),
|
||||
|
||||
// # Branding
|
||||
check('primary_color').optional({ nullable: true }).isHexColor().trim(),
|
||||
check('logo_key').optional({ nullable: true }).isString().trim(),
|
||||
|
||||
check('tax_number').optional({ nullable: true }).isString().trim(),
|
||||
];
|
||||
}
|
||||
@@ -156,7 +169,7 @@ export default class OrganizationController extends BaseController {
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const tenantDTO = this.matchedBodyData(req);
|
||||
const tenantDTO = this.matchedBodyData(req, { includeOptionals: false });
|
||||
|
||||
try {
|
||||
await this.organizationService.updateOrganization(tenantId, tenantDTO);
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { Request, Response, Router, NextFunction } from 'express';
|
||||
import { body, param } from 'express-validator';
|
||||
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
|
||||
import BaseController from '@/api/controllers/BaseController';
|
||||
import { PaymentServicesApplication } from '@/services/PaymentServices/PaymentServicesApplication';
|
||||
|
||||
@Service()
|
||||
export class PaymentServicesController extends BaseController {
|
||||
@Inject()
|
||||
private paymentServicesApp: PaymentServicesApplication;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
*/
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
asyncMiddleware(this.getPaymentServicesSpecificInvoice.bind(this))
|
||||
);
|
||||
router.get('/state', this.getPaymentMethodsState.bind(this));
|
||||
router.get('/:paymentServiceId', this.getPaymentService.bind(this));
|
||||
router.post(
|
||||
'/:paymentMethodId',
|
||||
[
|
||||
param('paymentMethodId').exists(),
|
||||
|
||||
body('name').optional().isString(),
|
||||
body('options.bank_account_id').optional().isNumeric(),
|
||||
body('options.clearing_account_id').optional().isNumeric(),
|
||||
],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.updatePaymentMethod.bind(this))
|
||||
);
|
||||
router.delete(
|
||||
'/:paymentMethodId',
|
||||
[param('paymentMethodId').exists()],
|
||||
this.validationResult,
|
||||
this.deletePaymentMethod.bind(this)
|
||||
);
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve accounts types list.
|
||||
* @param {Request} req - Request.
|
||||
* @param {Response} res - Response.
|
||||
* @return {Promise<Response | void>}
|
||||
*/
|
||||
private async getPaymentServicesSpecificInvoice(
|
||||
req: Request<{ invoiceId: number }>,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const paymentServices =
|
||||
await this.paymentServicesApp.getPaymentServicesForInvoice(tenantId);
|
||||
|
||||
return res.status(200).send({ paymentServices });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a specific payment service.
|
||||
* @param {Request} req - Request.
|
||||
* @param {Response} res - Response.
|
||||
* @param {NextFunction} next - Next function.
|
||||
* @return {Promise<Response | void>}
|
||||
*/
|
||||
private async getPaymentService(
|
||||
req: Request<{ paymentServiceId: number }>,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { paymentServiceId } = req.params;
|
||||
|
||||
try {
|
||||
const paymentService = await this.paymentServicesApp.getPaymentService(
|
||||
tenantId,
|
||||
paymentServiceId
|
||||
);
|
||||
|
||||
return res.status(200).send({ data: paymentService });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits the given payment method settings.
|
||||
* @param {Request} req - Request.
|
||||
* @param {Response} res - Response.
|
||||
* @return {Promise<Response | void>}
|
||||
*/
|
||||
private async updatePaymentMethod(
|
||||
req: Request<{ paymentMethodId: number }>,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { paymentMethodId } = req.params;
|
||||
const updatePaymentMethodDTO = this.matchedBodyData(req);
|
||||
|
||||
try {
|
||||
await this.paymentServicesApp.editPaymentMethod(
|
||||
tenantId,
|
||||
paymentMethodId,
|
||||
updatePaymentMethodDTO
|
||||
);
|
||||
return res.status(200).send({
|
||||
id: paymentMethodId,
|
||||
message: 'The given payment method has been updated.',
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the payment state providing state.
|
||||
* @param {Request} req - Request.
|
||||
* @param {Response} res - Response.
|
||||
* @param {NextFunction} next - Next function.
|
||||
* @return {Promise<Response | void>}
|
||||
*/
|
||||
private async getPaymentMethodsState(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const paymentMethodsState =
|
||||
await this.paymentServicesApp.getPaymentMethodsState(tenantId);
|
||||
|
||||
return res.status(200).send({ data: paymentMethodsState });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the given payment method.
|
||||
* @param {Request<{ paymentMethodId: number }>} req - Request.
|
||||
* @param {Response} res - Response.
|
||||
* @param {NextFunction} next - Next function.
|
||||
* @return {Promise<Response | void>}
|
||||
*/
|
||||
private async deletePaymentMethod(
|
||||
req: Request<{ paymentMethodId: number }>,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { paymentMethodId } = req.params;
|
||||
|
||||
try {
|
||||
await this.paymentServicesApp.deletePaymentMethod(
|
||||
tenantId,
|
||||
paymentMethodId
|
||||
);
|
||||
return res.status(204).send({
|
||||
id: paymentMethodId,
|
||||
message: 'The payment method has been deleted.',
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ export class PdfTemplatesController extends BaseController {
|
||||
this.validationResult,
|
||||
this.editPdfTemplate.bind(this)
|
||||
);
|
||||
router.get('/state', this.getOrganizationBrandingState.bind(this));
|
||||
router.get(
|
||||
'/',
|
||||
[query('resource').optional()],
|
||||
@@ -175,4 +176,20 @@ export class PdfTemplatesController extends BaseController {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
async getOrganizationBrandingState(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const data =
|
||||
await this.pdfTemplateApplication.getPdfTemplateBrandingState(tenantId);
|
||||
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import GetCreditNoteAssociatedAppliedInvoices from '@/services/CreditNotes/GetCr
|
||||
import GetRefundCreditTransaction from '@/services/CreditNotes/GetRefundCreditNoteTransaction';
|
||||
import GetCreditNotePdf from '../../../services/CreditNotes/GetCreditNotePdf';
|
||||
import { ACCEPT_TYPE } from '@/interfaces/Http';
|
||||
import { GetCreditNoteState } from '@/services/CreditNotes/GetCreditNoteState';
|
||||
/**
|
||||
* Credit notes controller.
|
||||
* @service
|
||||
@@ -81,6 +82,9 @@ export default class PaymentReceivesController extends BaseController {
|
||||
@Inject()
|
||||
creditNotePdf: GetCreditNotePdf;
|
||||
|
||||
@Inject()
|
||||
getCreditNoteStateService: GetCreditNoteState;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
*/
|
||||
@@ -105,6 +109,12 @@ export default class PaymentReceivesController extends BaseController {
|
||||
this.asyncMiddleware(this.newCreditNote),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/state',
|
||||
CheckPolicies(CreditNoteAction.View, AbilitySubject.CreditNote),
|
||||
this.asyncMiddleware(this.getCreditNoteState.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
// Get specific credit note.
|
||||
router.get(
|
||||
'/:id',
|
||||
@@ -461,13 +471,14 @@ export default class PaymentReceivesController extends BaseController {
|
||||
ACCEPT_TYPE.APPLICATION_PDF,
|
||||
]);
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF === acceptType) {
|
||||
const pdfContent = await this.creditNotePdf.getCreditNotePdf(
|
||||
const [pdfContent, filename] = await this.creditNotePdf.getCreditNotePdf(
|
||||
tenantId,
|
||||
creditNoteId
|
||||
);
|
||||
res.set({
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Length': pdfContent.length,
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
} else {
|
||||
@@ -736,6 +747,23 @@ export default class PaymentReceivesController extends BaseController {
|
||||
}
|
||||
};
|
||||
|
||||
private getCreditNoteState = async (
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) => {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const data = await this.getCreditNoteStateService.getCreditNoteState(
|
||||
tenantId
|
||||
);
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles service errors.
|
||||
* @param {Error} error
|
||||
|
||||
@@ -95,6 +95,12 @@ export default class PaymentReceivesController extends BaseController {
|
||||
asyncMiddleware(this.getPaymentReceiveInvoices.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/state',
|
||||
CheckPolicies(PaymentReceiveAction.View, AbilitySubject.PaymentReceive),
|
||||
this.getPaymentReceivedState.bind(this),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/:id',
|
||||
CheckPolicies(PaymentReceiveAction.View, AbilitySubject.PaymentReceive),
|
||||
@@ -391,6 +397,29 @@ export default class PaymentReceivesController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @async
|
||||
* @param {Request} req -
|
||||
* @param {Response} res -
|
||||
*/
|
||||
private async getPaymentReceivedState(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const data = await this.paymentReceiveApplication.getPaymentReceivedState(
|
||||
tenantId
|
||||
);
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the given payment receive details.
|
||||
* @async
|
||||
@@ -444,7 +473,7 @@ export default class PaymentReceivesController extends BaseController {
|
||||
]);
|
||||
// Response in pdf format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF === acceptType) {
|
||||
const pdfContent =
|
||||
const [pdfContent, filename] =
|
||||
await this.paymentReceiveApplication.getPaymentReceivePdf(
|
||||
tenantId,
|
||||
paymentReceiveId
|
||||
@@ -452,6 +481,7 @@ export default class PaymentReceivesController extends BaseController {
|
||||
res.set({
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Length': pdfContent.length,
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
// Response in json format.
|
||||
|
||||
@@ -51,7 +51,7 @@ export default class SalesEstimatesController extends BaseController {
|
||||
router.post(
|
||||
'/:id/approve',
|
||||
CheckPolicies(SaleEstimateAction.Edit, AbilitySubject.SaleEstimate),
|
||||
[this.validateSpecificEstimateSchema],
|
||||
[...this.validateSpecificEstimateSchema],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.approveSaleEstimate.bind(this)),
|
||||
this.handleServiceErrors
|
||||
@@ -59,7 +59,7 @@ export default class SalesEstimatesController extends BaseController {
|
||||
router.post(
|
||||
'/:id/reject',
|
||||
CheckPolicies(SaleEstimateAction.Edit, AbilitySubject.SaleEstimate),
|
||||
[this.validateSpecificEstimateSchema],
|
||||
[...this.validateSpecificEstimateSchema],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.rejectSaleEstimate.bind(this)),
|
||||
this.handleServiceErrors
|
||||
@@ -105,6 +105,12 @@ export default class SalesEstimatesController extends BaseController {
|
||||
asyncMiddleware(this.deleteEstimate.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/state',
|
||||
CheckPolicies(SaleEstimateAction.View, AbilitySubject.SaleEstimate),
|
||||
this.getSaleEstimateState.bind(this),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/:id',
|
||||
CheckPolicies(SaleEstimateAction.View, AbilitySubject.SaleEstimate),
|
||||
@@ -392,13 +398,15 @@ export default class SalesEstimatesController extends BaseController {
|
||||
]);
|
||||
// Retrieves estimate in pdf format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF == acceptType) {
|
||||
const pdfContent = await this.saleEstimatesApplication.getSaleEstimatePdf(
|
||||
tenantId,
|
||||
estimateId
|
||||
);
|
||||
const [pdfContent, filename] =
|
||||
await this.saleEstimatesApplication.getSaleEstimatePdf(
|
||||
tenantId,
|
||||
estimateId
|
||||
);
|
||||
res.set({
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Length': pdfContent.length,
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
// Retrieves estimates in json format.
|
||||
@@ -546,6 +554,23 @@ export default class SalesEstimatesController extends BaseController {
|
||||
}
|
||||
};
|
||||
|
||||
private getSaleEstimateState = async (
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) => {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const data = await this.saleEstimatesApplication.getSaleEstimateState(
|
||||
tenantId
|
||||
);
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles service errors.
|
||||
* @param {Error} error
|
||||
|
||||
@@ -130,6 +130,12 @@ export default class SaleInvoicesController extends BaseController {
|
||||
this.asyncMiddleware(this.getInvoicePaymentTransactions),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/state',
|
||||
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
||||
asyncMiddleware(this.getSaleInvoiceState.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/:id',
|
||||
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
||||
@@ -138,6 +144,7 @@ export default class SaleInvoicesController extends BaseController {
|
||||
asyncMiddleware(this.getSaleInvoice.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
||||
@@ -172,10 +179,21 @@ export default class SaleInvoicesController extends BaseController {
|
||||
'/:id/mail',
|
||||
[
|
||||
...this.specificSaleInvoiceValidation,
|
||||
body('subject').isString().optional(),
|
||||
|
||||
body('subject').isString().optional({ nullable: true }),
|
||||
body('message').isString().optional({ nullable: true }),
|
||||
|
||||
body('from').isString().optional(),
|
||||
body('to').isString().optional(),
|
||||
body('body').isString().optional(),
|
||||
|
||||
body('to').isArray().exists(),
|
||||
body('to.*').isString().isEmail().optional(),
|
||||
|
||||
body('cc').isArray().optional({ nullable: true }),
|
||||
body('cc.*').isString().isEmail().optional(),
|
||||
|
||||
body('bcc').isArray().optional({ nullable: true }),
|
||||
body('bcc.*').isString().isEmail().optional(),
|
||||
|
||||
body('attach_invoice').optional().isBoolean().toBoolean(),
|
||||
],
|
||||
this.validationResult,
|
||||
@@ -183,7 +201,7 @@ export default class SaleInvoicesController extends BaseController {
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/:id/mail',
|
||||
'/:id/mail/state',
|
||||
[...this.specificSaleInvoiceValidation],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getSaleInvoiceMail.bind(this)),
|
||||
@@ -258,6 +276,11 @@ export default class SaleInvoicesController extends BaseController {
|
||||
|
||||
// Pdf template id.
|
||||
check('pdf_template_id').optional({ nullable: true }).isNumeric().toInt(),
|
||||
|
||||
// Payment methods.
|
||||
check('payment_methods').optional({ nullable: true }).isArray(),
|
||||
check('payment_methods.*.payment_integration_id').exists().toInt(),
|
||||
check('payment_methods.*.enable').exists().isBoolean(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -426,19 +449,28 @@ export default class SaleInvoicesController extends BaseController {
|
||||
const acceptType = accept.types([
|
||||
ACCEPT_TYPE.APPLICATION_JSON,
|
||||
ACCEPT_TYPE.APPLICATION_PDF,
|
||||
ACCEPT_TYPE.APPLICATION_TEXT_HTML,
|
||||
]);
|
||||
// Retrieves invoice in pdf format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF == acceptType) {
|
||||
const pdfContent = await this.saleInvoiceApplication.saleInvoicePdf(
|
||||
tenantId,
|
||||
saleInvoiceId
|
||||
);
|
||||
// Retrieves invoice in PDF format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF === acceptType) {
|
||||
const [pdfContent, filename] =
|
||||
await this.saleInvoiceApplication.saleInvoicePdf(
|
||||
tenantId,
|
||||
saleInvoiceId
|
||||
);
|
||||
res.set({
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Length': pdfContent.length,
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
// Retrieves invoice in json format.
|
||||
// Retrieves invoice in html json format.
|
||||
} else if (ACCEPT_TYPE.APPLICATION_TEXT_HTML === acceptType) {
|
||||
const htmlContent = await this.saleInvoiceApplication.saleInvoiceHtml(
|
||||
tenantId,
|
||||
saleInvoiceId
|
||||
);
|
||||
return res.status(200).send({ htmlContent });
|
||||
} else {
|
||||
const saleInvoice = await this.saleInvoiceApplication.getSaleInvoice(
|
||||
tenantId,
|
||||
@@ -448,6 +480,24 @@ export default class SaleInvoicesController extends BaseController {
|
||||
return res.status(200).send({ saleInvoice });
|
||||
}
|
||||
}
|
||||
|
||||
private async getSaleInvoiceState(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const data = await this.saleInvoiceApplication.getSaleInvoiceState(
|
||||
tenantId
|
||||
);
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve paginated sales invoices with custom view metadata.
|
||||
* @param {Request} req
|
||||
@@ -746,7 +796,7 @@ export default class SaleInvoicesController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default mail options of the given sale invoice.
|
||||
* Retrieves the mail state of the given sale invoice.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
@@ -760,7 +810,7 @@ export default class SaleInvoicesController extends BaseController {
|
||||
const { id: invoiceId } = req.params;
|
||||
|
||||
try {
|
||||
const data = await this.saleInvoiceApplication.getSaleInvoiceMail(
|
||||
const data = await this.saleInvoiceApplication.getSaleInvoiceMailState(
|
||||
tenantId,
|
||||
invoiceId
|
||||
);
|
||||
|
||||
@@ -108,6 +108,12 @@ export default class SalesReceiptsController extends BaseController {
|
||||
this.handleServiceErrors,
|
||||
this.dynamicListService.handlerErrorsToResponse
|
||||
);
|
||||
router.get(
|
||||
'/state',
|
||||
CheckPolicies(SaleReceiptAction.View, AbilitySubject.SaleReceipt),
|
||||
asyncMiddleware(this.getSaleReceiptState.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/:id',
|
||||
CheckPolicies(SaleReceiptAction.View, AbilitySubject.SaleReceipt),
|
||||
@@ -350,13 +356,15 @@ export default class SalesReceiptsController extends BaseController {
|
||||
]);
|
||||
// Retrieves receipt in pdf format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF == acceptType) {
|
||||
const pdfContent = await this.saleReceiptsApplication.getSaleReceiptPdf(
|
||||
tenantId,
|
||||
saleReceiptId
|
||||
);
|
||||
const [pdfContent, filename] =
|
||||
await this.saleReceiptsApplication.getSaleReceiptPdf(
|
||||
tenantId,
|
||||
saleReceiptId
|
||||
);
|
||||
res.set({
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Length': pdfContent.length,
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
// Retrieves receipt in json format.
|
||||
@@ -369,6 +377,30 @@ export default class SalesReceiptsController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
public async getSaleReceiptState(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
|
||||
// Retrieves receipt in pdf format.
|
||||
try {
|
||||
const data = await this.saleReceiptsApplication.getSaleReceiptState(
|
||||
tenantId
|
||||
);
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sale receipt notification via SMS.
|
||||
* @param {Request} req
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Router, Request, Response, NextFunction } from 'express';
|
||||
import { param } from 'express-validator';
|
||||
import BaseController from '@/api/controllers/BaseController';
|
||||
import { PaymentLinksApplication } from '@/services/PaymentLinks/PaymentLinksApplication';
|
||||
|
||||
@Service()
|
||||
export class PublicSharableLinkController extends BaseController {
|
||||
@Inject()
|
||||
private paymentLinkApp: PaymentLinksApplication;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
*/
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
'/:paymentLinkId/invoice',
|
||||
[param('paymentLinkId').exists()],
|
||||
this.validationResult,
|
||||
this.getPaymentLinkPublicMeta.bind(this),
|
||||
this.validationResult
|
||||
);
|
||||
router.get(
|
||||
'/:paymentLinkId/invoice/pdf',
|
||||
[param('paymentLinkId').exists()],
|
||||
this.validationResult,
|
||||
this.getPaymentLinkInvoicePdf.bind(this),
|
||||
this.validationResult
|
||||
);
|
||||
router.post(
|
||||
'/:paymentLinkId/stripe_checkout_session',
|
||||
[param('paymentLinkId').exists()],
|
||||
this.validationResult,
|
||||
this.createInvoicePaymentLinkCheckoutSession.bind(this)
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the payment link public meta.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
* @returns
|
||||
*/
|
||||
public async getPaymentLinkPublicMeta(
|
||||
req: Request<{ paymentLinkId: string }>,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { paymentLinkId } = req.params;
|
||||
|
||||
try {
|
||||
const data = await this.paymentLinkApp.getInvoicePaymentLink(
|
||||
paymentLinkId
|
||||
);
|
||||
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Stripe checkout session for the given payment link id.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
* @returns {Promise<Response|void>}
|
||||
*/
|
||||
public async createInvoicePaymentLinkCheckoutSession(
|
||||
req: Request<{ paymentLinkId: string }>,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { paymentLinkId } = req.params;
|
||||
|
||||
try {
|
||||
const session =
|
||||
await this.paymentLinkApp.createInvoicePaymentCheckoutSession(
|
||||
paymentLinkId
|
||||
);
|
||||
return res.status(200).send(session);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the sale invoice pdf of the given payment link.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
public async getPaymentLinkInvoicePdf(
|
||||
req: Request<{ paymentLinkId: string }>,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { paymentLinkId } = req.params;
|
||||
|
||||
try {
|
||||
const pdfContent = await this.paymentLinkApp.getPaymentLinkInvoicePdf(
|
||||
paymentLinkId
|
||||
);
|
||||
res.set({
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Length': pdfContent.length,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Router, Request, Response, NextFunction } from 'express';
|
||||
import { body } from 'express-validator';
|
||||
import { AbilitySubject, PaymentReceiveAction } from '@/interfaces';
|
||||
import BaseController from '@/api/controllers/BaseController';
|
||||
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
|
||||
import CheckPolicies from '@/api/middleware/CheckPolicies';
|
||||
import { GenerateShareLink } from '@/services/Sales/Invoices/GenerateeInvoicePaymentLink';
|
||||
|
||||
@Service()
|
||||
export class ShareLinkController extends BaseController {
|
||||
@Inject()
|
||||
private generateShareLinkService: GenerateShareLink;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
*/
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.post(
|
||||
'/payment-links/generate',
|
||||
CheckPolicies(PaymentReceiveAction.Edit, AbilitySubject.PaymentReceive),
|
||||
[
|
||||
body('transaction_type').exists(),
|
||||
body('transaction_id').exists().isNumeric().toInt(),
|
||||
body('publicity').optional(),
|
||||
body('expiry_date').optional({ nullable: true }),
|
||||
],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.generateShareLink.bind(this))
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates sharable link for the given transaction.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
public async generateShareLink(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { transactionType, transactionId, publicity, expiryDate } =
|
||||
this.matchedBodyData(req);
|
||||
|
||||
try {
|
||||
const link = await this.generateShareLinkService.generatePaymentLink(
|
||||
tenantId,
|
||||
transactionId,
|
||||
publicity,
|
||||
expiryDate
|
||||
);
|
||||
res.status(200).json({ link });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import { NextFunction, Request, Response, Router } from 'express';
|
||||
import { body } from 'express-validator';
|
||||
import { Service, Inject } from 'typedi';
|
||||
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
|
||||
import { StripePaymentApplication } from '@/services/StripePayment/StripePaymentApplication';
|
||||
import BaseController from '../BaseController';
|
||||
|
||||
@Service()
|
||||
export class StripeIntegrationController extends BaseController {
|
||||
@Inject()
|
||||
private stripePaymentApp: StripePaymentApplication;
|
||||
|
||||
public router() {
|
||||
const router = Router();
|
||||
|
||||
router.get('/link', this.getStripeConnectLink.bind(this));
|
||||
router.post(
|
||||
'/callback',
|
||||
[body('code').exists()],
|
||||
this.validationResult,
|
||||
this.exchangeOAuth.bind(this)
|
||||
);
|
||||
router.post('/account', asyncMiddleware(this.createAccount.bind(this)));
|
||||
router.post(
|
||||
'/account_link',
|
||||
[body('stripe_account_id').exists()],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.createAccountLink.bind(this))
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Stripe OAuth2 connect link.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
* @returns {Promise<Response|void>}
|
||||
*/
|
||||
public async getStripeConnectLink(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
try {
|
||||
const authorizationUri = this.stripePaymentApp.getStripeConnectLink();
|
||||
|
||||
return res.status(200).send({ url: authorizationUri });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchanges the given Stripe authorization code to Stripe user id and access token.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async exchangeOAuth(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId } = req;
|
||||
const { code } = this.matchedBodyData(req);
|
||||
|
||||
try {
|
||||
await this.stripePaymentApp.exchangeStripeOAuthToken(tenantId, code);
|
||||
|
||||
return res.status(200).send({});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Stripe account.
|
||||
* @param {Request} req - The Express request object.
|
||||
* @param {Response} res - The Express response object.
|
||||
* @param {NextFunction} next - The Express next middleware function.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async createAccount(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const accountId = await this.stripePaymentApp.createStripeAccount(
|
||||
tenantId
|
||||
);
|
||||
return res.status(201).json({
|
||||
accountId,
|
||||
message: 'The Stripe account has been created successfully.',
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Stripe account session.
|
||||
* @param {Request} req - The Express request object.
|
||||
* @param {Response} res - The Express response object.
|
||||
* @param {NextFunction} next - The Express next middleware function.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public async createAccountLink(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { stripeAccountId } = this.matchedBodyData(req);
|
||||
|
||||
try {
|
||||
const clientSecret = await this.stripePaymentApp.createAccountLink(
|
||||
tenantId,
|
||||
stripeAccountId
|
||||
);
|
||||
return res.status(200).json({ clientSecret });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { NextFunction, Request, Response, Router } from 'express';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import bodyParser from 'body-parser';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import { StripeWebhookEventPayload } from '@/interfaces/StripePayment';
|
||||
import { StripePaymentService } from '@/services/StripePayment/StripePaymentService';
|
||||
import events from '@/subscribers/events';
|
||||
import config from '@/config';
|
||||
|
||||
@Service()
|
||||
export class StripeWebhooksController {
|
||||
@Inject()
|
||||
private stripePaymentService: StripePaymentService;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
public router() {
|
||||
const router = Router();
|
||||
|
||||
router.post(
|
||||
'/stripe',
|
||||
bodyParser.raw({ type: 'application/json' }),
|
||||
this.handleWebhook.bind(this)
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles incoming Stripe webhook events.
|
||||
* Verifies the webhook signature, processes the event based on its type,
|
||||
* and triggers appropriate actions or events in the system.
|
||||
*
|
||||
* @param {Request} req - The Express request object containing the webhook payload.
|
||||
* @param {Response} res - The Express response object.
|
||||
* @param {NextFunction} next - The Express next middleware function.
|
||||
*/
|
||||
private async handleWebhook(req: Request, res: Response, next: NextFunction) {
|
||||
try {
|
||||
let event = req.body;
|
||||
const sig = req.headers['stripe-signature'];
|
||||
|
||||
// Verify webhook signature and extract the event.
|
||||
// See https://stripe.com/docs/webhooks#verify-events for more information.
|
||||
try {
|
||||
event = this.stripePaymentService.stripe.webhooks.constructEvent(
|
||||
req.rawBody,
|
||||
sig,
|
||||
config.stripePayment.webhooksSecret
|
||||
);
|
||||
} catch (err) {
|
||||
return res.status(400).send(`Webhook Error: ${err.message}`);
|
||||
}
|
||||
// Handle the event based on its type
|
||||
switch (event.type) {
|
||||
case 'checkout.session.completed':
|
||||
// Triggers `onStripeCheckoutSessionCompleted` event.
|
||||
this.eventPublisher.emitAsync(
|
||||
events.stripeWebhooks.onCheckoutSessionCompleted,
|
||||
{
|
||||
event,
|
||||
} as StripeWebhookEventPayload
|
||||
);
|
||||
break;
|
||||
case 'account.updated':
|
||||
this.eventPublisher.emitAsync(
|
||||
events.stripeWebhooks.onAccountUpdated,
|
||||
{
|
||||
event,
|
||||
} as StripeWebhookEventPayload
|
||||
);
|
||||
break;
|
||||
// Add more cases as needed
|
||||
default:
|
||||
console.log(`Unhandled event type ${event.type}`);
|
||||
}
|
||||
|
||||
res.status(200).json({ received: true });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import { NextFunction, Router, Request, Response } from 'express';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import Container, { Inject, Service } from 'typedi';
|
||||
import { PlaidApplication } from '@/services/Banking/Plaid/PlaidApplication';
|
||||
import BaseController from '../BaseController';
|
||||
import { LemonSqueezyWebhooks } from '@/services/Subscription/LemonSqueezyWebhooks';
|
||||
import { PlaidWebhookTenantBootMiddleware } from '@/services/Banking/Plaid/PlaidWebhookTenantBootMiddleware';
|
||||
import { StripeWebhooksController } from '../StripeIntegration/StripeWebhooksController';
|
||||
|
||||
@Service()
|
||||
export class Webhooks extends BaseController {
|
||||
@@ -24,6 +25,8 @@ export class Webhooks extends BaseController {
|
||||
|
||||
router.post('/lemon', this.lemonWebhooks.bind(this));
|
||||
|
||||
router.use(Container.get(StripeWebhooksController).router());
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,11 @@ import { Webhooks } from './controllers/Webhooks/Webhooks';
|
||||
import { ExportController } from './controllers/Export/ExportController';
|
||||
import { AttachmentsController } from './controllers/Attachments/AttachmentsController';
|
||||
import { OneClickDemoController } from './controllers/OneClickDemo/OneClickDemoController';
|
||||
import { StripeIntegrationController } from './controllers/StripeIntegration/StripeIntegrationController';
|
||||
import { ShareLinkController } from './controllers/ShareLink/ShareLinkController';
|
||||
import { PublicSharableLinkController } from './controllers/ShareLink/PublicSharableLinkController';
|
||||
import { PdfTemplatesController } from './controllers/PdfTemplates/PdfTemplatesController';
|
||||
import { PaymentServicesController } from './controllers/PaymentServices/PaymentServicesController';
|
||||
|
||||
export default () => {
|
||||
const app = Router();
|
||||
@@ -83,6 +87,10 @@ export default () => {
|
||||
app.use('/account', Container.get(Account).router());
|
||||
app.use('/webhooks', Container.get(Webhooks).router());
|
||||
app.use('/demo', Container.get(OneClickDemoController).router());
|
||||
app.use(
|
||||
'/payment-links',
|
||||
Container.get(PublicSharableLinkController).router()
|
||||
);
|
||||
|
||||
// - Dashboard routes.
|
||||
// ---------------------------
|
||||
@@ -148,14 +156,22 @@ export default () => {
|
||||
dashboard.use('/import', Container.get(ImportController).router());
|
||||
dashboard.use('/export', Container.get(ExportController).router());
|
||||
dashboard.use('/attachments', Container.get(AttachmentsController).router());
|
||||
dashboard.use(
|
||||
'/stripe_integration',
|
||||
Container.get(StripeIntegrationController).router()
|
||||
);
|
||||
dashboard.use(
|
||||
'/pdf-templates',
|
||||
Container.get(PdfTemplatesController).router()
|
||||
);
|
||||
|
||||
dashboard.use(
|
||||
'/payment-services',
|
||||
Container.get(PaymentServicesController).router()
|
||||
);
|
||||
dashboard.use('/', Container.get(ProjectTasksController).router());
|
||||
dashboard.use('/', Container.get(ProjectTimesController).router());
|
||||
dashboard.use('/', Container.get(WarehousesItemController).router());
|
||||
dashboard.use('/', Container.get(ShareLinkController).router());
|
||||
|
||||
dashboard.use('/dashboard', Container.get(DashboardController).router());
|
||||
dashboard.use('/', Container.get(Miscellaneous).router());
|
||||
|
||||
@@ -50,7 +50,8 @@ export const injectI18nUtils = (req) => {
|
||||
export const initalizeTenantServices = async (tenantId: number) => {
|
||||
const tenant = await Tenant.query()
|
||||
.findById(tenantId)
|
||||
.withGraphFetched('metadata');
|
||||
.withGraphFetched('metadata')
|
||||
.throwIfNotFound();
|
||||
|
||||
const tenantServices = Container.get(TenancyService);
|
||||
const tenantsManager = Container.get(TenantsManagerService);
|
||||
|
||||
@@ -259,6 +259,17 @@ module.exports = {
|
||||
*/
|
||||
posthog: {
|
||||
apiKey: process.env.POSTHOG_API_KEY,
|
||||
host: process.env.POSTHOG_HOST
|
||||
}
|
||||
host: process.env.POSTHOG_HOST,
|
||||
},
|
||||
|
||||
/**
|
||||
* Stripe Payment Integration.
|
||||
*/
|
||||
stripePayment: {
|
||||
secretKey: process.env.STRIPE_PAYMENT_SECRET_KEY || '',
|
||||
publishableKey: process.env.STRIPE_PAYMENT_PUBLISHABLE_KEY || '',
|
||||
clientId: process.env.STRIPE_PAYMENT_CLIENT_ID || '',
|
||||
redirectTo: process.env.STRIPE_PAYMENT_REDIRECT_URL || '',
|
||||
webhooksSecret: process.env.STRIPE_PAYMENT_WEBHOOKS_SECRET || '',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,14 +2,30 @@ export const SALE_INVOICE_CREATED = 'Sale invoice created';
|
||||
export const SALE_INVOICE_EDITED = 'Sale invoice edited';
|
||||
export const SALE_INVOICE_DELETED = 'Sale invoice deleted';
|
||||
export const SALE_INVOICE_MAIL_DELIVERED = 'Sale invoice mail delivered';
|
||||
export const SALE_INVOICE_VIEWED = 'Sale invoice viewed';
|
||||
export const SALE_INVOICE_PDF_VIEWED = 'Sale invoice PDF viewed';
|
||||
export const SALE_INVOICE_MAIL_SENT = 'Sale invoice mail sent';
|
||||
export const SALE_INVOICE_MAIL_REMINDER_SENT =
|
||||
'Sale invoice reminder mail sent';
|
||||
|
||||
export const SALE_ESTIMATE_CREATED = 'Sale estimate created';
|
||||
export const SALE_ESTIMATE_EDITED = 'Sale estimate edited';
|
||||
export const SALE_ESTIMATE_DELETED = 'Sale estimate deleted';
|
||||
export const SALE_ESTIMATE_PDF_VIEWED = 'Sale estimate PDF viewed';
|
||||
export const SALE_ESTIMATE_VIEWED = 'Sale estimate viewed';
|
||||
export const SALE_ESTIMATE_MAIL_SENT = 'Sale estimate mail sent';
|
||||
|
||||
export const PAYMENT_RECEIVED_CREATED = 'Payment received created';
|
||||
export const PAYMENT_RECEIVED_EDITED = 'payment received edited';
|
||||
export const PAYMENT_RECEIVED_DELETED = 'Payment received deleted';
|
||||
export const PAYMENT_RECEIVED_PDF_VIEWED = 'Payment received PDF viewed';
|
||||
export const PAYMENT_RECEIVED_MAIL_SENT = 'Payment received mail sent';
|
||||
|
||||
export const SALE_RECEIPT_PDF_VIEWED = 'Sale credit PDF viewed';
|
||||
export const SALE_RECEIPT_MAIL_SENT = 'Sale credit mail sent';
|
||||
|
||||
export const CREDIT_NOTE_PDF_VIEWED = 'Credit note PDF viewed';
|
||||
export const CREDIT_NOTE_MAIL_SENT = 'Credit note mail sent';
|
||||
|
||||
export const BILL_CREATED = 'Bill created';
|
||||
export const BILL_EDITED = 'Bill edited';
|
||||
@@ -26,10 +42,12 @@ export const EXPENSE_DELETED = 'Expense deleted';
|
||||
export const ACCOUNT_CREATED = 'Account created';
|
||||
export const ACCOUNT_EDITED = 'Account Edited';
|
||||
export const ACCOUNT_DELETED = 'Account deleted';
|
||||
export const ACCOUNT_VIEWED = 'Account viewed';
|
||||
|
||||
export const ITEM_EVENT_CREATED = 'Item created';
|
||||
export const ITEM_EVENT_EDITED = 'Item edited';
|
||||
export const ITEM_EVENT_DELETED = 'Item deleted';
|
||||
export const ITEM_EVENT_VIEWED = 'Item viewed';
|
||||
|
||||
export const AUTH_SIGNED_UP = 'Auth Signed-up';
|
||||
export const AUTH_RESET_PASSWORD = 'Auth reset password';
|
||||
@@ -37,6 +55,8 @@ export const AUTH_RESET_PASSWORD = 'Auth reset password';
|
||||
export const SUBSCRIPTION_CANCELLED = 'Subscription cancelled';
|
||||
export const SUBSCRIPTION_RESUMED = 'Subscription resumed';
|
||||
export const SUBSCRIPTION_PLAN_CHANGED = 'Subscription plan changed';
|
||||
export const SUBSCRIPTION_PAYMENT_SUCCEED = 'Subscription payment succeed';
|
||||
export const SUBSCRIPTION_PAYMENT_FAILED = 'Subscription payment failed';
|
||||
|
||||
export const CUSTOMER_CREATED = 'Customer created';
|
||||
export const CUSTOMER_EDITED = 'Customer edited';
|
||||
@@ -69,6 +89,19 @@ export const BANK_RULE_CREATED = 'Bank rule created';
|
||||
export const BANK_RULE_EDITED = 'Bank rule edited';
|
||||
export const BANK_RULE_DELETED = 'Bank rule deleted';
|
||||
|
||||
export const PDF_TEMPLATE_CREATED = 'PDF template created';
|
||||
export const PDF_TEMPLATE_EDITED = 'PDF template edited';
|
||||
export const PDF_TEMPLATE_DELETED = 'PDF template deleted';
|
||||
export const PDF_TEMPLATE_ASSIGNED_DEFAULT = 'PDF template assigned as default';
|
||||
|
||||
export const PAYMENT_METHOD_EDITED = 'Payment method edited';
|
||||
export const PAYMENT_METHOD_DELETED = 'Payment method deleted';
|
||||
|
||||
export const INVOICE_PAYMENT_LINK_GENERATED = 'Invoice payment link generated';
|
||||
|
||||
export const STRIPE_INTEGRAION_CONNECTED =
|
||||
'Stripe integration oauth2 connected';
|
||||
|
||||
// # Event Groups
|
||||
export const ACCOUNT_GROUP = 'Account';
|
||||
export const ITEM_GROUP = 'Item';
|
||||
@@ -77,3 +110,21 @@ export const SALE_GROUP = 'Sale';
|
||||
export const PAYMENT_GROUP = 'Payment';
|
||||
export const BILL_GROUP = 'Bill';
|
||||
export const EXPENSE_GROUP = 'Expense';
|
||||
|
||||
// # Reports
|
||||
export const BALANCE_SHEET_VIEWED = 'Balance sheet viewed';
|
||||
export const TRIAL_BALANCE_SHEET_VIEWED = 'Trial balance sheet viewed';
|
||||
export const PROFIT_LOSS_SHEET_VIEWED = 'Profit loss sheet viewed';
|
||||
export const CASHFLOW_STATEMENT_VIEWED = 'Cashflow statement viewed';
|
||||
export const GENERAL_LEDGER_VIEWED = 'General ledger viewed';
|
||||
export const JOURNAL_VIEWED = 'Journal viewed';
|
||||
export const RECEIVABLE_AGING_VIEWED = 'Receivable aging viewed';
|
||||
export const PAYABLE_AGING_VIEWED = 'Payable aging viewed';
|
||||
export const CUSTOMER_BALANCE_SUMMARY_VIEWED =
|
||||
'Customer balance summary viewed';
|
||||
export const VENDOR_BALANCE_SUMMARY_VIEWED = 'Vendor balance summary viewed';
|
||||
export const INVENTORY_VALUATION_VIEWED = 'Inventory valuation viewed';
|
||||
export const CUSTOMER_TRANSACTIONS_VIEWED = 'Customer transactions viewed';
|
||||
export const VENDOR_TRANSACTIONS_VIEWED = 'Vendor transactions viewed';
|
||||
export const SALES_BY_ITEM_VIEWED = 'Sales by item viewed';
|
||||
export const PURCHASES_BY_ITEM_VIEWED = 'Purchases by item viewed';
|
||||
|
||||
@@ -129,6 +129,7 @@ export const ACCOUNT_TYPES = [
|
||||
normal: ACCOUNT_NORMAL.CREDIT,
|
||||
rootType: ACCOUNT_ROOT_TYPE.LIABILITY,
|
||||
parentType: ACCOUNT_PARENT_TYPE.CURRENT_LIABILITY,
|
||||
multiCurrency: true,
|
||||
balanceSheet: true,
|
||||
incomeSheet: false,
|
||||
},
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.table('payment_receives', (table) => {
|
||||
table.string('stripe_pintent_id').nullable();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.table('payment_receives', (table) => {
|
||||
table.dropColumn('stripe_pintent_id');
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('payment_integrations', (table) => {
|
||||
table.increments('id');
|
||||
table.string('service');
|
||||
table.string('name');
|
||||
table.string('slug');
|
||||
table.boolean('payment_enabled').defaultTo(false);
|
||||
table.boolean('payout_enabled').defaultTo(false);
|
||||
table.string('account_id');
|
||||
table.json('options');
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.dropTableIfExists('payment_integrations');
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('transactions_payment_methods', (table) => {
|
||||
table.increments('id');
|
||||
table.integer('reference_id').unsigned();
|
||||
table.string('reference_type');
|
||||
table
|
||||
.integer('payment_integration_id')
|
||||
.unsigned()
|
||||
.index()
|
||||
.references('id')
|
||||
.inTable('payment_integrations');
|
||||
table.boolean('enable').defaultTo(false);
|
||||
table.json('options').nullable();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.dropTableIfExists('transactions_payment_methods');
|
||||
};
|
||||
@@ -31,6 +31,17 @@ export const PrepardExpenses = {
|
||||
predefined: true,
|
||||
};
|
||||
|
||||
export const StripeClearingAccount = {
|
||||
name: 'Stripe Clearing',
|
||||
slug: 'stripe-clearing',
|
||||
account_type: 'other-current-asset',
|
||||
parent_account_id: null,
|
||||
code: '100020',
|
||||
active: true,
|
||||
index: 1,
|
||||
predefined: true,
|
||||
}
|
||||
|
||||
export default [
|
||||
{
|
||||
name: 'Bank Account',
|
||||
|
||||
@@ -262,16 +262,24 @@ export type ICreditNoteGLCommonEntry = Pick<
|
||||
>;
|
||||
|
||||
export interface CreditNotePdfTemplateAttributes {
|
||||
// # Primary color
|
||||
primaryColor: string;
|
||||
secondaryColor: string;
|
||||
|
||||
// # Company logo
|
||||
showCompanyLogo: boolean;
|
||||
companyLogo: string;
|
||||
|
||||
// # Company name
|
||||
companyName: string;
|
||||
|
||||
billedToAddress: string[];
|
||||
billedFromAddress: string[];
|
||||
showBilledToAddress: boolean;
|
||||
showBilledFromAddress: boolean;
|
||||
// # Customer Address
|
||||
showCustomerAddress: boolean;
|
||||
customerAddress: string;
|
||||
|
||||
// # Company address
|
||||
showCompanyAddress: boolean;
|
||||
companyAddress: string;
|
||||
billedToLabel: string;
|
||||
|
||||
total: string;
|
||||
@@ -306,3 +314,7 @@ export interface CreditNotePdfTemplateAttributes {
|
||||
showCreditNoteDate: boolean;
|
||||
creditNoteDateLabel: string;
|
||||
}
|
||||
|
||||
export interface ICreditNoteState {
|
||||
defaultTemplateId: number;
|
||||
}
|
||||
@@ -4,4 +4,5 @@ export const ACCEPT_TYPE = {
|
||||
APPLICATION_JSON_TABLE: 'application/json+table',
|
||||
APPLICATION_XLSX: 'application/xlsx',
|
||||
APPLICATION_CSV: 'application/csv',
|
||||
APPLICATION_TEXT_HTML: 'application/json+html',
|
||||
};
|
||||
|
||||
@@ -30,18 +30,15 @@ export interface AddressItem {
|
||||
}
|
||||
|
||||
export interface CommonMailOptions {
|
||||
toAddresses: AddressItem[];
|
||||
fromAddresses: AddressItem[];
|
||||
from: string;
|
||||
to: string | string[];
|
||||
from: Array<string>;
|
||||
subject: string;
|
||||
body: string;
|
||||
data?: Record<string, any>;
|
||||
message: string;
|
||||
to: Array<string>;
|
||||
cc?: Array<string>;
|
||||
bcc?: Array<string>;
|
||||
formatArgs?: Record<string, any>;
|
||||
toOptions: Array<AddressItem>;
|
||||
fromOptions: Array<AddressItem>;
|
||||
}
|
||||
|
||||
export interface CommonMailOptionsDTO {
|
||||
to?: string | string[];
|
||||
from?: string;
|
||||
subject?: string;
|
||||
body?: string;
|
||||
}
|
||||
export interface CommonMailOptionsDTO extends Partial<CommonMailOptions> {}
|
||||
|
||||
@@ -207,10 +207,13 @@ export interface PaymentReceivedPdfTemplateAttributes {
|
||||
companyLogo: string;
|
||||
companyName: string;
|
||||
|
||||
billedToAddress: string[];
|
||||
billedFromAddress: string[];
|
||||
showBilledFromAddress: boolean;
|
||||
showBillingToAddress: boolean;
|
||||
// Customer Address
|
||||
showCustomerAddress: boolean;
|
||||
customerAddress: string;
|
||||
|
||||
// Company address
|
||||
showCompanyAddress: boolean;
|
||||
companyAddress: string;
|
||||
billedToLabel: string;
|
||||
|
||||
total: string;
|
||||
@@ -235,3 +238,8 @@ export interface PaymentReceivedPdfTemplateAttributes {
|
||||
showPaymentReceivedDate: boolean;
|
||||
paymentReceivedDateLabel: string;
|
||||
}
|
||||
|
||||
|
||||
export interface IPaymentReceivedState {
|
||||
defaultTemplateId: number;
|
||||
}
|
||||
@@ -144,3 +144,6 @@ export interface ISaleEstimateMailPresendEvent {
|
||||
messageOptions: SaleEstimateMailOptionsDTO;
|
||||
}
|
||||
|
||||
export interface ISaleEstimateState {
|
||||
defaultTemplateId: number;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,34 @@ import { IDynamicListFilter } from '@/interfaces/DynamicFilter';
|
||||
import { IItemEntry, IItemEntryDTO } from './ItemEntry';
|
||||
import { AttachmentLinkDTO } from './Attachments';
|
||||
|
||||
export interface PaymentIntegrationTransactionLink {
|
||||
id: number;
|
||||
enable: true;
|
||||
paymentIntegrationId: number;
|
||||
referenceType: string;
|
||||
referenceId: number;
|
||||
}
|
||||
|
||||
export interface PaymentIntegrationTransactionLinkEventPayload {
|
||||
tenantId: number;
|
||||
enable: true;
|
||||
paymentIntegrationId: number;
|
||||
referenceType: string;
|
||||
referenceId: number;
|
||||
saleInvoiceId: number;
|
||||
trx?: Knex.Transaction;
|
||||
}
|
||||
|
||||
export interface PaymentIntegrationTransactionLinkDeleteEventPayload {
|
||||
tenantId: number;
|
||||
enable: true;
|
||||
paymentIntegrationId: number;
|
||||
referenceType: string;
|
||||
referenceId: number;
|
||||
oldSaleInvoiceId: number;
|
||||
trx?: Knex.Transaction;
|
||||
}
|
||||
|
||||
export interface ISaleInvoice {
|
||||
id: number;
|
||||
amount: number;
|
||||
@@ -50,6 +78,8 @@ export interface ISaleInvoice {
|
||||
invoiceMessage: string;
|
||||
|
||||
pdfTemplateId?: number;
|
||||
|
||||
paymentMethods?: Array<PaymentIntegrationTransactionLink>;
|
||||
}
|
||||
|
||||
export interface ISaleInvoiceDTO {
|
||||
@@ -136,7 +166,13 @@ export interface ISaleInvoiceEditingPayload {
|
||||
|
||||
export interface ISaleInvoiceDeletePayload {
|
||||
tenantId: number;
|
||||
saleInvoice: ISaleInvoice;
|
||||
oldSaleInvoice: ISaleInvoice;
|
||||
saleInvoiceId: number;
|
||||
}
|
||||
|
||||
export interface ISaleInvoiceDeletingPayload {
|
||||
tenantId: number;
|
||||
oldSaleInvoice: ISaleInvoice;
|
||||
saleInvoiceId: number;
|
||||
trx: Knex.Transaction;
|
||||
}
|
||||
@@ -198,7 +234,32 @@ export enum SaleInvoiceAction {
|
||||
}
|
||||
|
||||
export interface SaleInvoiceMailOptions extends CommonMailOptions {
|
||||
attachInvoice: boolean;
|
||||
attachInvoice?: boolean;
|
||||
formatArgs?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface SaleInvoiceMailState extends SaleInvoiceMailOptions {
|
||||
invoiceNo: string;
|
||||
|
||||
invoiceDate: string;
|
||||
invoiceDateFormatted: string;
|
||||
|
||||
dueDate: string;
|
||||
dueDateFormatted: string;
|
||||
|
||||
total: number;
|
||||
totalFormatted: string;
|
||||
|
||||
subtotal: number;
|
||||
subtotalFormatted: number;
|
||||
|
||||
companyName: string;
|
||||
companyLogoUri: string;
|
||||
|
||||
customerName: string;
|
||||
|
||||
// # Invoice entries
|
||||
entries?: Array<{ label: string; total: string; quantity: string | number }>;
|
||||
}
|
||||
|
||||
export interface SendInvoiceMailDTO extends CommonMailOptionsDTO {
|
||||
@@ -215,6 +276,7 @@ export interface ISaleInvoiceMailSend {
|
||||
tenantId: number;
|
||||
saleInvoiceId: number;
|
||||
messageOptions: SendInvoiceMailDTO;
|
||||
formattedMessageOptions: SaleInvoiceMailOptions;
|
||||
}
|
||||
|
||||
export interface ISaleInvoiceMailSent {
|
||||
@@ -223,7 +285,6 @@ export interface ISaleInvoiceMailSent {
|
||||
messageOptions: SendInvoiceMailDTO;
|
||||
}
|
||||
|
||||
|
||||
// Invoice Pdf Document
|
||||
export interface InvoicePdfLine {
|
||||
item: string;
|
||||
@@ -241,9 +302,9 @@ export interface InvoicePdfTax {
|
||||
export interface InvoicePdfTemplateAttributes {
|
||||
primaryColor: string;
|
||||
secondaryColor: string;
|
||||
|
||||
|
||||
companyName: string;
|
||||
|
||||
|
||||
showCompanyLogo: boolean;
|
||||
companyLogo: string;
|
||||
|
||||
@@ -259,8 +320,13 @@ export interface InvoicePdfTemplateAttributes {
|
||||
invoiceNumber: string;
|
||||
showInvoiceNumber: boolean;
|
||||
|
||||
showBillingToAddress: boolean;
|
||||
showBilledFromAddress: boolean;
|
||||
// Customer Address
|
||||
showCustomerAddress: boolean;
|
||||
customerAddress: string;
|
||||
|
||||
// Company address
|
||||
showCompanyAddress: boolean;
|
||||
companyAddress: string;
|
||||
billedToLabel: string;
|
||||
|
||||
lineItemLabel: string;
|
||||
@@ -272,21 +338,22 @@ export interface InvoicePdfTemplateAttributes {
|
||||
subtotalLabel: string;
|
||||
discountLabel: string;
|
||||
paymentMadeLabel: string;
|
||||
balanceDueLabel: string;
|
||||
|
||||
showTotal: boolean;
|
||||
showSubtotal: boolean;
|
||||
showDiscount: boolean;
|
||||
showTaxes: boolean;
|
||||
showPaymentMade: boolean;
|
||||
showDueAmount: boolean;
|
||||
showBalanceDue: boolean;
|
||||
|
||||
total: string;
|
||||
subtotal: string;
|
||||
discount: string;
|
||||
paymentMade: string;
|
||||
balanceDue: string;
|
||||
|
||||
// Due Amount
|
||||
dueAmount: string;
|
||||
showDueAmount: boolean;
|
||||
dueAmountLabel: string;
|
||||
|
||||
termsConditionsLabel: string;
|
||||
showTermsConditions: boolean;
|
||||
@@ -298,7 +365,8 @@ export interface InvoicePdfTemplateAttributes {
|
||||
statementLabel: string;
|
||||
showStatement: boolean;
|
||||
statement: string;
|
||||
}
|
||||
|
||||
billedToAddress: string[];
|
||||
billedFromAddres: string[];
|
||||
}
|
||||
export interface ISaleInvocieState {
|
||||
defaultTemplateId: number;
|
||||
}
|
||||
|
||||
@@ -163,11 +163,13 @@ export interface ISaleReceiptBrandingTemplateAttributes {
|
||||
companyLogo: string;
|
||||
companyName: string;
|
||||
|
||||
// Address
|
||||
billedToAddress: string[];
|
||||
billedFromAddress: string[];
|
||||
showBilledFromAddress: boolean;
|
||||
showBilledToAddress: boolean;
|
||||
// Customer Address
|
||||
showCustomerAddress: boolean;
|
||||
customerAddress: string;
|
||||
|
||||
// Company address
|
||||
showCompanyAddress: boolean;
|
||||
companyAddress: string;
|
||||
billedToLabel: string;
|
||||
|
||||
// Total
|
||||
@@ -209,3 +211,8 @@ export interface ISaleReceiptBrandingTemplateAttributes {
|
||||
showReceiptDate: boolean;
|
||||
receiptDateLabel: string;
|
||||
}
|
||||
|
||||
|
||||
export interface ISaleReceiptState {
|
||||
defaultTemplateId: number;
|
||||
}
|
||||
@@ -18,14 +18,26 @@ export interface IOrganizationBuildDTO {
|
||||
dateFormat?: string;
|
||||
}
|
||||
|
||||
interface OrganizationAddressDTO {
|
||||
address1: string;
|
||||
address2: string;
|
||||
postalCode: string;
|
||||
city: string;
|
||||
stateProvince: string;
|
||||
phone: string;
|
||||
}
|
||||
|
||||
export interface IOrganizationUpdateDTO {
|
||||
name: string;
|
||||
location: string;
|
||||
baseCurrency: string;
|
||||
timezone: string;
|
||||
fiscalYear: string;
|
||||
industry: string;
|
||||
taxNumber: string;
|
||||
location?: string;
|
||||
baseCurrency?: string;
|
||||
timezone?: string;
|
||||
fiscalYear?: string;
|
||||
industry?: string;
|
||||
taxNumber?: string;
|
||||
primaryColor?: string;
|
||||
logoKey?: string;
|
||||
address?: OrganizationAddressDTO;
|
||||
}
|
||||
|
||||
export interface IOrganizationBuildEventPayload {
|
||||
@@ -36,4 +48,4 @@ export interface IOrganizationBuildEventPayload {
|
||||
|
||||
export interface IOrganizationBuiltEventPayload {
|
||||
tenantId: number;
|
||||
}
|
||||
}
|
||||
|
||||
20
packages/server/src/interfaces/StripePayment.ts
Normal file
20
packages/server/src/interfaces/StripePayment.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export interface StripePaymentLinkCreatedEventPayload {
|
||||
tenantId: number;
|
||||
paymentLinkId: string;
|
||||
saleInvoiceId: number;
|
||||
stripeIntegrationId: number;
|
||||
}
|
||||
|
||||
export interface StripeCheckoutSessionCompletedEventPayload {
|
||||
event: any;
|
||||
}
|
||||
|
||||
export interface StripeInvoiceCheckoutSessionPOJO {
|
||||
sessionId: string;
|
||||
publishableKey: string;
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
export interface StripeWebhookEventPayload {
|
||||
event: any;
|
||||
}
|
||||
@@ -9,6 +9,9 @@ export default class Mail {
|
||||
subject: string = '';
|
||||
content: string = '';
|
||||
to: string | string[];
|
||||
cc: string | string[];
|
||||
bcc: string | string[];
|
||||
replyTo: string | string[];
|
||||
from: string = `${process.env.MAIL_FROM_NAME} ${process.env.MAIL_FROM_ADDRESS}`;
|
||||
data: { [key: string]: string | number };
|
||||
attachments: IMailAttachment[];
|
||||
@@ -20,9 +23,12 @@ export default class Mail {
|
||||
return {
|
||||
to: this.to,
|
||||
from: this.from,
|
||||
cc: this.cc,
|
||||
bcc: this.bcc,
|
||||
subject: this.subject,
|
||||
html: this.html,
|
||||
attachments: this.attachments,
|
||||
replyTo: this.replyTo,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,6 +66,21 @@ export default class Mail {
|
||||
return this;
|
||||
}
|
||||
|
||||
setCC(cc: string | string[]) {
|
||||
this.cc = cc;
|
||||
return this;
|
||||
}
|
||||
|
||||
setBCC(bcc: string | string[]) {
|
||||
this.bcc = bcc;
|
||||
return this;
|
||||
}
|
||||
|
||||
setReplyTo(replyTo: string | string[]) {
|
||||
this.replyTo = replyTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets from address to the mail.
|
||||
* @param {string} from
|
||||
@@ -72,7 +93,7 @@ export default class Mail {
|
||||
|
||||
/**
|
||||
* Set attachments to the mail.
|
||||
* @param {IMailAttachment[]} attachments
|
||||
* @param {IMailAttachment[]} attachments
|
||||
* @returns {Mail}
|
||||
*/
|
||||
setAttachments(attachments: IMailAttachment[]) {
|
||||
|
||||
@@ -117,8 +117,10 @@ import { DisconnectPlaidItemOnAccountDeleted } from '@/services/Banking/BankAcco
|
||||
import { LoopsEventsSubscriber } from '@/services/Loops/LoopsEventsSubscriber';
|
||||
import { DeleteUncategorizedTransactionsOnAccountDeleting } from '@/services/Banking/BankAccounts/events/DeleteUncategorizedTransactionsOnAccountDeleting';
|
||||
import { SeedInitialDemoAccountDataOnOrgBuild } from '@/services/OneClickDemo/events/SeedInitialDemoAccountData';
|
||||
import { TriggerInvalidateCacheOnSubscriptionChange } from '@/services/Subscription/events/TriggerInvalidateCacheOnSubscriptionChange';
|
||||
import { EventsTrackerListeners } from '@/services/EventsTracker/events/events';
|
||||
import { InvoicePaymentIntegrationSubscriber } from '@/services/Sales/Invoices/subscribers/InvoicePaymentIntegrationSubscriber';
|
||||
import { StripeWebhooksSubscriber } from '@/services/StripePayment/events/StripeWebhooksSubscriber';
|
||||
import { SeedStripeAccountsOnOAuthGrantedSubscriber } from '@/services/StripePayment/events/SeedStripeAccounts';
|
||||
|
||||
export default () => {
|
||||
return new EventPublisher();
|
||||
@@ -252,7 +254,6 @@ export const susbcribers = () => {
|
||||
// Subscription
|
||||
SubscribeFreeOnSignupCommunity,
|
||||
SendVerfiyMailOnSignUp,
|
||||
TriggerInvalidateCacheOnSubscriptionChange,
|
||||
|
||||
// Attachments
|
||||
AttachmentsOnSaleInvoiceCreated,
|
||||
@@ -291,6 +292,11 @@ export const susbcribers = () => {
|
||||
// Demo Account
|
||||
SeedInitialDemoAccountDataOnOrgBuild,
|
||||
|
||||
// Stripe Payment
|
||||
InvoicePaymentIntegrationSubscriber,
|
||||
StripeWebhooksSubscriber,
|
||||
SeedStripeAccountsOnOAuthGrantedSubscriber,
|
||||
|
||||
...EventsTrackerListeners
|
||||
];
|
||||
};
|
||||
|
||||
@@ -69,6 +69,8 @@ import { BankRuleCondition } from '@/models/BankRuleCondition';
|
||||
import { RecognizedBankTransaction } from '@/models/RecognizedBankTransaction';
|
||||
import { MatchedBankTransaction } from '@/models/MatchedBankTransaction';
|
||||
import { PdfTemplate } from '@/models/PdfTemplate';
|
||||
import { PaymentIntegration } from '@/models/PaymentIntegration';
|
||||
import { TransactionPaymentServiceEntry } from '@/models/TransactionPaymentServiceEntry';
|
||||
|
||||
export default (knex) => {
|
||||
const models = {
|
||||
@@ -140,7 +142,9 @@ export default (knex) => {
|
||||
BankRuleCondition,
|
||||
RecognizedBankTransaction,
|
||||
MatchedBankTransaction,
|
||||
PdfTemplate
|
||||
PdfTemplate,
|
||||
PaymentIntegration,
|
||||
TransactionPaymentServiceEntry,
|
||||
};
|
||||
return mapValues(models, (model) => model.bindKnex(knex));
|
||||
};
|
||||
|
||||
@@ -294,7 +294,7 @@ export default {
|
||||
name: 'item.field.note',
|
||||
fieldType: 'text',
|
||||
},
|
||||
category: {
|
||||
categoryId: {
|
||||
name: 'item.field.category',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'ItemCategory',
|
||||
|
||||
61
packages/server/src/models/PaymentIntegration.ts
Normal file
61
packages/server/src/models/PaymentIntegration.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { Model } from 'objection';
|
||||
import TenantModel from 'models/TenantModel';
|
||||
|
||||
export class PaymentIntegration extends Model {
|
||||
paymentEnabled!: boolean;
|
||||
payoutEnabled!: boolean;
|
||||
|
||||
static get tableName() {
|
||||
return 'payment_integrations';
|
||||
}
|
||||
|
||||
static get idColumn() {
|
||||
return 'id';
|
||||
}
|
||||
|
||||
static get virtualAttributes() {
|
||||
return ['fullEnabled'];
|
||||
}
|
||||
|
||||
static get jsonAttributes() {
|
||||
return ['options'];
|
||||
}
|
||||
|
||||
get fullEnabled() {
|
||||
return this.paymentEnabled && this.payoutEnabled;
|
||||
}
|
||||
|
||||
static get modifiers() {
|
||||
return {
|
||||
/**
|
||||
* Query to filter enabled payment and payout.
|
||||
*/
|
||||
fullEnabled(query) {
|
||||
query.where('paymentEnabled', true).andWhere('payoutEnabled', true);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['name', 'service'],
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
service: { type: 'string' },
|
||||
paymentEnabled: { type: 'boolean' },
|
||||
payoutEnabled: { type: 'boolean' },
|
||||
accountId: { type: 'string' },
|
||||
options: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
bankAccountId: { type: 'number' },
|
||||
clearingAccountId: { type: 'number' },
|
||||
},
|
||||
},
|
||||
createdAt: { type: 'string', format: 'date-time' },
|
||||
updatedAt: { type: 'string', format: 'date-time' },
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import { getUploadedObjectUri } from '@/services/Attachments/utils';
|
||||
import TenantModel from 'models/TenantModel';
|
||||
|
||||
export class PdfTemplate extends TenantModel {
|
||||
public readonly attributes: Record<string, any>;
|
||||
|
||||
/**
|
||||
* Table name.
|
||||
*/
|
||||
@@ -29,11 +32,35 @@ export class PdfTemplate extends TenantModel {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Model modifiers.
|
||||
*/
|
||||
static get modifiers() {
|
||||
return {
|
||||
/**
|
||||
* Filters the due invoices.
|
||||
*/
|
||||
default(query) {
|
||||
query.where('default', true);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual attributes.
|
||||
*/
|
||||
static get virtualAttributes() {
|
||||
return [];
|
||||
return ['companyLogoUri'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the company logo uri.
|
||||
* @returns {string}
|
||||
*/
|
||||
get companyLogoUri() {
|
||||
return this.attributes?.companyLogoKey
|
||||
? getUploadedObjectUri(this.attributes.companyLogoKey)
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -413,6 +413,10 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
const TaxRateTransaction = require('models/TaxRateTransaction');
|
||||
const Document = require('models/Document');
|
||||
const { MatchedBankTransaction } = require('models/MatchedBankTransaction');
|
||||
const {
|
||||
TransactionPaymentServiceEntry,
|
||||
} = require('models/TransactionPaymentServiceEntry');
|
||||
const { PdfTemplate } = require('models/PdfTemplate');
|
||||
|
||||
return {
|
||||
/**
|
||||
@@ -509,7 +513,7 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
join: {
|
||||
from: 'sales_invoices.warehouseId',
|
||||
to: 'warehouses.id',
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -566,12 +570,42 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
modelClass: MatchedBankTransaction,
|
||||
join: {
|
||||
from: 'sales_invoices.id',
|
||||
to: "matched_bank_transactions.referenceId",
|
||||
to: 'matched_bank_transactions.referenceId',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('reference_type', 'SaleInvoice');
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Sale invoice may belongs to payment methods entries.
|
||||
*/
|
||||
paymentMethods: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: TransactionPaymentServiceEntry,
|
||||
join: {
|
||||
from: 'sales_invoices.id',
|
||||
to: 'transactions_payment_methods.referenceId',
|
||||
},
|
||||
beforeInsert: (model) => {
|
||||
model.referenceType = 'SaleInvoice';
|
||||
},
|
||||
filter: (query) => {
|
||||
query.where('reference_type', 'SaleInvoice');
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Sale invoice may belongs to pdf branding template.
|
||||
*/
|
||||
pdfTemplate: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: PdfTemplate,
|
||||
join: {
|
||||
from: 'sales_invoices.pdfTemplateId',
|
||||
to: 'pdf_templates.id',
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
46
packages/server/src/models/TransactionPaymentServiceEntry.ts
Normal file
46
packages/server/src/models/TransactionPaymentServiceEntry.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import TenantModel from 'models/TenantModel';
|
||||
|
||||
export class TransactionPaymentServiceEntry extends TenantModel {
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'transactions_payment_methods';
|
||||
}
|
||||
|
||||
/**
|
||||
* Json schema of the model.
|
||||
*/
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['paymentIntegrationId'],
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
referenceId: { type: 'integer' },
|
||||
referenceType: { type: 'string' },
|
||||
paymentIntegrationId: { type: 'integer' },
|
||||
enable: { type: 'boolean' },
|
||||
options: { type: 'object' },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const { PaymentIntegration } = require('./PaymentIntegration');
|
||||
|
||||
return {
|
||||
paymentIntegration: {
|
||||
relation: TenantModel.BelongsToOneRelation,
|
||||
modelClass: PaymentIntegration,
|
||||
join: {
|
||||
from: 'transactions_payment_methods.paymentIntegrationId',
|
||||
to: 'payment_integrations.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,12 @@ export default class UncategorizedCashflowTransaction extends mixin(
|
||||
) {
|
||||
id!: number;
|
||||
date!: Date | string;
|
||||
|
||||
/**
|
||||
* Transaction amount.
|
||||
* Negative represents to spending and positive to deposit/card charge.
|
||||
* @param {number}
|
||||
*/
|
||||
amount!: number;
|
||||
categorized!: boolean;
|
||||
accountId!: number;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { IAccount } from '@/interfaces';
|
||||
import { Knex } from 'knex';
|
||||
import {
|
||||
PrepardExpenses,
|
||||
StripeClearingAccount,
|
||||
TaxPayableAccount,
|
||||
UnearnedRevenueAccount,
|
||||
} from '@/database/seeds/data/accounts';
|
||||
@@ -247,4 +248,37 @@ export default class AccountRepository extends TenantRepository {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds or creates the stripe clearing account.
|
||||
* @param {Record<string, string>} extraAttrs
|
||||
* @param {Knex.Transaction} trx
|
||||
* @returns
|
||||
*/
|
||||
public async findOrCreateStripeClearing(
|
||||
extraAttrs: Record<string, string> = {},
|
||||
trx?: Knex.Transaction
|
||||
) {
|
||||
// Retrieves the given tenant metadata.
|
||||
const tenantMeta = await TenantMetadata.query().findOne({
|
||||
tenantId: this.tenantId,
|
||||
});
|
||||
const _extraAttrs = {
|
||||
currencyCode: tenantMeta.baseCurrency,
|
||||
...extraAttrs,
|
||||
};
|
||||
|
||||
let result = await this.model
|
||||
.query(trx)
|
||||
.findOne({ slug: StripeClearingAccount.slug, ..._extraAttrs });
|
||||
|
||||
if (!result) {
|
||||
result = await this.model.query(trx).insertAndFetch({
|
||||
...StripeClearingAccount,
|
||||
..._extraAttrs,
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ export class AccountTransformer extends Transformer {
|
||||
*/
|
||||
public includeAttributes = (): string[] => {
|
||||
return [
|
||||
'accountTypeLabel',
|
||||
'accountNormalFormatted',
|
||||
'formattedAmount',
|
||||
'flattenName',
|
||||
'bankBalanceFormatted',
|
||||
@@ -84,6 +86,22 @@ export class AccountTransformer extends Transformer {
|
||||
return account.plaidItem?.isPaused || false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted account type label.
|
||||
* @returns {string}
|
||||
*/
|
||||
protected accountTypeLabel = (account: any): string => {
|
||||
return this.context.i18n.__(account.accountTypeLabel);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted account normal.
|
||||
* @returns {string}
|
||||
*/
|
||||
protected accountNormalFormatted = (account: any): string => {
|
||||
return this.context.i18n.__(account.accountNormalFormatted);
|
||||
};
|
||||
|
||||
/**
|
||||
* Transformes the accounts collection to flat or nested array.
|
||||
* @param {IAccount[]}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import I18nService from '@/services/I18n/I18nService';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { AccountTransformer } from './AccountTransform';
|
||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class GetAccount {
|
||||
@@ -10,10 +11,10 @@ export class GetAccount {
|
||||
private tenancy: HasTenancyService;
|
||||
|
||||
@Inject()
|
||||
private i18nService: I18nService;
|
||||
private transformer: TransformerInjectable;
|
||||
|
||||
@Inject()
|
||||
private transformer: TransformerInjectable;
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Retrieve the given account details.
|
||||
@@ -39,10 +40,11 @@ export class GetAccount {
|
||||
new AccountTransformer(),
|
||||
{ accountsGraph }
|
||||
);
|
||||
return this.i18nService.i18nApply(
|
||||
[['accountTypeLabel'], ['accountNormalFormatted']],
|
||||
transformed,
|
||||
tenantId
|
||||
);
|
||||
const eventPayload = { tenantId, accountId };
|
||||
|
||||
// Triggers `onAccountViewed` event.
|
||||
await this.eventPublisher.emitAsync(events.accounts.onViewed, eventPayload);
|
||||
|
||||
return transformed;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import multer from 'multer';
|
||||
import type { Multer } from 'multer';
|
||||
import multerS3 from 'multer-s3';
|
||||
import { s3 } from '@/lib/S3/S3';
|
||||
import { Service } from 'typedi';
|
||||
import config from '@/config';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
|
||||
@Service()
|
||||
export class AttachmentUploadPipeline {
|
||||
/**
|
||||
* Middleware to ensure that S3 configuration is properly set before proceeding.
|
||||
* This function checks if the necessary S3 configuration keys are present and throws an error if any are missing.
|
||||
*
|
||||
* @param req The HTTP request object.
|
||||
* @param res The HTTP response object.
|
||||
* @param next The callback to pass control to the next middleware function.
|
||||
@@ -49,6 +48,11 @@ export class AttachmentUploadPipeline {
|
||||
key: function (req, file, cb) {
|
||||
cb(null, Date.now().toString());
|
||||
},
|
||||
acl: function(req, file, cb) {
|
||||
// Conditionally set file to public or private based on isPublic flag
|
||||
const aclValue = true ? 'public-read' : 'private';
|
||||
cb(null, aclValue); // Set ACL based on the isPublic flag
|
||||
}
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { isEmpty } from 'lodash';
|
||||
import {
|
||||
ISaleInvoiceCreatedPayload,
|
||||
ISaleInvoiceCreatingPaylaod,
|
||||
ISaleInvoiceDeletePayload,
|
||||
ISaleInvoiceDeletingPayload,
|
||||
ISaleInvoiceEditedPayload,
|
||||
} from '@/interfaces';
|
||||
import events from '@/subscribers/events';
|
||||
@@ -146,13 +146,13 @@ export class AttachmentsOnSaleInvoiceCreated {
|
||||
*/
|
||||
private async handleUnlinkAttachmentsOnInvoiceDeleted({
|
||||
tenantId,
|
||||
saleInvoice,
|
||||
oldSaleInvoice,
|
||||
trx,
|
||||
}: ISaleInvoiceDeletePayload) {
|
||||
}: ISaleInvoiceDeletingPayload) {
|
||||
await this.unlinkAttachmentService.unlinkAllModelKeys(
|
||||
tenantId,
|
||||
'SaleInvoice',
|
||||
saleInvoice.id,
|
||||
oldSaleInvoice.id,
|
||||
trx
|
||||
);
|
||||
}
|
||||
|
||||
9
packages/server/src/services/Attachments/utils.ts
Normal file
9
packages/server/src/services/Attachments/utils.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import path from 'path';
|
||||
import config from '@/config';
|
||||
|
||||
export const getUploadedObjectUri = (objectKey: string) => {
|
||||
return new URL(
|
||||
path.join(config.s3.bucket, objectKey),
|
||||
config.s3.endpoint
|
||||
).toString();
|
||||
};
|
||||
@@ -4,11 +4,27 @@ import {
|
||||
Institution as PlaidInstitution,
|
||||
AccountBase as PlaidAccount,
|
||||
TransactionBase as PlaidTransactionBase,
|
||||
AccountType as PlaidAccountType,
|
||||
} from 'plaid';
|
||||
import {
|
||||
CreateUncategorizedTransactionDTO,
|
||||
IAccountCreateDTO,
|
||||
} from '@/interfaces';
|
||||
import { ACCOUNT_TYPE } from '@/data/AccountTypes';
|
||||
|
||||
/**
|
||||
* Retrieves the system account type from the given Plaid account type.
|
||||
* @param {PlaidAccountType} plaidAccountType
|
||||
* @returns {string}
|
||||
*/
|
||||
const getAccountTypeFromPlaidAccountType = (
|
||||
plaidAccountType: PlaidAccountType
|
||||
) => {
|
||||
if (plaidAccountType === PlaidAccountType.Credit) {
|
||||
return ACCOUNT_TYPE.CREDIT_CARD;
|
||||
}
|
||||
return ACCOUNT_TYPE.BANK;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transformes the Plaid account to create cashflow account DTO.
|
||||
@@ -28,7 +44,7 @@ export const transformPlaidAccountToCreateAccount = R.curry(
|
||||
code: '',
|
||||
description: plaidAccount.official_name,
|
||||
currencyCode: plaidAccount.balances.iso_currency_code,
|
||||
accountType: 'cash',
|
||||
accountType: getAccountTypeFromPlaidAccountType(plaidAccount.type),
|
||||
active: true,
|
||||
bankBalance: plaidAccount.balances.current,
|
||||
accountMask: plaidAccount.mask,
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Knex } from 'knex';
|
||||
import {
|
||||
ILedgerEntry,
|
||||
ICashflowTransaction,
|
||||
AccountNormal,
|
||||
} from '../../interfaces';
|
||||
import {
|
||||
transformCashflowTransactionType,
|
||||
getCashflowAccountTransactionsTypes,
|
||||
} from './utils';
|
||||
import { ILedgerEntry, ICashflowTransaction } from '../../interfaces';
|
||||
import { transformCashflowTransactionType } from './utils';
|
||||
import LedgerStorageService from '@/services/Accounting/LedgerStorageService';
|
||||
import Ledger from '@/services/Accounting/Ledger';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
@@ -70,7 +63,7 @@ export default class CashflowTransactionJournalEntries {
|
||||
debit: cashflowTransaction.isCashDebit
|
||||
? cashflowTransaction.localAmount
|
||||
: 0,
|
||||
accountNormal: AccountNormal.DEBIT,
|
||||
accountNormal: cashflowTransaction?.cashflowAccount?.accountNormal,
|
||||
index: 1,
|
||||
};
|
||||
};
|
||||
@@ -143,6 +136,7 @@ export default class CashflowTransactionJournalEntries {
|
||||
// Retrieves the cashflow transactions with associated entries.
|
||||
const transaction = await CashflowTransaction.query(trx)
|
||||
.findById(cashflowTransactionId)
|
||||
.withGraphFetched('cashflowAccount')
|
||||
.withGraphFetched('creditAccount');
|
||||
|
||||
// Retrieves the cashflow transaction ledger.
|
||||
|
||||
@@ -4,6 +4,7 @@ import { CashflowAccountTransformer } from './CashflowAccountTransformer';
|
||||
import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import DynamicListingService from '@/services/DynamicListing/DynamicListService';
|
||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||
import { ACCOUNT_TYPE } from '@/data/AccountTypes';
|
||||
|
||||
@Service()
|
||||
export default class GetCashflowAccountsService {
|
||||
@@ -41,14 +42,20 @@ export default class GetCashflowAccountsService {
|
||||
const accounts = await CashflowAccount.query().onBuild((builder) => {
|
||||
dynamicList.buildQuery()(builder);
|
||||
|
||||
builder.whereIn('account_type', ['bank', 'cash']);
|
||||
builder.whereIn('account_type', [
|
||||
ACCOUNT_TYPE.BANK,
|
||||
ACCOUNT_TYPE.CASH,
|
||||
ACCOUNT_TYPE.CREDIT_CARD,
|
||||
]);
|
||||
builder.modify('inactiveMode', filter.inactiveMode);
|
||||
});
|
||||
// Retrieves the transformed accounts.
|
||||
return this.transformer.transform(
|
||||
const transformed = await this.transformer.transform(
|
||||
tenantId,
|
||||
accounts,
|
||||
new CashflowAccountTransformer()
|
||||
);
|
||||
|
||||
return transformed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export class GetCashflowTransactionService {
|
||||
private tenancy: HasTenancyService;
|
||||
|
||||
@Inject()
|
||||
private transfromer: TransformerInjectable;
|
||||
private transformer: TransformerInjectable;
|
||||
|
||||
/**
|
||||
* Retrieve the given cashflow transaction.
|
||||
@@ -37,7 +37,7 @@ export class GetCashflowTransactionService {
|
||||
this.throwErrorCashflowTranscationNotFound(cashflowTransaction);
|
||||
|
||||
// Transformes the cashflow transaction model to POJO.
|
||||
return this.transfromer.transform(
|
||||
return this.transformer.transform(
|
||||
tenantId,
|
||||
cashflowTransaction,
|
||||
new CashflowTransactionTransformer()
|
||||
|
||||
@@ -122,6 +122,7 @@ export default class NewCashflowTransactionService {
|
||||
* @param {number} tenantId -
|
||||
* @param {ICashflowOwnerContributionDTO} ownerContributionDTO
|
||||
* @param {number} userId - User id.
|
||||
* @returns {Promise<ICashflowTransaction>}
|
||||
*/
|
||||
public newCashflowTransaction = async (
|
||||
tenantId: number,
|
||||
|
||||
@@ -1,26 +1,47 @@
|
||||
import { Inject } from "typedi";
|
||||
import { GetPdfTemplate } from "../PdfTemplate/GetPdfTemplate";
|
||||
import { defaultCreditNoteBrandingAttributes } from "./constants";
|
||||
import { mergePdfTemplateWithDefaultAttributes } from "../Sales/Invoices/utils";
|
||||
import { Inject } from 'typedi';
|
||||
import { GetPdfTemplate } from '../PdfTemplate/GetPdfTemplate';
|
||||
import { defaultCreditNoteBrandingAttributes } from './constants';
|
||||
import { mergePdfTemplateWithDefaultAttributes } from '../Sales/Invoices/utils';
|
||||
import { GetOrganizationBrandingAttributes } from '../PdfTemplate/GetOrganizationBrandingAttributes';
|
||||
|
||||
export class CreditNoteBrandingTemplate {
|
||||
@Inject()
|
||||
private getPdfTemplateService: GetPdfTemplate;
|
||||
|
||||
@Inject()
|
||||
private getOrgBrandingAttributes: GetOrganizationBrandingAttributes;
|
||||
|
||||
/**
|
||||
* Retrieves the credit note branding template.
|
||||
* @param {number} tenantId
|
||||
* @param {number} templateId
|
||||
* @param {number} tenantId
|
||||
* @param {number} templateId
|
||||
* @returns {}
|
||||
*/
|
||||
public async getCreditNoteBrandingTemplate(tenantId: number, templateId: number) {
|
||||
public async getCreditNoteBrandingTemplate(
|
||||
tenantId: number,
|
||||
templateId: number
|
||||
) {
|
||||
const template = await this.getPdfTemplateService.getPdfTemplate(
|
||||
tenantId,
|
||||
templateId
|
||||
);
|
||||
// Retrieves the organization branding attributes.
|
||||
const commonOrgBrandingAttrs =
|
||||
await this.getOrgBrandingAttributes.getOrganizationBrandingAttributes(
|
||||
tenantId
|
||||
);
|
||||
// Merges the default branding attributes with common organization branding attrs.
|
||||
const organizationBrandingAttrs = {
|
||||
...defaultCreditNoteBrandingAttributes,
|
||||
...commonOrgBrandingAttrs,
|
||||
};
|
||||
const brandingTemplateAttrs = {
|
||||
...template.attributes,
|
||||
companyLogoUri: template.companyLogoUri,
|
||||
};
|
||||
const attributes = mergePdfTemplateWithDefaultAttributes(
|
||||
template.attributes,
|
||||
defaultCreditNoteBrandingAttributes
|
||||
brandingTemplateAttrs,
|
||||
organizationBrandingAttrs
|
||||
);
|
||||
return {
|
||||
...template,
|
||||
|
||||
@@ -6,6 +6,8 @@ import { CreditNoteBrandingTemplate } from './CreditNoteBrandingTemplate';
|
||||
import { CreditNotePdfTemplateAttributes } from '@/interfaces';
|
||||
import HasTenancyService from '../Tenancy/TenancyService';
|
||||
import { transformCreditNoteToPdfTemplate } from './utils';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export default class GetCreditNotePdf {
|
||||
@@ -24,24 +26,59 @@ export default class GetCreditNotePdf {
|
||||
@Inject()
|
||||
private creditNoteBrandingTemplate: CreditNoteBrandingTemplate;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Retrieves sale invoice pdf content.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {number} creditNoteId - Credit note id.
|
||||
* @returns {Promise<[Buffer, string]>}
|
||||
*/
|
||||
public async getCreditNotePdf(tenantId: number, creditNoteId: number) {
|
||||
public async getCreditNotePdf(
|
||||
tenantId: number,
|
||||
creditNoteId: number
|
||||
): Promise<[Buffer, string]> {
|
||||
const brandingAttributes = await this.getCreditNoteBrandingAttributes(
|
||||
tenantId,
|
||||
creditNoteId
|
||||
);
|
||||
console.log(brandingAttributes, 'brandingAttributes');
|
||||
|
||||
const htmlContent = await this.templateInjectable.render(
|
||||
tenantId,
|
||||
'modules/credit-note-standard',
|
||||
brandingAttributes
|
||||
);
|
||||
return this.chromiumlyTenancy.convertHtmlContent(tenantId, htmlContent);
|
||||
const filename = await this.getCreditNoteFilename(tenantId, creditNoteId);
|
||||
|
||||
const document = await this.chromiumlyTenancy.convertHtmlContent(
|
||||
tenantId,
|
||||
htmlContent
|
||||
);
|
||||
const eventPayload = { tenantId, creditNoteId };
|
||||
|
||||
// Triggers the `onCreditNotePdfViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.creditNote.onPdfViewed,
|
||||
eventPayload
|
||||
);
|
||||
return [document, filename];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the filename pdf document of the given credit note.
|
||||
* @param {number} tenantId
|
||||
* @param {number} creditNoteId
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
public async getCreditNoteFilename(
|
||||
tenantId: number,
|
||||
creditNoteId: number
|
||||
): Promise<string> {
|
||||
const { CreditNote } = this.tenancy.models(tenantId);
|
||||
|
||||
const creditNote = await CreditNote.query().findById(creditNoteId);
|
||||
|
||||
return `Credit-${creditNote.creditNoteNumber}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { ICreditNoteState } from '@/interfaces';
|
||||
import HasTenancyService from '../Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class GetCreditNoteState {
|
||||
@Inject()
|
||||
private tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Retrieves the create/edit initial state of the payment received.
|
||||
* @param {Number} saleInvoiceId -
|
||||
* @return {Promise<ISaleInvoice>}
|
||||
*/
|
||||
public async getCreditNoteState(tenantId: number): Promise<ICreditNoteState> {
|
||||
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||
|
||||
const defaultPdfTemplate = await PdfTemplate.query()
|
||||
.findOne({ resource: 'CreditNote' })
|
||||
.modify('default');
|
||||
|
||||
return {
|
||||
defaultTemplateId: defaultPdfTemplate?.id,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import Knex from 'knex';
|
||||
import { IRefundCreditNote } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { Knex } from 'knex';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export default class RefundSyncCreditNoteBalance {
|
||||
|
||||
@@ -68,30 +68,25 @@ export const DEFAULT_VIEWS = [
|
||||
];
|
||||
|
||||
export const defaultCreditNoteBrandingAttributes = {
|
||||
// # Colors
|
||||
primaryColor: '',
|
||||
secondaryColor: '',
|
||||
|
||||
// # Company logo
|
||||
showCompanyLogo: true,
|
||||
companyLogo: '',
|
||||
companyLogoKey: '',
|
||||
companyLogoUri: '',
|
||||
|
||||
// # Company name
|
||||
companyName: 'Bigcapital Technology, Inc.',
|
||||
|
||||
// Address
|
||||
billedToAddress: [
|
||||
'Bigcapital Technology, Inc.',
|
||||
'131 Continental Dr Suite 305 Newark,',
|
||||
'Delaware 19713',
|
||||
'United States',
|
||||
'+1 762-339-5634',
|
||||
'ahmed@bigcapital.app',
|
||||
],
|
||||
billedFromAddress: [
|
||||
'131 Continental Dr Suite 305 Newark,',
|
||||
'Delaware 19713',
|
||||
'United States',
|
||||
'+1 762-339-5634',
|
||||
'ahmed@bigcapital.app',
|
||||
],
|
||||
showBilledToAddress: true,
|
||||
showBilledFromAddress: true,
|
||||
// # Customer address
|
||||
showCustomerAddress: true,
|
||||
customerAddress: '',
|
||||
|
||||
// # Company address
|
||||
showCompanyAddress: true,
|
||||
companyAddress: '',
|
||||
billedToLabel: 'Billed To',
|
||||
|
||||
// Total
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CreditNotePdfTemplateAttributes, ICreditNote } from '@/interfaces';
|
||||
import { contactAddressTextFormat } from '@/utils/address-text-format';
|
||||
|
||||
export const transformCreditNoteToPdfTemplate = (
|
||||
creditNote: ICreditNote
|
||||
@@ -19,5 +20,6 @@ export const transformCreditNoteToPdfTemplate = (
|
||||
})),
|
||||
customerNote: creditNote.note,
|
||||
termsConditions: creditNote.termsConditions,
|
||||
customerAddress: contactAddressTextFormat(creditNote.customer),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ACCOUNT_CREATED,
|
||||
ACCOUNT_EDITED,
|
||||
ACCOUNT_DELETED,
|
||||
ACCOUNT_VIEWED,
|
||||
} from '@/constants/event-tracker';
|
||||
|
||||
@Service()
|
||||
@@ -31,6 +32,7 @@ export class AccountEventsTracker extends EventSubscriber {
|
||||
events.accounts.onDeleted,
|
||||
this.handleTrackDeletedAccountEvent
|
||||
);
|
||||
bus.subscribe(events.accounts.onViewed, this.handleTrackAccountViewedEvent);
|
||||
}
|
||||
|
||||
private handleTrackAccountCreatedEvent = ({
|
||||
@@ -62,4 +64,12 @@ export class AccountEventsTracker extends EventSubscriber {
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackAccountViewedEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: ACCOUNT_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ITEM_EVENT_CREATED,
|
||||
ITEM_EVENT_EDITED,
|
||||
ITEM_EVENT_DELETED,
|
||||
ITEM_EVENT_VIEWED,
|
||||
} from '@/constants/event-tracker';
|
||||
|
||||
@Service()
|
||||
@@ -25,6 +26,7 @@ export class ItemEventsTracker extends EventSubscriber {
|
||||
bus.subscribe(events.item.onCreated, this.handleTrackItemCreatedEvent);
|
||||
bus.subscribe(events.item.onEdited, this.handleTrackEditedItemEvent);
|
||||
bus.subscribe(events.item.onDeleted, this.handleTrackDeletedItemEvent);
|
||||
bus.subscribe(events.item.onViewed, this.handleTrackViewedItemEvent);
|
||||
}
|
||||
|
||||
private handleTrackItemCreatedEvent = ({
|
||||
@@ -56,4 +58,14 @@ export class ItemEventsTracker extends EventSubscriber {
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackViewedItemEvent = ({
|
||||
tenantId,
|
||||
}: IItemEventDeletedPayload) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: ITEM_EVENT_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
|
||||
import { PosthogService } from '../PostHog';
|
||||
import { INVOICE_PAYMENT_LINK_GENERATED } from '@/constants/event-tracker';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class PaymentLinkEventsTracker extends EventSubscriber {
|
||||
@Inject()
|
||||
private posthog: PosthogService;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.saleInvoice.onPublicLinkGenerated,
|
||||
this.handleTrackInvoicePublicLinkGeneratedEvent
|
||||
);
|
||||
}
|
||||
|
||||
public handleTrackInvoicePublicLinkGeneratedEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: INVOICE_PAYMENT_LINK_GENERATED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
|
||||
import { PosthogService } from '../PostHog';
|
||||
import events from '@/subscribers/events';
|
||||
import {
|
||||
PAYMENT_METHOD_EDITED,
|
||||
PAYMENT_METHOD_DELETED,
|
||||
} from '@/constants/event-tracker';
|
||||
|
||||
@Service()
|
||||
export class PaymentMethodEventsTracker extends EventSubscriber {
|
||||
@Inject()
|
||||
private posthog: PosthogService;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.paymentMethod.onEdited,
|
||||
this.handleTrackPaymentMethodEditedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.paymentMethod.onDeleted,
|
||||
this.handleTrackPaymentMethodDeletedEvent
|
||||
);
|
||||
}
|
||||
|
||||
private handleTrackPaymentMethodEditedEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PAYMENT_METHOD_EDITED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackPaymentMethodDeletedEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PAYMENT_METHOD_DELETED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
PAYMENT_RECEIVED_CREATED,
|
||||
PAYMENT_RECEIVED_EDITED,
|
||||
PAYMENT_RECEIVED_DELETED,
|
||||
PAYMENT_RECEIVED_PDF_VIEWED,
|
||||
PAYMENT_RECEIVED_MAIL_SENT,
|
||||
} from '@/constants/event-tracker';
|
||||
|
||||
@Service()
|
||||
@@ -34,6 +36,14 @@ export class PaymentReceivedEventsTracker extends EventSubscriber {
|
||||
events.paymentReceive.onDeleted,
|
||||
this.handleTrackDeletedPaymentReceivedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.paymentReceive.onPdfViewed,
|
||||
this.handleTrackPdfViewedPaymentReceivedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.paymentReceive.onMailSent,
|
||||
this.handleTrackMailSentPaymentReceivedEvent
|
||||
);
|
||||
}
|
||||
|
||||
private handleTrackPaymentReceivedCreatedEvent = ({
|
||||
@@ -65,4 +75,24 @@ export class PaymentReceivedEventsTracker extends EventSubscriber {
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackPdfViewedPaymentReceivedEvent = ({
|
||||
tenantId,
|
||||
}: IPaymentReceivedDeletedPayload) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PAYMENT_RECEIVED_PDF_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackMailSentPaymentReceivedEvent = ({
|
||||
tenantId,
|
||||
}: IPaymentReceivedDeletedPayload) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PAYMENT_RECEIVED_MAIL_SENT,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import {
|
||||
PDF_TEMPLATE_CREATED,
|
||||
PDF_TEMPLATE_EDITED,
|
||||
PDF_TEMPLATE_DELETED,
|
||||
PDF_TEMPLATE_ASSIGNED_DEFAULT,
|
||||
} from '@/constants/event-tracker';
|
||||
import { PosthogService } from '../PostHog';
|
||||
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class PdfTemplateEventsTracker extends EventSubscriber {
|
||||
@Inject()
|
||||
private posthog: PosthogService;
|
||||
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.pdfTemplate.onCreated,
|
||||
this.handleTrackPdfTemplateCreatedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.pdfTemplate.onEdited,
|
||||
this.handleTrackEditedPdfTemplateEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.pdfTemplate.onDeleted,
|
||||
this.handleTrackDeletedPdfTemplateEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.pdfTemplate.onAssignedDefault,
|
||||
this.handleTrackAssignedAsDefaultPdfTemplateEvent
|
||||
);
|
||||
}
|
||||
|
||||
private handleTrackPdfTemplateCreatedEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PDF_TEMPLATE_CREATED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackEditedPdfTemplateEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PDF_TEMPLATE_EDITED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackDeletedPdfTemplateEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PDF_TEMPLATE_DELETED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackAssignedAsDefaultPdfTemplateEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PDF_TEMPLATE_ASSIGNED_DEFAULT,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
|
||||
import { ReportsEvents } from '@/constants/event-tracker';
|
||||
import { PosthogService } from '../PostHog';
|
||||
import events from '@/subscribers/events';
|
||||
import {
|
||||
BALANCE_SHEET_VIEWED,
|
||||
TRIAL_BALANCE_SHEET_VIEWED,
|
||||
PROFIT_LOSS_SHEET_VIEWED,
|
||||
CASHFLOW_STATEMENT_VIEWED,
|
||||
GENERAL_LEDGER_VIEWED,
|
||||
JOURNAL_VIEWED,
|
||||
RECEIVABLE_AGING_VIEWED,
|
||||
PAYABLE_AGING_VIEWED,
|
||||
CUSTOMER_BALANCE_SUMMARY_VIEWED,
|
||||
VENDOR_BALANCE_SUMMARY_VIEWED,
|
||||
INVENTORY_VALUATION_VIEWED,
|
||||
CUSTOMER_TRANSACTIONS_VIEWED,
|
||||
VENDOR_TRANSACTIONS_VIEWED,
|
||||
SALES_BY_ITEM_VIEWED,
|
||||
PURCHASES_BY_ITEM_VIEWED,
|
||||
} from '@/constants/event-tracker';
|
||||
|
||||
@Service()
|
||||
export class ReportsEventsTracker extends EventSubscriber {
|
||||
@Inject()
|
||||
private posthog: PosthogService;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.reports.onBalanceSheetViewed,
|
||||
this.handleTrackBalanceSheetViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onTrialBalanceSheetView,
|
||||
this.handleTrackTrialBalanceSheetViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onProfitLossSheetViewed,
|
||||
this.handleTrackProfitLossSheetViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onCashflowStatementViewed,
|
||||
this.handleTrackCashflowStatementViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onGeneralLedgerViewed,
|
||||
this.handleTrackGeneralLedgerViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onJournalViewed,
|
||||
this.handleTrackJournalViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onReceivableAgingViewed,
|
||||
this.handleTrackReceivableAgingViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onPayableAgingViewed,
|
||||
this.handleTrackPayableAgingViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onCustomerBalanceSummaryViewed,
|
||||
this.handleTrackCustomerBalanceSummaryViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onVendorBalanceSummaryViewed,
|
||||
this.handleTrackVendorBalanceSummaryViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onInventoryValuationViewed,
|
||||
this.handleTrackInventoryValuationViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onCustomerTransactionsViewed,
|
||||
this.handleTrackCustomerTransactionsViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onVendorTransactionsViewed,
|
||||
this.handleTrackVendorTransactionsViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onSalesByItemViewed,
|
||||
this.handleTrackSalesByItemViewedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.reports.onPurchasesByItemViewed,
|
||||
this.handleTrackPurchasesByItemViewedEvent
|
||||
);
|
||||
}
|
||||
|
||||
private handleTrackBalanceSheetViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: BALANCE_SHEET_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackTrialBalanceSheetViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: TRIAL_BALANCE_SHEET_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackProfitLossSheetViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PROFIT_LOSS_SHEET_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackCashflowStatementViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: CASHFLOW_STATEMENT_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackGeneralLedgerViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: GENERAL_LEDGER_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackJournalViewedEvent = ({ tenantId }: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: JOURNAL_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackReceivableAgingViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: RECEIVABLE_AGING_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackPayableAgingViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PAYABLE_AGING_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackCustomerBalanceSummaryViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: CUSTOMER_BALANCE_SUMMARY_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackVendorBalanceSummaryViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: VENDOR_BALANCE_SUMMARY_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackInventoryValuationViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: INVENTORY_VALUATION_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackCustomerTransactionsViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: CUSTOMER_TRANSACTIONS_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackVendorTransactionsViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: VENDOR_TRANSACTIONS_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackSalesByItemViewedEvent = ({ tenantId }: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SALES_BY_ITEM_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackPurchasesByItemViewedEvent = ({
|
||||
tenantId,
|
||||
}: ReportsEvents) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: PURCHASES_BY_ITEM_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import {
|
||||
SALE_ESTIMATE_CREATED,
|
||||
SALE_ESTIMATE_EDITED,
|
||||
SALE_ESTIMATE_DELETED,
|
||||
SALE_ESTIMATE_PDF_VIEWED,
|
||||
SALE_ESTIMATE_VIEWED,
|
||||
SALE_ESTIMATE_MAIL_SENT,
|
||||
} from '@/constants/event-tracker';
|
||||
|
||||
@Service()
|
||||
@@ -34,6 +37,18 @@ export class SaleEstimateEventsTracker extends EventSubscriber {
|
||||
events.saleEstimate.onDeleted,
|
||||
this.handleTrackDeletedEstimateEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.saleEstimate.onPdfViewed,
|
||||
this.handleTrackPdfViewedEstimateEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.saleEstimate.onViewed,
|
||||
this.handleTrackViewedEstimateEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.saleEstimate.onMailSent,
|
||||
this.handleTrackMailSentEstimateEvent
|
||||
);
|
||||
}
|
||||
|
||||
private handleTrackEstimateCreatedEvent = ({
|
||||
@@ -65,4 +80,30 @@ export class SaleEstimateEventsTracker extends EventSubscriber {
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackPdfViewedEstimateEvent = ({
|
||||
tenantId,
|
||||
}: ISaleEstimateDeletedPayload) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SALE_ESTIMATE_PDF_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackViewedEstimateEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SALE_ESTIMATE_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackMailSentEstimateEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SALE_ESTIMATE_MAIL_SENT,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ import {
|
||||
SALE_INVOICE_CREATED,
|
||||
SALE_INVOICE_DELETED,
|
||||
SALE_INVOICE_EDITED,
|
||||
SALE_INVOICE_MAIL_SENT,
|
||||
SALE_INVOICE_PDF_VIEWED,
|
||||
SALE_INVOICE_VIEWED,
|
||||
} from '@/constants/event-tracker';
|
||||
|
||||
@Service()
|
||||
@@ -33,6 +36,18 @@ export class SaleInvoiceEventsTracker extends EventSubscriber {
|
||||
events.saleInvoice.onDeleted,
|
||||
this.handleTrackDeletedInvoiceEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.saleInvoice.onViewed,
|
||||
this.handleTrackViewedInvoiceEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.saleInvoice.onPdfViewed,
|
||||
this.handleTrackPdfViewedInvoiceEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.saleInvoice.onMailSent,
|
||||
this.handleTrackMailSentInvoiceEvent
|
||||
);
|
||||
}
|
||||
|
||||
private handleTrackInvoiceCreatedEvent = ({
|
||||
@@ -64,4 +79,28 @@ export class SaleInvoiceEventsTracker extends EventSubscriber {
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackViewedInvoiceEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SALE_INVOICE_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackPdfViewedInvoiceEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SALE_INVOICE_PDF_VIEWED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleTrackMailSentInvoiceEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SALE_INVOICE_MAIL_SENT,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
|
||||
import { ISaleInvoiceCreatedPayload } from '@/interfaces';
|
||||
import { PosthogService } from '../PostHog';
|
||||
import { STRIPE_INTEGRAION_CONNECTED } from '@/constants/event-tracker';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class StripeIntegrationEventsTracker extends EventSubscriber {
|
||||
@Inject()
|
||||
private posthog: PosthogService;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.stripeIntegration.onOAuthCodeGranted,
|
||||
this.handleTrackOAuthCodeGrantedTrackEvent
|
||||
);
|
||||
}
|
||||
|
||||
private handleTrackOAuthCodeGrantedTrackEvent = ({
|
||||
tenantId,
|
||||
}: ISaleInvoiceCreatedPayload) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: STRIPE_INTEGRAION_CONNECTED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import { ITransactionsLockingPartialUnlocked } from '@/interfaces';
|
||||
import { PosthogService } from '../PostHog';
|
||||
import {
|
||||
SUBSCRIPTION_CANCELLED,
|
||||
SUBSCRIPTION_PAYMENT_FAILED,
|
||||
SUBSCRIPTION_PAYMENT_SUCCEED,
|
||||
SUBSCRIPTION_PLAN_CHANGED,
|
||||
SUBSCRIPTION_RESUMED,
|
||||
} from '@/constants/event-tracker';
|
||||
@@ -27,6 +29,14 @@ export class TransactionsLockingEventsTracker extends EventSubscriber {
|
||||
events.subscription.onSubscriptionPlanChanged,
|
||||
this.handleSubscriptionPlanChangedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.subscription.onSubscriptionPaymentSucceed,
|
||||
this.handleSubscriptionPaymentFailedEvent
|
||||
);
|
||||
bus.subscribe(
|
||||
events.subscription.onSubscriptionPaymentFailed,
|
||||
this.handleSubscriptionPaymentSucceed
|
||||
);
|
||||
}
|
||||
|
||||
private handleSubscriptionResumedEvent = ({ tenantId }) => {
|
||||
@@ -52,4 +62,20 @@ export class TransactionsLockingEventsTracker extends EventSubscriber {
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleSubscriptionPaymentFailedEvent = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SUBSCRIPTION_PAYMENT_FAILED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
|
||||
private handleSubscriptionPaymentSucceed = ({ tenantId }) => {
|
||||
this.posthog.trackEvent({
|
||||
distinctId: `tenant-${tenantId}`,
|
||||
event: SUBSCRIPTION_PAYMENT_SUCCEED,
|
||||
properties: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@ import { CustomerEventsTracker } from './CustomerEventsTracker';
|
||||
import { VendorEventsTracker } from './VendorEventsTracker';
|
||||
import { ManualJournalEventsTracker } from './ManualJournalEventsTracker';
|
||||
import { BankRuleEventsTracker } from './BankRuleEventsTracker';
|
||||
import { PdfTemplateEventsTracker } from './PdfTemplateEventsTracker';
|
||||
import { PaymentMethodEventsTracker } from './PaymentMethodEventsTracker';
|
||||
import { PaymentLinkEventsTracker } from './PaymentLinkEventsTracker';
|
||||
import { StripeIntegrationEventsTracker } from './StripeIntegrationEventsTracker';
|
||||
import { ReportsEventsTracker } from './ReportsEventsTracker';
|
||||
|
||||
export const EventsTrackerListeners = [
|
||||
SaleInvoiceEventsTracker,
|
||||
@@ -28,4 +33,9 @@ export const EventsTrackerListeners = [
|
||||
VendorEventsTracker,
|
||||
ManualJournalEventsTracker,
|
||||
BankRuleEventsTracker,
|
||||
PdfTemplateEventsTracker,
|
||||
PaymentMethodEventsTracker,
|
||||
PaymentLinkEventsTracker,
|
||||
StripeIntegrationEventsTracker,
|
||||
ReportsEventsTracker,
|
||||
];
|
||||
|
||||
@@ -6,6 +6,8 @@ import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import APAgingSummarySheet from './APAgingSummarySheet';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { APAgingSummaryMeta } from './APAgingSummaryMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class APAgingSummaryService {
|
||||
@@ -15,6 +17,9 @@ export class APAgingSummaryService {
|
||||
@Inject()
|
||||
private APAgingSummaryMeta: APAgingSummaryMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Default report query.
|
||||
*/
|
||||
@@ -96,6 +101,12 @@ export class APAgingSummaryService {
|
||||
// Retrieve the aging summary report meta.
|
||||
const meta = await this.APAgingSummaryMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onPayableAgingViewed` event.
|
||||
await this.eventPublisher.emitAsync(events.reports.onPayableAgingViewed, {
|
||||
tenantId,
|
||||
query,
|
||||
});
|
||||
|
||||
return {
|
||||
data,
|
||||
columns,
|
||||
|
||||
@@ -6,6 +6,8 @@ import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import ARAgingSummarySheet from './ARAgingSummarySheet';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { ARAgingSummaryMeta } from './ARAgingSummaryMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export default class ARAgingSummaryService {
|
||||
@@ -15,6 +17,9 @@ export default class ARAgingSummaryService {
|
||||
@Inject()
|
||||
private ARAgingSummaryMeta: ARAgingSummaryMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Default report query.
|
||||
*/
|
||||
@@ -91,6 +96,15 @@ export default class ARAgingSummaryService {
|
||||
// Retrieve the aging summary report meta.
|
||||
const meta = await this.ARAgingSummaryMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onReceivableAgingViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onReceivableAgingViewed,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data,
|
||||
columns,
|
||||
|
||||
@@ -10,6 +10,8 @@ import BalanceSheetStatement from './BalanceSheet';
|
||||
import { Tenant } from '@/system/models';
|
||||
import BalanceSheetRepository from './BalanceSheetRepository';
|
||||
import { BalanceSheetMetaInjectable } from './BalanceSheetMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export default class BalanceSheetStatementService
|
||||
@@ -21,6 +23,9 @@ export default class BalanceSheetStatementService
|
||||
@Inject()
|
||||
private balanceSheetMeta: BalanceSheetMetaInjectable;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {IBalanceSheetQuery}
|
||||
@@ -98,6 +103,10 @@ export default class BalanceSheetStatementService
|
||||
// Balance sheet meta.
|
||||
const meta = await this.balanceSheetMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onBalanceSheetViewed` event.
|
||||
await this.eventPublisher.emitAsync(events.reports.onBalanceSheetViewed, {
|
||||
query,
|
||||
});
|
||||
return {
|
||||
query: filter,
|
||||
data,
|
||||
|
||||
@@ -13,6 +13,8 @@ import Ledger from '@/services/Accounting/Ledger';
|
||||
import CustomerBalanceSummaryRepository from './CustomerBalanceSummaryRepository';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { CustomerBalanceSummaryMeta } from './CustomerBalanceSummaryMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class CustomerBalanceSummaryService
|
||||
@@ -24,6 +26,9 @@ export class CustomerBalanceSummaryService
|
||||
@Inject()
|
||||
private customerBalanceSummaryMeta: CustomerBalanceSummaryMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {ICustomerBalanceSummaryQuery}
|
||||
@@ -104,6 +109,15 @@ export class CustomerBalanceSummaryService
|
||||
// Retrieve the customer balance summary meta.
|
||||
const meta = await this.customerBalanceSummaryMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onCustomerBalanceSummaryViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onCustomerBalanceSummaryViewed,
|
||||
{
|
||||
tenant,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: report.reportData(),
|
||||
query: filter,
|
||||
|
||||
@@ -5,6 +5,8 @@ import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import GeneralLedgerSheet from '@/services/FinancialStatements/GeneralLedger/GeneralLedger';
|
||||
import { GeneralLedgerMeta } from './GeneralLedgerMeta';
|
||||
import { GeneralLedgerRepository } from './GeneralLedgerRepository';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class GeneralLedgerService {
|
||||
@@ -14,6 +16,9 @@ export class GeneralLedgerService {
|
||||
@Inject()
|
||||
private generalLedgerMeta: GeneralLedgerMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults general ledger report filter query.
|
||||
* @return {IBalanceSheetQuery}
|
||||
@@ -72,6 +77,11 @@ export class GeneralLedgerService {
|
||||
// Retrieve general ledger report metadata.
|
||||
const meta = await this.generalLedgerMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onGeneralLedgerViewed` event.
|
||||
await this.eventPublisher.emitAsync(events.reports.onGeneralLedgerViewed, {
|
||||
tenantId,
|
||||
});
|
||||
|
||||
return {
|
||||
data: reportData,
|
||||
query: filter,
|
||||
|
||||
@@ -11,6 +11,8 @@ import { InventoryValuationSheet } from './InventoryValuationSheet';
|
||||
import InventoryService from '@/services/Inventory/Inventory';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { InventoryValuationMetaInjectable } from './InventoryValuationSheetMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class InventoryValuationSheetService {
|
||||
@@ -26,6 +28,9 @@ export class InventoryValuationSheetService {
|
||||
@Inject()
|
||||
private inventoryValuationMeta: InventoryValuationMetaInjectable;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {IBalanceSheetQuery}
|
||||
@@ -116,6 +121,15 @@ export class InventoryValuationSheetService {
|
||||
// Retrieves the inventorty valuation meta.
|
||||
const meta = await this.inventoryValuationMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onInventoryValuationViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onInventoryValuationViewed,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: inventoryValuationData,
|
||||
query: filter,
|
||||
|
||||
@@ -7,6 +7,8 @@ import Journal from '@/services/Accounting/JournalPoster';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { transformToMap } from 'utils';
|
||||
import { JournalSheetMeta } from './JournalSheetMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class JournalSheetService {
|
||||
@@ -16,6 +18,9 @@ export class JournalSheetService {
|
||||
@Inject()
|
||||
private journalSheetMeta: JournalSheetMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Default journal sheet filter queyr.
|
||||
*/
|
||||
@@ -101,6 +106,12 @@ export class JournalSheetService {
|
||||
// Retrieve the journal sheet meta.
|
||||
const meta = await this.journalSheetMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onJournalViewed` event.
|
||||
await this.eventPublisher.emitAsync(events.reports.onJournalViewed, {
|
||||
tenantId,
|
||||
query,
|
||||
});
|
||||
|
||||
return {
|
||||
data: journalSheetData,
|
||||
query: filter,
|
||||
|
||||
@@ -10,6 +10,8 @@ import { Tenant } from '@/system/models';
|
||||
import { mergeQueryWithDefaults } from './utils';
|
||||
import { ProfitLossSheetRepository } from './ProfitLossSheetRepository';
|
||||
import { ProfitLossSheetMeta } from './ProfitLossSheetMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
// Profit/Loss sheet service.
|
||||
@Service()
|
||||
@@ -20,6 +22,9 @@ export default class ProfitLossSheetService {
|
||||
@Inject()
|
||||
private profitLossSheetMeta: ProfitLossSheetMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Retrieve profit/loss sheet statement.
|
||||
* @param {number} tenantId
|
||||
@@ -62,6 +67,15 @@ export default class ProfitLossSheetService {
|
||||
// Retrieve the profit/loss sheet meta.
|
||||
const meta = await this.profitLossSheetMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onProfitLossSheetViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onProfitLossSheetViewed,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
query: filter,
|
||||
data,
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
IPurchasesByItemsSheet,
|
||||
} from '@/interfaces/PurchasesByItemsSheet';
|
||||
import { PurchasesByItemsMeta } from './PurchasesByItemsMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class PurchasesByItemsService {
|
||||
@@ -17,6 +19,9 @@ export class PurchasesByItemsService {
|
||||
@Inject()
|
||||
private purchasesByItemsMeta: PurchasesByItemsMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults purchases by items filter query.
|
||||
* @return {IPurchasesByItemsReportQuery}
|
||||
@@ -92,6 +97,15 @@ export class PurchasesByItemsService {
|
||||
// Retrieve the purchases by items meta.
|
||||
const meta = await this.purchasesByItemsMeta.meta(tenantId, query);
|
||||
|
||||
// Triggers `onPurchasesByItemViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onPurchasesByItemViewed,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: purchasesByItemsData,
|
||||
query: filter,
|
||||
|
||||
@@ -5,6 +5,8 @@ import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import SalesByItems from './SalesByItems';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { SalesByItemsMeta } from './SalesByItemsMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class SalesByItemsReportService {
|
||||
@@ -14,6 +16,9 @@ export class SalesByItemsReportService {
|
||||
@Inject()
|
||||
private salesByItemsMeta: SalesByItemsMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {IBalanceSheetQuery}
|
||||
@@ -89,6 +94,12 @@ export class SalesByItemsReportService {
|
||||
// Retrieve the sales by items meta.
|
||||
const meta = await this.salesByItemsMeta.meta(tenantId, query);
|
||||
|
||||
// Triggers `onSalesByItemViewed` event.
|
||||
await this.eventPublisher.emitAsync(events.reports.onSalesByItemViewed, {
|
||||
tenantId,
|
||||
query,
|
||||
});
|
||||
|
||||
return {
|
||||
data: salesByItemsData,
|
||||
query: filter,
|
||||
|
||||
@@ -13,6 +13,8 @@ import Ledger from '@/services/Accounting/Ledger';
|
||||
import TransactionsByCustomersRepository from './TransactionsByCustomersRepository';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { TransactionsByCustomersMeta } from './TransactionsByCustomersMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
export class TransactionsByCustomersSheet
|
||||
implements ITransactionsByCustomersService
|
||||
@@ -26,6 +28,9 @@ export class TransactionsByCustomersSheet
|
||||
@Inject()
|
||||
private transactionsByCustomersMeta: TransactionsByCustomersMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {ICustomerBalanceSummaryQuery}
|
||||
@@ -166,6 +171,15 @@ export class TransactionsByCustomersSheet
|
||||
|
||||
const meta = await this.transactionsByCustomersMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onCustomerTransactionsViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onCustomerTransactionsViewed,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: reportInstance.reportData(),
|
||||
query: filter,
|
||||
|
||||
@@ -13,6 +13,8 @@ import Ledger from '@/services/Accounting/Ledger';
|
||||
import TransactionsByVendorRepository from './TransactionsByVendorRepository';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { TransactionsByVendorMeta } from './TransactionsByVendorMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
export class TransactionsByVendorsInjectable
|
||||
implements ITransactionsByVendorsService
|
||||
@@ -26,6 +28,9 @@ export class TransactionsByVendorsInjectable
|
||||
@Inject()
|
||||
private transactionsByVendorMeta: TransactionsByVendorMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {IVendorBalanceSummaryQuery}
|
||||
@@ -171,6 +176,15 @@ export class TransactionsByVendorsInjectable
|
||||
);
|
||||
const meta = await this.transactionsByVendorMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onVendorTransactionsViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onVendorTransactionsViewed,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: reportInstance.reportData(),
|
||||
query: filter,
|
||||
|
||||
@@ -7,6 +7,8 @@ import FinancialSheet from '../FinancialSheet';
|
||||
import { Tenant } from '@/system/models';
|
||||
import { TrialBalanceSheetRepository } from './TrialBalanceSheetRepository';
|
||||
import { TrialBalanceSheetMeta } from './TrialBalanceSheetMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export default class TrialBalanceSheetService extends FinancialSheet {
|
||||
@@ -16,6 +18,9 @@ export default class TrialBalanceSheetService extends FinancialSheet {
|
||||
@Inject()
|
||||
private trialBalanceSheetMetaService: TrialBalanceSheetMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults trial balance sheet filter query.
|
||||
* @return {IBalanceSheetQuery}
|
||||
@@ -81,6 +86,15 @@ export default class TrialBalanceSheetService extends FinancialSheet {
|
||||
// Trial balance sheet meta.
|
||||
const meta = await this.trialBalanceSheetMetaService.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onTrialBalanceSheetViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onTrialBalanceSheetView,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: trialBalanceSheetData,
|
||||
query: filter,
|
||||
|
||||
@@ -15,6 +15,8 @@ import { Tenant } from '@/system/models';
|
||||
import { JournalSheetMeta } from '../JournalSheet/JournalSheetMeta';
|
||||
|
||||
import { VendorBalanceSummaryMeta } from './VendorBalanceSummaryMeta';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
export class VendorBalanceSummaryService
|
||||
implements IVendorBalanceSummaryService
|
||||
@@ -28,6 +30,9 @@ export class VendorBalanceSummaryService
|
||||
@Inject()
|
||||
private vendorBalanceSummaryMeta: VendorBalanceSummaryMeta;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Defaults balance sheet filter query.
|
||||
* @return {IVendorBalanceSummaryQuery}
|
||||
@@ -49,7 +54,7 @@ export class VendorBalanceSummaryService
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Retrieve the vendors ledger entrjes.
|
||||
* @param {number} tenantId -
|
||||
* @param {Date|string} date -
|
||||
@@ -107,10 +112,19 @@ export class VendorBalanceSummaryService
|
||||
// Retrieve the vendor balance summary meta.
|
||||
const meta = await this.vendorBalanceSummaryMeta.meta(tenantId, filter);
|
||||
|
||||
// Triggers `onVendorBalanceSummaryViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.reports.onVendorBalanceSummaryViewed,
|
||||
{
|
||||
tenantId,
|
||||
query,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: reportInstance.reportData(),
|
||||
query: filter,
|
||||
meta
|
||||
meta,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ export const valueParser =
|
||||
// Parses the enumeration value.
|
||||
} else if (field.fieldType === 'enumeration') {
|
||||
const option = get(field, 'options', []).find(
|
||||
(option) => option.label === value
|
||||
(option) => option.label?.toLowerCase() === value?.toLowerCase()
|
||||
);
|
||||
_value = get(option, 'key');
|
||||
// Parses the numeric value.
|
||||
@@ -433,8 +433,8 @@ export const getMapToPath = (to: string, group = '') =>
|
||||
group ? `${group}.${to}` : to;
|
||||
|
||||
export const getImportsStoragePath = () => {
|
||||
return path.join(global.__storage_dir, `/imports`);
|
||||
}
|
||||
return path.join(global.__storage_dir, `/imports`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes the imported file from the storage and database.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user