mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 15:50:32 +00:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -12,6 +12,9 @@
|
|||||||
<a href="https://github.com/bigcapitalhq/bigcapital/commits/develop">
|
<a href="https://github.com/bigcapitalhq/bigcapital/commits/develop">
|
||||||
<img src="https://img.shields.io/github/commit-activity/m/bigcapitalhq/bigcapital/develop" />
|
<img src="https://img.shields.io/github/commit-activity/m/bigcapitalhq/bigcapital/develop" />
|
||||||
</a>
|
</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">
|
<a href="https://discord.com/invite/c8nPBJafeb">
|
||||||
<img src="https://img.shields.io/discord/1066514716752625725?label=Discord" alt="" />
|
<img src="https://img.shields.io/discord/1066514716752625725?label=Discord" alt="" />
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"version": "independent",
|
"version": "independent",
|
||||||
"npmClient": "pnpm",
|
"npmClient": "pnpm",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*",
|
||||||
|
"shared/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -4,11 +4,11 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "lerna run dev",
|
"dev": "lerna run dev",
|
||||||
"build": "lerna run build",
|
"build": "lerna run build",
|
||||||
"dev:webapp": "lerna run dev --scope \"@bigcapital/webapp\"",
|
"dev:webapp": "lerna run dev --scope \"@bigcapital/webapp\" --scope \"@bigcapital/utils\"",
|
||||||
"build:webapp": "lerna run build --scope \"@bigcapital/webapp\"",
|
"build:webapp": "lerna run build --scope \"@bigcapital/webapp\" --scope \"@bigcapital/utils\"",
|
||||||
"dev:server": "lerna run dev --scope \"@bigcapital/server\"",
|
"dev:server": "lerna run dev --scope \"@bigcapital/server\" --scope \"@bigcapital/utils\"",
|
||||||
"build:server": "lerna run build --scope \"@bigcapital/server\"",
|
"build:server": "lerna run build --scope \"@bigcapital/server\" --scope \"@bigcapital/utils\"",
|
||||||
"serve:server": "lerna run serve --scope \"@bigcapital/server\"",
|
"serve:server": "lerna run serve --scope \"@bigcapital/server\" --scope \"@bigcapital/utils\"",
|
||||||
"test:e2e": "playwright test",
|
"test:e2e": "playwright test",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
@@ -29,5 +29,8 @@
|
|||||||
"hooks": {
|
"hooks": {
|
||||||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
"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
|
RUN npm install -g pnpm
|
||||||
|
|
||||||
# Copy application dependency manifests to the container image.
|
# Copy application dependency manifests to the container image.
|
||||||
COPY ./package*.json ./
|
COPY --chown=node:node ./ ./
|
||||||
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/
|
|
||||||
|
|
||||||
# Install application dependencies
|
# Install application dependencies
|
||||||
RUN apk update
|
RUN apk update
|
||||||
@@ -109,6 +105,6 @@ RUN pnpm install
|
|||||||
COPY --chown=node:node ./packages/server ./packages/server
|
COPY --chown=node:node ./packages/server ./packages/server
|
||||||
|
|
||||||
# # Creates a "dist" folder with the production build
|
# # 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" ]
|
CMD [ "node", "./packages/server/build/index.js" ]
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.576.0",
|
"@aws-sdk/client-s3": "^3.576.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.583.0",
|
"@aws-sdk/s3-request-presigner": "^3.583.0",
|
||||||
|
"@bigcapital/utils": "*",
|
||||||
"@casl/ability": "^5.4.3",
|
"@casl/ability": "^5.4.3",
|
||||||
"@hapi/boom": "^7.4.3",
|
"@hapi/boom": "^7.4.3",
|
||||||
"@lemonsqueezy/lemonsqueezy.js": "^2.2.0",
|
"@lemonsqueezy/lemonsqueezy.js": "^2.2.0",
|
||||||
|
|||||||
@@ -10,21 +10,37 @@ block head
|
|||||||
position: relative;
|
position: relative;
|
||||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
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 {
|
.#{prefix}-big-title {
|
||||||
font-size: 60px;
|
font-size: 30px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
margin-bottom: 25px;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
.#{prefix}-logo-wrap {
|
.#{prefix}-logo-wrap img {
|
||||||
height: 120px;
|
width: 100%;
|
||||||
width: 120px;
|
height: 100%;
|
||||||
position: absolute;
|
max-width: 260px;
|
||||||
right: 26px;
|
max-height: 100px;
|
||||||
top: 26px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
.#{prefix}-terms-list {
|
.#{prefix}-terms-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -132,11 +148,12 @@ block head
|
|||||||
|
|
||||||
block content
|
block content
|
||||||
div(class=`${prefix}-root`)
|
div(class=`${prefix}-root`)
|
||||||
div(class=`${prefix}-big-title`) Credit Note
|
|
||||||
|
|
||||||
if showCompanyLogo && companyLogoUri
|
//- Header (includes big title, details and logo)
|
||||||
div(class=`${prefix}-logo-wrap`)
|
div(class=`${prefix}-header`)
|
||||||
img(src=companyLogoUri alt=`Company Logo`)
|
//- Header details (includes big title and details)
|
||||||
|
div(class=`${prefix}-header-details`)
|
||||||
|
div(class=`${prefix}-big-title`) Credit Note
|
||||||
|
|
||||||
div(class=`${prefix}-terms-list`)
|
div(class=`${prefix}-terms-list`)
|
||||||
if showCreditNoteNumber
|
if showCreditNoteNumber
|
||||||
@@ -149,6 +166,10 @@ block content
|
|||||||
div(class=`${prefix}-terms-item__label`) #{creditNoteDateLabel}:
|
div(class=`${prefix}-terms-item__label`) #{creditNoteDateLabel}:
|
||||||
div(class=`${prefix}-terms-item__value`) #{creditNoteDate}
|
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`)
|
div(class=`${prefix}-address-section`)
|
||||||
if showCompanyAddress
|
if showCompanyAddress
|
||||||
div(class=`${prefix}-address-from`)
|
div(class=`${prefix}-address-from`)
|
||||||
|
|||||||
@@ -10,21 +10,37 @@ block head
|
|||||||
position: relative;
|
position: relative;
|
||||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
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 {
|
.#{prefix}-big-title {
|
||||||
font-size: 60px;
|
font-size: 30px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
margin-bottom: 25px;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
.#{prefix}-logo-wrap {
|
.#{prefix}-logo-wrap img {
|
||||||
height: 120px;
|
width: 100%;
|
||||||
width: 120px;
|
height: 100%;
|
||||||
position: absolute;
|
max-width: 260px;
|
||||||
right: 26px;
|
max-height: 100px;
|
||||||
top: 26px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
.#{prefix}-terms {
|
.#{prefix}-terms {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -131,11 +147,13 @@ block head
|
|||||||
|
|
||||||
block content
|
block content
|
||||||
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
||||||
h1(class=`${prefix}-big-title`) Estimate
|
|
||||||
|
|
||||||
if showCompanyLogo && companyLogoUri
|
//- Header (invluces big title, details and logo)
|
||||||
div(class=`${prefix}-logo-wrap`)
|
div(class=`${prefix}-header`)
|
||||||
img(alt="Company logo", src=companyLogoUri)
|
|
||||||
|
//- Header details (includes big title and details )
|
||||||
|
div(class=`${prefix}-header-details`)
|
||||||
|
h1(class=`${prefix}-big-title`) Estimate
|
||||||
|
|
||||||
//- Terms List
|
//- Terms List
|
||||||
div(class=`${prefix}-terms`)
|
div(class=`${prefix}-terms`)
|
||||||
@@ -143,15 +161,22 @@ block content
|
|||||||
div(class=`${prefix}-terms-item`)
|
div(class=`${prefix}-terms-item`)
|
||||||
div(class=`${prefix}-terms-item__label`) #{estimateNumberLabel}
|
div(class=`${prefix}-terms-item__label`) #{estimateNumberLabel}
|
||||||
div(class=`${prefix}-terms-item__value`) #{estimateNumebr}
|
div(class=`${prefix}-terms-item__value`) #{estimateNumebr}
|
||||||
|
|
||||||
if showEstimateDate
|
if showEstimateDate
|
||||||
div(class=`${prefix}-terms-item`)
|
div(class=`${prefix}-terms-item`)
|
||||||
div(class=`${prefix}-terms-item__label`) #{estimateDateLabel}
|
div(class=`${prefix}-terms-item__label`) #{estimateDateLabel}
|
||||||
div(class=`${prefix}-terms-item__value`) #{estimateDate}
|
div(class=`${prefix}-terms-item__value`) #{estimateDate}
|
||||||
|
|
||||||
if showExpirationDate
|
if showExpirationDate
|
||||||
div(class=`${prefix}-terms-item`)
|
div(class=`${prefix}-terms-item`)
|
||||||
div(class=`${prefix}-terms-item__label`) #{expirationDateLabel}
|
div(class=`${prefix}-terms-item__label`) #{expirationDateLabel}
|
||||||
div(class=`${prefix}-terms-item__value`) #{expirationDate}
|
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)
|
//- Addresses (Group section)
|
||||||
div(class=`${prefix}-addresses`)
|
div(class=`${prefix}-addresses`)
|
||||||
if showCompanyAddress
|
if showCompanyAddress
|
||||||
|
|||||||
@@ -10,21 +10,37 @@ block head
|
|||||||
position: relative;
|
position: relative;
|
||||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
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 {
|
.#{prefix}-big-title {
|
||||||
font-size: 60px;
|
font-size: 30px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
margin-bottom: 25px;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
.#{prefix}-logo-wrap {
|
.#{prefix}-logo-wrap img {
|
||||||
height: 120px;
|
width: 100%;
|
||||||
width: 120px;
|
height: 100%;
|
||||||
position: absolute;
|
max-width: 260px;
|
||||||
right: 26px;
|
max-height: 100px;
|
||||||
top: 26px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
.#{prefix}-details {
|
.#{prefix}-details {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -139,13 +155,13 @@ block content
|
|||||||
//- block head
|
//- block head
|
||||||
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
||||||
|
|
||||||
|
//- 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
|
//- Title and company logo
|
||||||
h1(class=`${prefix}-big-title`) Invoice
|
h1(class=`${prefix}-big-title`) Invoice
|
||||||
|
|
||||||
if showCompanyLogo && companyLogoUri
|
|
||||||
div(class=`${prefix}-logo-wrap`)
|
|
||||||
img(alt="Company logo", src=companyLogoUri)
|
|
||||||
|
|
||||||
//- Invoice details
|
//- Invoice details
|
||||||
div(class=`${prefix}-details`)
|
div(class=`${prefix}-details`)
|
||||||
if showInvoiceNumber
|
if showInvoiceNumber
|
||||||
@@ -163,6 +179,11 @@ block content
|
|||||||
div(class=`${prefix}-detail__label`) #{dueDateLabel}
|
div(class=`${prefix}-detail__label`) #{dueDateLabel}
|
||||||
div(class=`${prefix}-detail__value`) #{dueDate}
|
div(class=`${prefix}-detail__value`) #{dueDate}
|
||||||
|
|
||||||
|
//- Company logo
|
||||||
|
if showCompanyLogo && companyLogoUri
|
||||||
|
div(class=`${prefix}-logo-wrap`)
|
||||||
|
img(alt="Company logo", src=companyLogoUri)
|
||||||
|
|
||||||
//- Address section
|
//- Address section
|
||||||
div(class=`${prefix}-address-root`)
|
div(class=`${prefix}-address-root`)
|
||||||
if showCompanyAddress
|
if showCompanyAddress
|
||||||
|
|||||||
@@ -10,22 +10,38 @@ block head
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
position: relative;
|
position: relative;
|
||||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
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{
|
.#{prefix}-big-title{
|
||||||
font-size: 60px;
|
font-size: 30px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
margin-bottom: 25px;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
.#{prefix}-logo-wrap{
|
.#{prefix}-logo-wrap img {
|
||||||
height: 120px;
|
width: 100%;
|
||||||
width: 120px;
|
height: 100%;
|
||||||
position: absolute;
|
max-width: 260px;
|
||||||
right: 26px;
|
max-height: 100px;
|
||||||
top: 26px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
.#{prefix}-terms-list{
|
.#{prefix}-terms-list{
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -120,12 +136,11 @@ block head
|
|||||||
}
|
}
|
||||||
block content
|
block content
|
||||||
div(class=`${prefix}-root`)
|
div(class=`${prefix}-root`)
|
||||||
|
//- 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}-big-title`) Payment
|
||||||
|
|
||||||
if showCompanyLogo && companyLogoUri
|
|
||||||
div(class=`${prefix}-logo-wrap`)
|
|
||||||
img(src=companyLogoUri alt="Company Logo")
|
|
||||||
|
|
||||||
div(class=`${prefix}-terms-list`)
|
div(class=`${prefix}-terms-list`)
|
||||||
if showPaymentReceivedNumber
|
if showPaymentReceivedNumber
|
||||||
div(class=`${prefix}-terms-item`)
|
div(class=`${prefix}-terms-item`)
|
||||||
@@ -137,6 +152,10 @@ block content
|
|||||||
div(class=`${prefix}-terms-item__label`) #{paymentReceivedDateLabel}
|
div(class=`${prefix}-terms-item__label`) #{paymentReceivedDateLabel}
|
||||||
div(class=`${prefix}-terms-item__value`) #{paymentReceivedDate}
|
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`)
|
div(class=`${prefix}-addresses`)
|
||||||
if showCompanyAddress
|
if showCompanyAddress
|
||||||
div(class=`${prefix}-address-from`)
|
div(class=`${prefix}-address-from`)
|
||||||
|
|||||||
@@ -10,19 +10,33 @@ block head
|
|||||||
position: relative;
|
position: relative;
|
||||||
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
|
||||||
}
|
}
|
||||||
.#{prefix}-logo-wrap {
|
.#{prefix}-header{
|
||||||
height: 120px;
|
box-sizing: border-box;
|
||||||
width: 120px;
|
display: flex;
|
||||||
position: absolute;
|
flex-flow: wrap;
|
||||||
right: 26px;
|
flex: 0 0 auto;
|
||||||
top: 26px;
|
align-items: start;
|
||||||
overflow: hidden;
|
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 {
|
.#{prefix}-big-title {
|
||||||
font-size: 60px;
|
font-size: 30px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
margin-bottom: 25px;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
@@ -125,25 +139,30 @@ block content
|
|||||||
//- block head
|
//- block head
|
||||||
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
div(class=`${prefix}-root`, style=`--invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor};`)
|
||||||
|
|
||||||
|
//- 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
|
//- Title and company logo
|
||||||
h1(class=`${prefix}-big-title`) Receipt
|
h1(class=`${prefix}-big-title`) Receipt
|
||||||
|
|
||||||
//- Company Logo
|
|
||||||
if showCompanyLogo && companyLogoUri
|
|
||||||
div(class=`${prefix}-logo-wrap`)
|
|
||||||
img(src=companyLogoUri alt=`Company Logo`)
|
|
||||||
|
|
||||||
//- Terms List
|
//- Terms List
|
||||||
div(class=`${prefix}-terms-list`)
|
div(class=`${prefix}-terms-list`)
|
||||||
if showReceiptNumber
|
if showReceiptNumber
|
||||||
div(class=`${prefix}-terms-item`)
|
div(class=`${prefix}-terms-item`)
|
||||||
span(class=`${prefix}-terms-item__label`)= receiptNumberLabel
|
span(class=`${prefix}-terms-item__label`)= receiptNumberLabel
|
||||||
span(class=`${prefix}-terms-item__value`)= receiptNumber
|
span(class=`${prefix}-terms-item__value`)= receiptNumber
|
||||||
|
|
||||||
if showReceiptDate
|
if showReceiptDate
|
||||||
div(class=`${prefix}-terms-item`)
|
div(class=`${prefix}-terms-item`)
|
||||||
span(class=`${prefix}-terms-item__label`)= receiptDateLabel
|
span(class=`${prefix}-terms-item__label`)= receiptDateLabel
|
||||||
span(class=`${prefix}-terms-item__value`)= receiptDate
|
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
|
//- Address Section
|
||||||
div(class=`${prefix}-address-section`)
|
div(class=`${prefix}-address-section`)
|
||||||
if showCompanyAddress
|
if showCompanyAddress
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import GetCreditNoteAssociatedAppliedInvoices from '@/services/CreditNotes/GetCr
|
|||||||
import GetRefundCreditTransaction from '@/services/CreditNotes/GetRefundCreditNoteTransaction';
|
import GetRefundCreditTransaction from '@/services/CreditNotes/GetRefundCreditNoteTransaction';
|
||||||
import GetCreditNotePdf from '../../../services/CreditNotes/GetCreditNotePdf';
|
import GetCreditNotePdf from '../../../services/CreditNotes/GetCreditNotePdf';
|
||||||
import { ACCEPT_TYPE } from '@/interfaces/Http';
|
import { ACCEPT_TYPE } from '@/interfaces/Http';
|
||||||
|
import { GetCreditNoteState } from '@/services/CreditNotes/GetCreditNoteState';
|
||||||
/**
|
/**
|
||||||
* Credit notes controller.
|
* Credit notes controller.
|
||||||
* @service
|
* @service
|
||||||
@@ -81,6 +82,9 @@ export default class PaymentReceivesController extends BaseController {
|
|||||||
@Inject()
|
@Inject()
|
||||||
creditNotePdf: GetCreditNotePdf;
|
creditNotePdf: GetCreditNotePdf;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
getCreditNoteStateService: GetCreditNoteState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Router constructor.
|
* Router constructor.
|
||||||
*/
|
*/
|
||||||
@@ -105,6 +109,12 @@ export default class PaymentReceivesController extends BaseController {
|
|||||||
this.asyncMiddleware(this.newCreditNote),
|
this.asyncMiddleware(this.newCreditNote),
|
||||||
this.handleServiceErrors
|
this.handleServiceErrors
|
||||||
);
|
);
|
||||||
|
router.get(
|
||||||
|
'/state',
|
||||||
|
CheckPolicies(CreditNoteAction.View, AbilitySubject.CreditNote),
|
||||||
|
this.asyncMiddleware(this.getCreditNoteState.bind(this)),
|
||||||
|
this.handleServiceErrors
|
||||||
|
);
|
||||||
// Get specific credit note.
|
// Get specific credit note.
|
||||||
router.get(
|
router.get(
|
||||||
'/:id',
|
'/:id',
|
||||||
@@ -736,6 +746,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.
|
* Handles service errors.
|
||||||
* @param {Error} error
|
* @param {Error} error
|
||||||
|
|||||||
@@ -95,6 +95,12 @@ export default class PaymentReceivesController extends BaseController {
|
|||||||
asyncMiddleware(this.getPaymentReceiveInvoices.bind(this)),
|
asyncMiddleware(this.getPaymentReceiveInvoices.bind(this)),
|
||||||
this.handleServiceErrors
|
this.handleServiceErrors
|
||||||
);
|
);
|
||||||
|
router.get(
|
||||||
|
'/state',
|
||||||
|
CheckPolicies(PaymentReceiveAction.View, AbilitySubject.PaymentReceive),
|
||||||
|
this.getPaymentReceivedState.bind(this),
|
||||||
|
this.handleServiceErrors
|
||||||
|
);
|
||||||
router.get(
|
router.get(
|
||||||
'/:id',
|
'/:id',
|
||||||
CheckPolicies(PaymentReceiveAction.View, AbilitySubject.PaymentReceive),
|
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.
|
* Retrieve the given payment receive details.
|
||||||
* @async
|
* @async
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export default class SalesEstimatesController extends BaseController {
|
|||||||
router.post(
|
router.post(
|
||||||
'/:id/approve',
|
'/:id/approve',
|
||||||
CheckPolicies(SaleEstimateAction.Edit, AbilitySubject.SaleEstimate),
|
CheckPolicies(SaleEstimateAction.Edit, AbilitySubject.SaleEstimate),
|
||||||
[this.validateSpecificEstimateSchema],
|
[...this.validateSpecificEstimateSchema],
|
||||||
this.validationResult,
|
this.validationResult,
|
||||||
asyncMiddleware(this.approveSaleEstimate.bind(this)),
|
asyncMiddleware(this.approveSaleEstimate.bind(this)),
|
||||||
this.handleServiceErrors
|
this.handleServiceErrors
|
||||||
@@ -59,7 +59,7 @@ export default class SalesEstimatesController extends BaseController {
|
|||||||
router.post(
|
router.post(
|
||||||
'/:id/reject',
|
'/:id/reject',
|
||||||
CheckPolicies(SaleEstimateAction.Edit, AbilitySubject.SaleEstimate),
|
CheckPolicies(SaleEstimateAction.Edit, AbilitySubject.SaleEstimate),
|
||||||
[this.validateSpecificEstimateSchema],
|
[...this.validateSpecificEstimateSchema],
|
||||||
this.validationResult,
|
this.validationResult,
|
||||||
asyncMiddleware(this.rejectSaleEstimate.bind(this)),
|
asyncMiddleware(this.rejectSaleEstimate.bind(this)),
|
||||||
this.handleServiceErrors
|
this.handleServiceErrors
|
||||||
@@ -105,6 +105,12 @@ export default class SalesEstimatesController extends BaseController {
|
|||||||
asyncMiddleware(this.deleteEstimate.bind(this)),
|
asyncMiddleware(this.deleteEstimate.bind(this)),
|
||||||
this.handleServiceErrors
|
this.handleServiceErrors
|
||||||
);
|
);
|
||||||
|
router.get(
|
||||||
|
'/state',
|
||||||
|
CheckPolicies(SaleEstimateAction.View, AbilitySubject.SaleEstimate),
|
||||||
|
this.getSaleEstimateState.bind(this),
|
||||||
|
this.handleServiceErrors
|
||||||
|
);
|
||||||
router.get(
|
router.get(
|
||||||
'/:id',
|
'/:id',
|
||||||
CheckPolicies(SaleEstimateAction.View, AbilitySubject.SaleEstimate),
|
CheckPolicies(SaleEstimateAction.View, AbilitySubject.SaleEstimate),
|
||||||
@@ -546,6 +552,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.
|
* Handles service errors.
|
||||||
* @param {Error} error
|
* @param {Error} error
|
||||||
|
|||||||
@@ -130,6 +130,12 @@ export default class SaleInvoicesController extends BaseController {
|
|||||||
this.asyncMiddleware(this.getInvoicePaymentTransactions),
|
this.asyncMiddleware(this.getInvoicePaymentTransactions),
|
||||||
this.handleServiceErrors
|
this.handleServiceErrors
|
||||||
);
|
);
|
||||||
|
router.get(
|
||||||
|
'/state',
|
||||||
|
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
||||||
|
asyncMiddleware(this.getSaleInvoiceState.bind(this)),
|
||||||
|
this.handleServiceErrors
|
||||||
|
);
|
||||||
router.get(
|
router.get(
|
||||||
'/:id',
|
'/:id',
|
||||||
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
||||||
@@ -138,6 +144,7 @@ export default class SaleInvoicesController extends BaseController {
|
|||||||
asyncMiddleware(this.getSaleInvoice.bind(this)),
|
asyncMiddleware(this.getSaleInvoice.bind(this)),
|
||||||
this.handleServiceErrors
|
this.handleServiceErrors
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/',
|
'/',
|
||||||
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
CheckPolicies(SaleInvoiceAction.View, AbilitySubject.SaleInvoice),
|
||||||
@@ -453,6 +460,24 @@ export default class SaleInvoicesController extends BaseController {
|
|||||||
return res.status(200).send({ saleInvoice });
|
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.
|
* Retrieve paginated sales invoices with custom view metadata.
|
||||||
* @param {Request} req
|
* @param {Request} req
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ export default class SalesReceiptsController extends BaseController {
|
|||||||
this.handleServiceErrors,
|
this.handleServiceErrors,
|
||||||
this.dynamicListService.handlerErrorsToResponse
|
this.dynamicListService.handlerErrorsToResponse
|
||||||
);
|
);
|
||||||
|
router.get(
|
||||||
|
'/state',
|
||||||
|
CheckPolicies(SaleReceiptAction.View, AbilitySubject.SaleReceipt),
|
||||||
|
asyncMiddleware(this.getSaleReceiptState.bind(this)),
|
||||||
|
this.handleServiceErrors
|
||||||
|
);
|
||||||
router.get(
|
router.get(
|
||||||
'/:id',
|
'/:id',
|
||||||
CheckPolicies(SaleReceiptAction.View, AbilitySubject.SaleReceipt),
|
CheckPolicies(SaleReceiptAction.View, AbilitySubject.SaleReceipt),
|
||||||
@@ -369,6 +375,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.
|
* Sale receipt notification via SMS.
|
||||||
* @param {Request} req
|
* @param {Request} req
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ export class PublicSharableLinkController extends BaseController {
|
|||||||
this.getPaymentLinkPublicMeta.bind(this),
|
this.getPaymentLinkPublicMeta.bind(this),
|
||||||
this.validationResult
|
this.validationResult
|
||||||
);
|
);
|
||||||
|
router.get(
|
||||||
|
'/:paymentLinkId/invoice/pdf',
|
||||||
|
[param('paymentLinkId').exists()],
|
||||||
|
this.validationResult,
|
||||||
|
this.getPaymentLinkInvoicePdf.bind(this),
|
||||||
|
this.validationResult
|
||||||
|
);
|
||||||
router.post(
|
router.post(
|
||||||
'/:paymentLinkId/stripe_checkout_session',
|
'/:paymentLinkId/stripe_checkout_session',
|
||||||
[param('paymentLinkId').exists()],
|
[param('paymentLinkId').exists()],
|
||||||
@@ -80,4 +87,31 @@ export class PublicSharableLinkController extends BaseController {
|
|||||||
next(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export const SALE_INVOICE_CREATED = 'Sale invoice created';
|
|||||||
export const SALE_INVOICE_EDITED = 'Sale invoice edited';
|
export const SALE_INVOICE_EDITED = 'Sale invoice edited';
|
||||||
export const SALE_INVOICE_DELETED = 'Sale invoice deleted';
|
export const SALE_INVOICE_DELETED = 'Sale invoice deleted';
|
||||||
export const SALE_INVOICE_MAIL_DELIVERED = 'Sale invoice mail delivered';
|
export const SALE_INVOICE_MAIL_DELIVERED = 'Sale invoice mail delivered';
|
||||||
|
export const SALE_INVOICE_VIEWED = 'Sale invoice viewed';
|
||||||
|
|
||||||
export const SALE_ESTIMATE_CREATED = 'Sale estimate created';
|
export const SALE_ESTIMATE_CREATED = 'Sale estimate created';
|
||||||
export const SALE_ESTIMATE_EDITED = 'Sale estimate edited';
|
export const SALE_ESTIMATE_EDITED = 'Sale estimate edited';
|
||||||
@@ -26,10 +27,12 @@ export const EXPENSE_DELETED = 'Expense deleted';
|
|||||||
export const ACCOUNT_CREATED = 'Account created';
|
export const ACCOUNT_CREATED = 'Account created';
|
||||||
export const ACCOUNT_EDITED = 'Account Edited';
|
export const ACCOUNT_EDITED = 'Account Edited';
|
||||||
export const ACCOUNT_DELETED = 'Account deleted';
|
export const ACCOUNT_DELETED = 'Account deleted';
|
||||||
|
export const ACCOUNT_VIEWED = 'Account viewed';
|
||||||
|
|
||||||
export const ITEM_EVENT_CREATED = 'Item created';
|
export const ITEM_EVENT_CREATED = 'Item created';
|
||||||
export const ITEM_EVENT_EDITED = 'Item edited';
|
export const ITEM_EVENT_EDITED = 'Item edited';
|
||||||
export const ITEM_EVENT_DELETED = 'Item deleted';
|
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_SIGNED_UP = 'Auth Signed-up';
|
||||||
export const AUTH_RESET_PASSWORD = 'Auth reset password';
|
export const AUTH_RESET_PASSWORD = 'Auth reset password';
|
||||||
|
|||||||
@@ -314,3 +314,7 @@ export interface CreditNotePdfTemplateAttributes {
|
|||||||
showCreditNoteDate: boolean;
|
showCreditNoteDate: boolean;
|
||||||
creditNoteDateLabel: string;
|
creditNoteDateLabel: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ICreditNoteState {
|
||||||
|
defaultTemplateId: number;
|
||||||
|
}
|
||||||
@@ -238,3 +238,8 @@ export interface PaymentReceivedPdfTemplateAttributes {
|
|||||||
showPaymentReceivedDate: boolean;
|
showPaymentReceivedDate: boolean;
|
||||||
paymentReceivedDateLabel: string;
|
paymentReceivedDateLabel: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface IPaymentReceivedState {
|
||||||
|
defaultTemplateId: number;
|
||||||
|
}
|
||||||
@@ -144,3 +144,6 @@ export interface ISaleEstimateMailPresendEvent {
|
|||||||
messageOptions: SaleEstimateMailOptionsDTO;
|
messageOptions: SaleEstimateMailOptionsDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ISaleEstimateState {
|
||||||
|
defaultTemplateId: number;
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export interface PaymentIntegrationTransactionLinkEventPayload {
|
|||||||
referenceType: string;
|
referenceType: string;
|
||||||
referenceId: number;
|
referenceId: number;
|
||||||
saleInvoiceId: number;
|
saleInvoiceId: number;
|
||||||
trx?: Knex.Transaction
|
trx?: Knex.Transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaymentIntegrationTransactionLinkDeleteEventPayload {
|
export interface PaymentIntegrationTransactionLinkDeleteEventPayload {
|
||||||
@@ -30,7 +30,7 @@ export interface PaymentIntegrationTransactionLinkDeleteEventPayload {
|
|||||||
referenceType: string;
|
referenceType: string;
|
||||||
referenceId: number;
|
referenceId: number;
|
||||||
oldSaleInvoiceId: number;
|
oldSaleInvoiceId: number;
|
||||||
trx?: Knex.Transaction
|
trx?: Knex.Transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISaleInvoice {
|
export interface ISaleInvoice {
|
||||||
@@ -339,3 +339,7 @@ export interface InvoicePdfTemplateAttributes {
|
|||||||
showStatement: boolean;
|
showStatement: boolean;
|
||||||
statement: string;
|
statement: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ISaleInvocieState {
|
||||||
|
defaultTemplateId: number;
|
||||||
|
}
|
||||||
|
|||||||
@@ -211,3 +211,8 @@ export interface ISaleReceiptBrandingTemplateAttributes {
|
|||||||
showReceiptDate: boolean;
|
showReceiptDate: boolean;
|
||||||
receiptDateLabel: string;
|
receiptDateLabel: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface ISaleReceiptState {
|
||||||
|
defaultTemplateId: number;
|
||||||
|
}
|
||||||
@@ -29,6 +29,20 @@ export class PdfTemplate extends TenantModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model modifiers.
|
||||||
|
*/
|
||||||
|
static get modifiers() {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* Filters the due invoices.
|
||||||
|
*/
|
||||||
|
default(query) {
|
||||||
|
query.where('default', true);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual attributes.
|
* Virtual attributes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import I18nService from '@/services/I18n/I18nService';
|
|||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
import { AccountTransformer } from './AccountTransform';
|
import { AccountTransformer } from './AccountTransform';
|
||||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||||
|
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||||
|
import events from '@/subscribers/events';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class GetAccount {
|
export class GetAccount {
|
||||||
@@ -15,6 +17,9 @@ export class GetAccount {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private transformer: TransformerInjectable;
|
private transformer: TransformerInjectable;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private eventPublisher: EventPublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the given account details.
|
* Retrieve the given account details.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
@@ -39,6 +44,13 @@ export class GetAccount {
|
|||||||
new AccountTransformer(),
|
new AccountTransformer(),
|
||||||
{ accountsGraph }
|
{ accountsGraph }
|
||||||
);
|
);
|
||||||
|
const eventPayload = {
|
||||||
|
tenantId,
|
||||||
|
accountId,
|
||||||
|
};
|
||||||
|
// Triggers `onAccountViewed` event.
|
||||||
|
await this.eventPublisher.emitAsync(events.accounts.onViewed, eventPayload);
|
||||||
|
|
||||||
return this.i18nService.i18nApply(
|
return this.i18nService.i18nApply(
|
||||||
[['accountTypeLabel'], ['accountNormalFormatted']],
|
[['accountTypeLabel'], ['accountNormalFormatted']],
|
||||||
transformed,
|
transformed,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
ACCOUNT_CREATED,
|
ACCOUNT_CREATED,
|
||||||
ACCOUNT_EDITED,
|
ACCOUNT_EDITED,
|
||||||
ACCOUNT_DELETED,
|
ACCOUNT_DELETED,
|
||||||
|
ACCOUNT_VIEWED,
|
||||||
} from '@/constants/event-tracker';
|
} from '@/constants/event-tracker';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
@@ -31,6 +32,7 @@ export class AccountEventsTracker extends EventSubscriber {
|
|||||||
events.accounts.onDeleted,
|
events.accounts.onDeleted,
|
||||||
this.handleTrackDeletedAccountEvent
|
this.handleTrackDeletedAccountEvent
|
||||||
);
|
);
|
||||||
|
bus.subscribe(events.accounts.onViewed, this.handleTrackAccountViewedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleTrackAccountCreatedEvent = ({
|
private handleTrackAccountCreatedEvent = ({
|
||||||
@@ -62,4 +64,12 @@ export class AccountEventsTracker extends EventSubscriber {
|
|||||||
properties: {},
|
properties: {},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private handleTrackAccountViewedEvent = ({ tenantId }) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: ACCOUNT_VIEWED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
ITEM_EVENT_CREATED,
|
ITEM_EVENT_CREATED,
|
||||||
ITEM_EVENT_EDITED,
|
ITEM_EVENT_EDITED,
|
||||||
ITEM_EVENT_DELETED,
|
ITEM_EVENT_DELETED,
|
||||||
|
ITEM_EVENT_VIEWED,
|
||||||
} from '@/constants/event-tracker';
|
} from '@/constants/event-tracker';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
@@ -25,6 +26,7 @@ export class ItemEventsTracker extends EventSubscriber {
|
|||||||
bus.subscribe(events.item.onCreated, this.handleTrackItemCreatedEvent);
|
bus.subscribe(events.item.onCreated, this.handleTrackItemCreatedEvent);
|
||||||
bus.subscribe(events.item.onEdited, this.handleTrackEditedItemEvent);
|
bus.subscribe(events.item.onEdited, this.handleTrackEditedItemEvent);
|
||||||
bus.subscribe(events.item.onDeleted, this.handleTrackDeletedItemEvent);
|
bus.subscribe(events.item.onDeleted, this.handleTrackDeletedItemEvent);
|
||||||
|
bus.subscribe(events.item.onViewed, this.handleTrackViewedItemEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleTrackItemCreatedEvent = ({
|
private handleTrackItemCreatedEvent = ({
|
||||||
@@ -56,4 +58,14 @@ export class ItemEventsTracker extends EventSubscriber {
|
|||||||
properties: {},
|
properties: {},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private handleTrackViewedItemEvent = ({
|
||||||
|
tenantId,
|
||||||
|
}: IItemEventDeletedPayload) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: ITEM_EVENT_VIEWED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
SALE_INVOICE_CREATED,
|
SALE_INVOICE_CREATED,
|
||||||
SALE_INVOICE_DELETED,
|
SALE_INVOICE_DELETED,
|
||||||
SALE_INVOICE_EDITED,
|
SALE_INVOICE_EDITED,
|
||||||
|
SALE_INVOICE_VIEWED,
|
||||||
} from '@/constants/event-tracker';
|
} from '@/constants/event-tracker';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
@@ -33,6 +34,10 @@ export class SaleInvoiceEventsTracker extends EventSubscriber {
|
|||||||
events.saleInvoice.onDeleted,
|
events.saleInvoice.onDeleted,
|
||||||
this.handleTrackDeletedInvoiceEvent
|
this.handleTrackDeletedInvoiceEvent
|
||||||
);
|
);
|
||||||
|
bus.subscribe(
|
||||||
|
events.saleInvoice.onViewed,
|
||||||
|
this.handleTrackViewedInvoiceEvent
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleTrackInvoiceCreatedEvent = ({
|
private handleTrackInvoiceCreatedEvent = ({
|
||||||
@@ -64,4 +69,12 @@ export class SaleInvoiceEventsTracker extends EventSubscriber {
|
|||||||
properties: {},
|
properties: {},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private handleTrackViewedInvoiceEvent = ({ tenantId }) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: SALE_INVOICE_VIEWED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { IItem } from '@/interfaces';
|
|||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||||
import ItemTransformer from './ItemTransformer';
|
import ItemTransformer from './ItemTransformer';
|
||||||
|
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||||
|
import events from '@/subscribers/events';
|
||||||
|
|
||||||
@Inject()
|
@Inject()
|
||||||
export class GetItem {
|
export class GetItem {
|
||||||
@@ -12,6 +14,9 @@ export class GetItem {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private transformer: TransformerInjectable;
|
private transformer: TransformerInjectable;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private eventPublisher: EventPublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the item details of the given id with associated details.
|
* Retrieve the item details of the given id with associated details.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
@@ -31,6 +36,16 @@ export class GetItem {
|
|||||||
.withGraphFetched('purchaseTaxRate')
|
.withGraphFetched('purchaseTaxRate')
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
return this.transformer.transform(tenantId, item, new ItemTransformer());
|
const transformed = await this.transformer.transform(
|
||||||
|
tenantId,
|
||||||
|
item,
|
||||||
|
new ItemTransformer()
|
||||||
|
);
|
||||||
|
const eventPayload = { tenantId, itemId };
|
||||||
|
|
||||||
|
// Triggers the `onItemViewed` event.
|
||||||
|
await this.eventPublisher.emitAsync(events.item.onViewed, eventPayload);
|
||||||
|
|
||||||
|
return transformed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { initalizeTenantServices } from '@/api/middleware/TenantDependencyInjection';
|
||||||
|
import { SaleInvoicePdf } from '../Sales/Invoices/SaleInvoicePdf';
|
||||||
|
import { PaymentLink } from '@/system/models';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export class GetPaymentLinkInvoicePdf {
|
||||||
|
@Inject()
|
||||||
|
private getSaleInvoicePdfService: SaleInvoicePdf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the sale invoice PDF of the given payment link id.
|
||||||
|
* @param {number} tenantId
|
||||||
|
* @param {number} paymentLinkId
|
||||||
|
* @returns {Promise<Buffer>}
|
||||||
|
*/
|
||||||
|
async getPaymentLinkInvoicePdf(paymentLinkId: string): Promise<Buffer> {
|
||||||
|
const paymentLink = await PaymentLink.query()
|
||||||
|
.findOne('linkId', paymentLinkId)
|
||||||
|
.where('resourceType', 'SaleInvoice')
|
||||||
|
.throwIfNotFound();
|
||||||
|
|
||||||
|
const tenantId = paymentLink.tenantId;
|
||||||
|
await initalizeTenantServices(tenantId);
|
||||||
|
|
||||||
|
const saleInvoiceId = paymentLink.resourceId;
|
||||||
|
|
||||||
|
return this.getSaleInvoicePdfService.saleInvoicePdf(
|
||||||
|
tenantId,
|
||||||
|
saleInvoiceId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
|
|||||||
import { GetInvoicePaymentLinkMetadata } from './GetInvoicePaymentLinkMetadata';
|
import { GetInvoicePaymentLinkMetadata } from './GetInvoicePaymentLinkMetadata';
|
||||||
import { CreateInvoiceCheckoutSession } from './CreateInvoiceCheckoutSession';
|
import { CreateInvoiceCheckoutSession } from './CreateInvoiceCheckoutSession';
|
||||||
import { StripeInvoiceCheckoutSessionPOJO } from '@/interfaces/StripePayment';
|
import { StripeInvoiceCheckoutSessionPOJO } from '@/interfaces/StripePayment';
|
||||||
|
import { GetPaymentLinkInvoicePdf } from './GetPaymentLinkInvoicePdf';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class PaymentLinksApplication {
|
export class PaymentLinksApplication {
|
||||||
@@ -11,6 +12,9 @@ export class PaymentLinksApplication {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private createInvoiceCheckoutSessionService: CreateInvoiceCheckoutSession;
|
private createInvoiceCheckoutSessionService: CreateInvoiceCheckoutSession;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private getPaymentLinkInvoicePdfService: GetPaymentLinkInvoicePdf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the invoice payment link.
|
* Retrieves the invoice payment link.
|
||||||
* @param {string} paymentLinkId
|
* @param {string} paymentLinkId
|
||||||
@@ -34,4 +38,16 @@ export class PaymentLinksApplication {
|
|||||||
paymentLinkId
|
paymentLinkId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the sale invoice pdf of the given payment link id.
|
||||||
|
* @param {number} tenantId
|
||||||
|
* @param {number} paymentLinkId
|
||||||
|
* @returns {Promise<Buffer> }
|
||||||
|
*/
|
||||||
|
public getPaymentLinkInvoicePdf(paymentLinkId: string): Promise<Buffer> {
|
||||||
|
return this.getPaymentLinkInvoicePdfService.getPaymentLinkInvoicePdf(
|
||||||
|
paymentLinkId
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import * as R from 'ramda';
|
|
||||||
import HasTenancyService from '../Tenancy/TenancyService';
|
|
||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
import { isEmpty } from 'lodash';
|
import { isNil } from 'lodash';
|
||||||
|
import HasTenancyService from '../Tenancy/TenancyService';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class BrandingTemplateDTOTransformer {
|
export class BrandingTemplateDTOTransformer {
|
||||||
@@ -22,11 +21,12 @@ export class BrandingTemplateDTOTransformer {
|
|||||||
const { PdfTemplate } = this.tenancy.models(tenantId);
|
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||||
const attributeName = 'pdfTemplateId';
|
const attributeName = 'pdfTemplateId';
|
||||||
|
|
||||||
const defaultTemplate = await PdfTemplate.query().findOne({
|
const defaultTemplate = await PdfTemplate.query()
|
||||||
resource,
|
.modify('default')
|
||||||
default: true,
|
.findOne({ resource });
|
||||||
});
|
|
||||||
if (!defaultTemplate || !isEmpty(object[attributeName])) {
|
// If the default template is not found OR the given object has no defined template id.
|
||||||
|
if (!defaultTemplate || !isNil(object[attributeName])) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { ISaleEstimateState } from '@/interfaces';
|
||||||
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export class GetSaleEstimateState {
|
||||||
|
@Inject()
|
||||||
|
private tenancy: HasTenancyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the create/edit sale estimate state.
|
||||||
|
* @param {Number} saleEstimateId -
|
||||||
|
* @return {Promise<ISaleEstimateState>}
|
||||||
|
*/
|
||||||
|
public async getSaleEstimateState(
|
||||||
|
tenantId: number
|
||||||
|
): Promise<ISaleEstimateState> {
|
||||||
|
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
|
const defaultPdfTemplate = await PdfTemplate.query()
|
||||||
|
.findOne({ resource: 'SaleEstimate' })
|
||||||
|
.modify('default');
|
||||||
|
|
||||||
|
return {
|
||||||
|
defaultTemplateId: defaultPdfTemplate?.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import { RejectSaleEstimate } from './RejectSaleEstimate';
|
|||||||
import { SaleEstimateNotifyBySms } from './SaleEstimateSmsNotify';
|
import { SaleEstimateNotifyBySms } from './SaleEstimateSmsNotify';
|
||||||
import { SaleEstimatesPdf } from './SaleEstimatesPdf';
|
import { SaleEstimatesPdf } from './SaleEstimatesPdf';
|
||||||
import { SendSaleEstimateMail } from './SendSaleEstimateMail';
|
import { SendSaleEstimateMail } from './SendSaleEstimateMail';
|
||||||
|
import { GetSaleEstimateState } from './GetSaleEstimateState';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class SaleEstimatesApplication {
|
export class SaleEstimatesApplication {
|
||||||
@@ -56,6 +57,9 @@ export class SaleEstimatesApplication {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private sendEstimateMailService: SendSaleEstimateMail;
|
private sendEstimateMailService: SendSaleEstimateMail;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private getSaleEstimateStateService: GetSaleEstimateState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a sale estimate.
|
* Create a sale estimate.
|
||||||
* @param {number} tenantId - The tenant id.
|
* @param {number} tenantId - The tenant id.
|
||||||
@@ -249,4 +253,13 @@ export class SaleEstimatesApplication {
|
|||||||
saleEstimateId
|
saleEstimateId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the current state of the sale estimate.
|
||||||
|
* @param {number} tenantId - The ID of the tenant.
|
||||||
|
* @returns {Promise<ISaleEstimateState>} - A promise resolving to the sale estimate state.
|
||||||
|
*/
|
||||||
|
public getSaleEstimateState(tenantId: number) {
|
||||||
|
return this.getSaleEstimateStateService.getSaleEstimateState(tenantId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,12 +104,24 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected formattedCustomerAddress(invoice) {
|
get customerAddressFormat() {
|
||||||
return contactAddressTextFormat(invoice.customer, `{ADDRESS_1}
|
return `{ADDRESS_1}
|
||||||
{ADDRESS_2}
|
{ADDRESS_2}
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
{CITY} {STATE} {POSTAL_CODE}
|
||||||
{COUNTRY}
|
{COUNTRY}
|
||||||
{PHONE}`);
|
{PHONE}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the formatted customer address.
|
||||||
|
* @param invoice
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
protected formattedCustomerAddress(invoice) {
|
||||||
|
return contactAddressTextFormat(
|
||||||
|
invoice.customer,
|
||||||
|
this.customerAddressFormat
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { SaleInvoiceTransformer } from './SaleInvoiceTransformer';
|
|||||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
import { CommandSaleInvoiceValidators } from './CommandSaleInvoiceValidators';
|
import { CommandSaleInvoiceValidators } from './CommandSaleInvoiceValidators';
|
||||||
|
import events from '@/subscribers/events';
|
||||||
|
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class GetSaleInvoice {
|
export class GetSaleInvoice {
|
||||||
@@ -16,6 +18,9 @@ export class GetSaleInvoice {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private validators: CommandSaleInvoiceValidators;
|
private validators: CommandSaleInvoiceValidators;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private eventPublisher: EventPublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve sale invoice with associated entries.
|
* Retrieve sale invoice with associated entries.
|
||||||
* @param {Number} saleInvoiceId -
|
* @param {Number} saleInvoiceId -
|
||||||
@@ -41,10 +46,20 @@ export class GetSaleInvoice {
|
|||||||
// Validates the given sale invoice existance.
|
// Validates the given sale invoice existance.
|
||||||
this.validators.validateInvoiceExistance(saleInvoice);
|
this.validators.validateInvoiceExistance(saleInvoice);
|
||||||
|
|
||||||
return this.transformer.transform(
|
const transformed = await this.transformer.transform(
|
||||||
tenantId,
|
tenantId,
|
||||||
saleInvoice,
|
saleInvoice,
|
||||||
new SaleInvoiceTransformer()
|
new SaleInvoiceTransformer()
|
||||||
);
|
);
|
||||||
|
const eventPayload = {
|
||||||
|
tenantId,
|
||||||
|
saleInvoiceId,
|
||||||
|
};
|
||||||
|
// Triggers the `onSaleInvoiceItemViewed` event.
|
||||||
|
await this.eventPublisher.emitAsync(
|
||||||
|
events.saleInvoice.onViewed,
|
||||||
|
eventPayload
|
||||||
|
);
|
||||||
|
return transformed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { ISaleInvocieState } from '@/interfaces';
|
||||||
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export class GetSaleInvoiceState {
|
||||||
|
@Inject()
|
||||||
|
private tenancy: HasTenancyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the create/edit invoice state.
|
||||||
|
* @param {Number} saleInvoiceId -
|
||||||
|
* @return {Promise<ISaleInvoice>}
|
||||||
|
*/
|
||||||
|
public async getSaleInvoiceState(
|
||||||
|
tenantId: number
|
||||||
|
): Promise<ISaleInvocieState> {
|
||||||
|
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
|
const defaultPdfTemplate = await PdfTemplate.query()
|
||||||
|
.findOne({ resource: 'SaleInvoice' })
|
||||||
|
.modify('default');
|
||||||
|
|
||||||
|
return {
|
||||||
|
defaultTemplateId: defaultPdfTemplate?.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ import { SaleInvoiceNotifyBySms } from './SaleInvoiceNotifyBySms';
|
|||||||
import { SendInvoiceMailReminder } from './SendSaleInvoiceMailReminder';
|
import { SendInvoiceMailReminder } from './SendSaleInvoiceMailReminder';
|
||||||
import { SendSaleInvoiceMail } from './SendSaleInvoiceMail';
|
import { SendSaleInvoiceMail } from './SendSaleInvoiceMail';
|
||||||
import { GetSaleInvoiceMailReminder } from './GetSaleInvoiceMailReminder';
|
import { GetSaleInvoiceMailReminder } from './GetSaleInvoiceMailReminder';
|
||||||
|
import { GetSaleInvoiceState } from './GetSaleInvoiceState';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class SaleInvoiceApplication {
|
export class SaleInvoiceApplication {
|
||||||
@@ -73,6 +74,9 @@ export class SaleInvoiceApplication {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private getSaleInvoiceReminderService: GetSaleInvoiceMailReminder;
|
private getSaleInvoiceReminderService: GetSaleInvoiceMailReminder;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private getSaleInvoiceStateService: GetSaleInvoiceState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new sale invoice with associated GL entries.
|
* Creates a new sale invoice with associated GL entries.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
@@ -169,6 +173,16 @@ export class SaleInvoiceApplication {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the sale invoice state.
|
||||||
|
* @param {number} tenantId
|
||||||
|
* @param {number} saleInvoiceId
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public getSaleInvoiceState(tenantId: number) {
|
||||||
|
return this.getSaleInvoiceStateService.getSaleInvoiceState(tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark the given sale invoice as delivered.
|
* Mark the given sale invoice as delivered.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { IPaymentReceivedState } from '@/interfaces';
|
||||||
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export class GetPaymentReceivedState {
|
||||||
|
@Inject()
|
||||||
|
private tenancy: HasTenancyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the create/edit initial state of the payment received.
|
||||||
|
* @param {number} tenantId - The ID of the tenant.
|
||||||
|
* @returns {Promise<IPaymentReceivedState>} - A promise resolving to the payment received state.
|
||||||
|
*/
|
||||||
|
public async getPaymentReceivedState(
|
||||||
|
tenantId: number
|
||||||
|
): Promise<IPaymentReceivedState> {
|
||||||
|
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
|
const defaultPdfTemplate = await PdfTemplate.query()
|
||||||
|
.findOne({ resource: 'PaymentReceive' })
|
||||||
|
.modify('default');
|
||||||
|
|
||||||
|
return {
|
||||||
|
defaultTemplateId: defaultPdfTemplate?.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ import { GetPaymentReceivedInvoices } from './GetPaymentReceivedInvoices';
|
|||||||
import { PaymentReceiveNotifyBySms } from './PaymentReceivedSmsNotify';
|
import { PaymentReceiveNotifyBySms } from './PaymentReceivedSmsNotify';
|
||||||
import GetPaymentReceivedPdf from './GetPaymentReceivedPdf';
|
import GetPaymentReceivedPdf from './GetPaymentReceivedPdf';
|
||||||
import { SendPaymentReceiveMailNotification } from './PaymentReceivedMailNotification';
|
import { SendPaymentReceiveMailNotification } from './PaymentReceivedMailNotification';
|
||||||
|
import { GetPaymentReceivedState } from './GetPaymentReceivedState';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class PaymentReceivesApplication {
|
export class PaymentReceivesApplication {
|
||||||
@@ -49,6 +50,9 @@ export class PaymentReceivesApplication {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private getPaymentReceivePdfService: GetPaymentReceivedPdf;
|
private getPaymentReceivePdfService: GetPaymentReceivedPdf;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private getPaymentReceivedStateService: GetPaymentReceivedState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new payment receive.
|
* Creates a new payment receive.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
@@ -223,4 +227,15 @@ export class PaymentReceivesApplication {
|
|||||||
paymentReceiveId
|
paymentReceiveId
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the create/edit initial state of the payment received.
|
||||||
|
* @param {number} tenantId - The ID of the tenant.
|
||||||
|
* @returns {Promise<IPaymentReceivedState>}
|
||||||
|
*/
|
||||||
|
public getPaymentReceivedState = (tenantId: number) => {
|
||||||
|
return this.getPaymentReceivedStateService.getPaymentReceivedState(
|
||||||
|
tenantId
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { ISaleReceiptState } from '@/interfaces';
|
||||||
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export class GetSaleReceiptState {
|
||||||
|
@Inject()
|
||||||
|
private tenancy: HasTenancyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retireves the sale receipt state.
|
||||||
|
* @param {Number} tenantId -
|
||||||
|
* @return {Promise<ISaleReceiptState>}
|
||||||
|
*/
|
||||||
|
public async getSaleReceiptState(
|
||||||
|
tenantId: number
|
||||||
|
): Promise<ISaleReceiptState> {
|
||||||
|
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
|
const defaultPdfTemplate = await PdfTemplate.query()
|
||||||
|
.findOne({ resource: 'SaleReceipt' })
|
||||||
|
.modify('default');
|
||||||
|
|
||||||
|
return {
|
||||||
|
defaultTemplateId: defaultPdfTemplate?.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
IFilterMeta,
|
IFilterMeta,
|
||||||
IPaginationMeta,
|
IPaginationMeta,
|
||||||
ISaleReceipt,
|
ISaleReceipt,
|
||||||
|
ISaleReceiptState,
|
||||||
ISalesReceiptsFilter,
|
ISalesReceiptsFilter,
|
||||||
SaleReceiptMailOpts,
|
SaleReceiptMailOpts,
|
||||||
SaleReceiptMailOptsDTO,
|
SaleReceiptMailOptsDTO,
|
||||||
@@ -16,6 +17,7 @@ import { CloseSaleReceipt } from './CloseSaleReceipt';
|
|||||||
import { SaleReceiptsPdf } from './SaleReceiptsPdfService';
|
import { SaleReceiptsPdf } from './SaleReceiptsPdfService';
|
||||||
import { SaleReceiptNotifyBySms } from './SaleReceiptNotifyBySms';
|
import { SaleReceiptNotifyBySms } from './SaleReceiptNotifyBySms';
|
||||||
import { SaleReceiptMailNotification } from './SaleReceiptMailNotification';
|
import { SaleReceiptMailNotification } from './SaleReceiptMailNotification';
|
||||||
|
import { GetSaleReceiptState } from './GetSaleReceiptState';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class SaleReceiptApplication {
|
export class SaleReceiptApplication {
|
||||||
@@ -46,6 +48,9 @@ export class SaleReceiptApplication {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private saleReceiptNotifyByMailService: SaleReceiptMailNotification;
|
private saleReceiptNotifyByMailService: SaleReceiptMailNotification;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private getSaleReceiptStateService: GetSaleReceiptState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new sale receipt with associated entries.
|
* Creates a new sale receipt with associated entries.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
@@ -207,4 +212,13 @@ export class SaleReceiptApplication {
|
|||||||
saleReceiptId
|
saleReceiptId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the current state of the sale receipt.
|
||||||
|
* @param {number} tenantId - The ID of the tenant.
|
||||||
|
* @returns {Promise<ISaleReceiptState>} - A promise resolving to the sale receipt state.
|
||||||
|
*/
|
||||||
|
public getSaleReceiptState(tenantId: number): Promise<ISaleReceiptState> {
|
||||||
|
return this.getSaleReceiptStateService.getSaleReceiptState(tenantId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ export default {
|
|||||||
* Accounts service.
|
* Accounts service.
|
||||||
*/
|
*/
|
||||||
accounts: {
|
accounts: {
|
||||||
|
onViewed: 'onAccountViewed',
|
||||||
|
onListViewed: 'onAccountsListViewed',
|
||||||
|
|
||||||
onCreating: 'onAccountCreating',
|
onCreating: 'onAccountCreating',
|
||||||
onCreated: 'onAccountCreated',
|
onCreated: 'onAccountCreated',
|
||||||
|
|
||||||
@@ -127,6 +130,9 @@ export default {
|
|||||||
* Sales invoices service.
|
* Sales invoices service.
|
||||||
*/
|
*/
|
||||||
saleInvoice: {
|
saleInvoice: {
|
||||||
|
onViewed: 'onSaleInvoiceItemViewed',
|
||||||
|
onListViewed: 'onSaleInvoiceListViewed',
|
||||||
|
|
||||||
onCreate: 'onSaleInvoiceCreate',
|
onCreate: 'onSaleInvoiceCreate',
|
||||||
onCreating: 'onSaleInvoiceCreating',
|
onCreating: 'onSaleInvoiceCreating',
|
||||||
onCreated: 'onSaleInvoiceCreated',
|
onCreated: 'onSaleInvoiceCreated',
|
||||||
@@ -338,6 +344,8 @@ export default {
|
|||||||
* Items service.
|
* Items service.
|
||||||
*/
|
*/
|
||||||
item: {
|
item: {
|
||||||
|
onViewed: 'onItemViewed',
|
||||||
|
|
||||||
onCreated: 'onItemCreated',
|
onCreated: 'onItemCreated',
|
||||||
onCreating: 'onItemCreating',
|
onCreating: 'onItemCreating',
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { organizationAddressTextFormat } from '@/utils/address-text-format';
|
import {
|
||||||
|
defaultOrganizationAddressFormat,
|
||||||
|
organizationAddressTextFormat,
|
||||||
|
} from '@/utils/address-text-format';
|
||||||
import BaseModel from 'models/Model';
|
import BaseModel from 'models/Model';
|
||||||
|
import { findByIsoCountryCode } from '@bigcapital/utils';
|
||||||
import { getUploadedObjectUri } from '../../services/Attachments/utils';
|
import { getUploadedObjectUri } from '../../services/Attachments/utils';
|
||||||
|
|
||||||
export default class TenantMetadata extends BaseModel {
|
export default class TenantMetadata extends BaseModel {
|
||||||
@@ -67,14 +71,9 @@ export default class TenantMetadata extends BaseModel {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
public get addressTextFormatted() {
|
public get addressTextFormatted() {
|
||||||
const defaultMessage = `<strong>{ORGANIZATION_NAME}</strong>
|
const addressCountry = findByIsoCountryCode(this.location);
|
||||||
{ADDRESS_1}
|
|
||||||
{ADDRESS_2}
|
return organizationAddressTextFormat(defaultOrganizationAddressFormat, {
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
|
||||||
{COUNTRY}
|
|
||||||
{PHONE}
|
|
||||||
`;
|
|
||||||
return organizationAddressTextFormat(defaultMessage, {
|
|
||||||
organizationName: this.name,
|
organizationName: this.name,
|
||||||
address1: this.address?.address1,
|
address1: this.address?.address1,
|
||||||
address2: this.address?.address2,
|
address2: this.address?.address2,
|
||||||
@@ -82,7 +81,7 @@ export default class TenantMetadata extends BaseModel {
|
|||||||
city: this.address?.city,
|
city: this.address?.city,
|
||||||
postalCode: this.address?.postalCode,
|
postalCode: this.address?.postalCode,
|
||||||
phone: this.address?.phone,
|
phone: this.address?.phone,
|
||||||
country: 'United State',
|
country: addressCountry?.name ?? '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ interface OrganizationAddressFormatArgs {
|
|||||||
phone?: string;
|
phone?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultMessage = `
|
export const defaultOrganizationAddressFormat = `
|
||||||
<strong>{ORGANIZATION_NAME}</strong>
|
<strong>{ORGANIZATION_NAME}</strong>
|
||||||
{ADDRESS_1}
|
{ADDRESS_1}
|
||||||
{ADDRESS_2}
|
{ADDRESS_2}
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
{CITY} {STATE} {POSTAL_CODE}
|
||||||
{COUNTRY}
|
{COUNTRY}
|
||||||
{PHONE}
|
{PHONE}
|
||||||
`;
|
`;
|
||||||
@@ -36,7 +36,9 @@ const formatText = (message: string, replacements: Record<string, string>) => {
|
|||||||
},
|
},
|
||||||
message
|
message
|
||||||
);
|
);
|
||||||
formattedMessage = formattedMessage.replace(/\n{2,}/g, '\n').trim();
|
// Removes any empty lines.
|
||||||
|
formattedMessage = formattedMessage.replace(/^\s*[\r\n]/gm, '');
|
||||||
|
formattedMessage = formattedMessage.replace(/\n{2,}/g, '\n');
|
||||||
formattedMessage = formattedMessage.replace(/\n/g, '<br />');
|
formattedMessage = formattedMessage.replace(/\n/g, '<br />');
|
||||||
formattedMessage = formattedMessage.trim();
|
formattedMessage = formattedMessage.trim();
|
||||||
|
|
||||||
@@ -72,17 +74,17 @@ interface ContactAddressTextFormatArgs {
|
|||||||
phone?: string;
|
phone?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contactFormatMessage = `{CONTACT_NAME}
|
export const defaultContactAddressFormat = `{CONTACT_NAME}
|
||||||
{ADDRESS_1}
|
{ADDRESS_1}
|
||||||
{ADDRESS_2}
|
{ADDRESS_2}
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
{CITY} {STATE} {POSTAL_CODE}
|
||||||
{COUNTRY}
|
{COUNTRY}
|
||||||
{PHONE}
|
{PHONE}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const contactAddressTextFormat = (
|
export const contactAddressTextFormat = (
|
||||||
contact: IContact,
|
contact: IContact,
|
||||||
message: string = contactFormatMessage
|
message: string = defaultContactAddressFormat
|
||||||
) => {
|
) => {
|
||||||
const args = {
|
const args = {
|
||||||
displayName: contact.displayName,
|
displayName: contact.displayName,
|
||||||
|
|||||||
@@ -5,11 +5,7 @@ USER root
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy application dependency manifests to the container image.
|
# Copy application dependency manifests to the container image.
|
||||||
COPY ./package*.json ./
|
COPY . .
|
||||||
COPY ./pnpm-lock.yaml ./pnpm-lock.yaml
|
|
||||||
COPY ./lerna.json ./lerna.json
|
|
||||||
COPY ./pnpm-workspace.yaml ./pnpm-workspace.yaml
|
|
||||||
COPY ./packages/webapp/package*.json ./packages/webapp/
|
|
||||||
|
|
||||||
# Install application dependencies
|
# Install application dependencies
|
||||||
RUN apk update
|
RUN apk update
|
||||||
@@ -23,7 +19,6 @@ RUN npm install -g pnpm
|
|||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
|
|
||||||
# Build webapp package
|
# Build webapp package
|
||||||
COPY ./packages/webapp /app/packages/webapp
|
|
||||||
RUN pnpm run build:webapp
|
RUN pnpm run build:webapp
|
||||||
|
|
||||||
FROM nginx
|
FROM nginx
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"version": "0.10.2",
|
"version": "0.10.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@bigcapital/utils": "*",
|
||||||
"@blueprintjs-formik/core": "^0.3.6",
|
"@blueprintjs-formik/core": "^0.3.6",
|
||||||
"@blueprintjs-formik/datetime": "^0.3.7",
|
"@blueprintjs-formik/datetime": "^0.3.7",
|
||||||
"@blueprintjs-formik/select": "^0.3.5",
|
"@blueprintjs-formik/select": "^0.3.5",
|
||||||
@@ -16,6 +17,8 @@
|
|||||||
"@casl/ability": "^5.4.3",
|
"@casl/ability": "^5.4.3",
|
||||||
"@casl/react": "^2.3.0",
|
"@casl/react": "^2.3.0",
|
||||||
"@craco/craco": "^5.9.0",
|
"@craco/craco": "^5.9.0",
|
||||||
|
"@emotion/css": "^11.13.4",
|
||||||
|
"@emotion/react": "^11.13.3",
|
||||||
"@reduxjs/toolkit": "^1.2.5",
|
"@reduxjs/toolkit": "^1.2.5",
|
||||||
"@stripe/connect-js": "^3.3.12",
|
"@stripe/connect-js": "^3.3.12",
|
||||||
"@stripe/react-connect-js": "^3.3.13",
|
"@stripe/react-connect-js": "^3.3.13",
|
||||||
@@ -37,6 +40,7 @@
|
|||||||
"@types/react": "^16.14.28",
|
"@types/react": "^16.14.28",
|
||||||
"@types/react-body-classname": "^1.1.7",
|
"@types/react-body-classname": "^1.1.7",
|
||||||
"@types/react-dom": "^16.9.16",
|
"@types/react-dom": "^16.9.16",
|
||||||
|
"@types/react-helmet": "^6.1.11",
|
||||||
"@types/react-redux": "^7.1.24",
|
"@types/react-redux": "^7.1.24",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"@types/react-transition-group": "^4.4.5",
|
"@types/react-transition-group": "^4.4.5",
|
||||||
@@ -46,6 +50,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^2.10.0",
|
"@typescript-eslint/eslint-plugin": "^2.10.0",
|
||||||
"@typescript-eslint/parser": "^2.10.0",
|
"@typescript-eslint/parser": "^2.10.0",
|
||||||
"@welldone-software/why-did-you-render": "^6.0.0-rc.1",
|
"@welldone-software/why-did-you-render": "^6.0.0-rc.1",
|
||||||
|
"@xstyled/emotion": "^3.8.1",
|
||||||
"accounting": "^0.4.1",
|
"accounting": "^0.4.1",
|
||||||
"axios": "^1.6.0",
|
"axios": "^1.6.0",
|
||||||
"basscss": "^8.0.2",
|
"basscss": "^8.0.2",
|
||||||
@@ -59,6 +64,7 @@
|
|||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
"flat": "^5.0.2",
|
"flat": "^5.0.2",
|
||||||
"formik": "^2.2.5",
|
"formik": "^2.2.5",
|
||||||
|
"helmet": "^3.21.0",
|
||||||
"history": "4.10.1",
|
"history": "4.10.1",
|
||||||
"http-proxy-middleware": "^1.0.0",
|
"http-proxy-middleware": "^1.0.0",
|
||||||
"jest": "24.9.0",
|
"jest": "24.9.0",
|
||||||
@@ -87,6 +93,7 @@
|
|||||||
"react-dropzone-esm": "^15.0.1",
|
"react-dropzone-esm": "^15.0.1",
|
||||||
"react-error-boundary": "^3.0.2",
|
"react-error-boundary": "^3.0.2",
|
||||||
"react-error-overlay": "^6.0.9",
|
"react-error-overlay": "^6.0.9",
|
||||||
|
"react-helmet": "^6.1.0",
|
||||||
"react-hotkeys-hook": "^3.0.3",
|
"react-hotkeys-hook": "^3.0.3",
|
||||||
"react-intl-universal": "^2.4.7",
|
"react-intl-universal": "^2.4.7",
|
||||||
"react-loadable": "^5.5.0",
|
"react-loadable": "^5.5.0",
|
||||||
@@ -120,6 +127,7 @@
|
|||||||
"style-loader": "0.23.1",
|
"style-loader": "0.23.1",
|
||||||
"styled-components": "^5.3.1",
|
"styled-components": "^5.3.1",
|
||||||
"stylis-rtlcss": "^2.1.1",
|
"stylis-rtlcss": "^2.1.1",
|
||||||
|
"theme-ui": "^0.16.2",
|
||||||
"typescript": "^4.8.3",
|
"typescript": "^4.8.3",
|
||||||
"yup": "^0.28.1"
|
"yup": "^0.28.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const OneClickDemoPage = lazy(
|
|||||||
const PaymentPortalPage = lazy(
|
const PaymentPortalPage = lazy(
|
||||||
() => import('@/containers/PaymentPortal/PaymentPortalPage'),
|
() => import('@/containers/PaymentPortal/PaymentPortalPage'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App inner.
|
* App inner.
|
||||||
*/
|
*/
|
||||||
@@ -59,7 +60,10 @@ function AppInsider({ history }) {
|
|||||||
children={<EmailConfirmation />}
|
children={<EmailConfirmation />}
|
||||||
/>
|
/>
|
||||||
<Route path={'/auth'} children={<AuthenticationPage />} />
|
<Route path={'/auth'} children={<AuthenticationPage />} />
|
||||||
<Route path={'/payment/:linkId'} children={<PaymentPortalPage />} />
|
<Route
|
||||||
|
path={'/payment/:linkId'}
|
||||||
|
children={<PaymentPortalPage />}
|
||||||
|
/>
|
||||||
<Route path={'/'} children={<DashboardPrivatePages />} />
|
<Route path={'/'} children={<DashboardPrivatePages />} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</Router>
|
</Router>
|
||||||
|
|||||||
@@ -1,12 +1,31 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React, { createContext } from 'react';
|
import React, { createContext } from 'react';
|
||||||
|
|
||||||
const AppIntlContext = createContext();
|
interface AppIntlContextValue {
|
||||||
|
currentLocale: string;
|
||||||
|
direction: 'rtl' | 'ltr';
|
||||||
|
isRTL: boolean;
|
||||||
|
isLTR: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppIntlContext = createContext<AppIntlContextValue>(
|
||||||
|
{} as AppIntlContextValue,
|
||||||
|
);
|
||||||
|
|
||||||
|
interface AppIntlProviderProps {
|
||||||
|
currentLocale: string;
|
||||||
|
isRTL: boolean;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application intl provider.
|
* Application intl provider.
|
||||||
*/
|
*/
|
||||||
function AppIntlProvider({ currentLocale, isRTL, children }) {
|
function AppIntlProvider({
|
||||||
|
currentLocale,
|
||||||
|
isRTL,
|
||||||
|
children,
|
||||||
|
}: AppIntlProviderProps) {
|
||||||
const provider = {
|
const provider = {
|
||||||
currentLocale,
|
currentLocale,
|
||||||
isRTL,
|
isRTL,
|
||||||
@@ -21,6 +40,7 @@ function AppIntlProvider({ currentLocale, isRTL, children }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const useAppIntlContext = () => React.useContext(AppIntlContext);
|
const useAppIntlContext = () =>
|
||||||
|
React.useContext<AppIntlContextValue>(AppIntlContext);
|
||||||
|
|
||||||
export { AppIntlProvider, useAppIntlContext };
|
export { AppIntlProvider, useAppIntlContext };
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { LoadingIndicator } from '../Indicator';
|
import { LoadingIndicator } from '../Indicator';
|
||||||
|
import { css } from '@emotion/css';
|
||||||
|
|
||||||
export function DashboardInsider({
|
export function DashboardInsider({
|
||||||
loading,
|
loading,
|
||||||
@@ -9,6 +10,7 @@ export function DashboardInsider({
|
|||||||
name,
|
name,
|
||||||
mount = false,
|
mount = false,
|
||||||
className,
|
className,
|
||||||
|
style
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -17,9 +19,11 @@ export function DashboardInsider({
|
|||||||
dashboard__insider: true,
|
dashboard__insider: true,
|
||||||
'dashboard__insider--loading': loading,
|
'dashboard__insider--loading': loading,
|
||||||
[`dashboard__insider--${name}`]: !!name,
|
[`dashboard__insider--${name}`]: !!name,
|
||||||
|
|
||||||
},
|
},
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
style={style}
|
||||||
>
|
>
|
||||||
<LoadingIndicator loading={loading} mount={mount}>
|
<LoadingIndicator loading={loading} mount={mount}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
// @ts-nocheck
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ThemeProvider, StyleSheetManager } from 'styled-components';
|
import {
|
||||||
|
ThemeProvider as StyleComponentsThemeProvider,
|
||||||
|
StyleSheetManager,
|
||||||
|
} from 'styled-components';
|
||||||
import rtlcss from 'stylis-rtlcss';
|
import rtlcss from 'stylis-rtlcss';
|
||||||
|
import {
|
||||||
|
defaultTheme,
|
||||||
|
ThemeProvider as XStyledEmotionThemeProvider,
|
||||||
|
} from '@xstyled/emotion';
|
||||||
import { useAppIntlContext } from '../AppIntlProvider';
|
import { useAppIntlContext } from '../AppIntlProvider';
|
||||||
|
|
||||||
|
const theme = {
|
||||||
|
...defaultTheme,
|
||||||
|
bpPrefix: 'bp4',
|
||||||
|
};
|
||||||
|
|
||||||
interface DashboardThemeProviderProps {
|
interface DashboardThemeProviderProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
@@ -17,7 +28,11 @@ export function DashboardThemeProvider({
|
|||||||
<StyleSheetManager
|
<StyleSheetManager
|
||||||
{...(direction === 'rtl' ? { stylisPlugins: [rtlcss] } : {})}
|
{...(direction === 'rtl' ? { stylisPlugins: [rtlcss] } : {})}
|
||||||
>
|
>
|
||||||
<ThemeProvider theme={{ dir: direction }}>{children}</ThemeProvider>
|
<StyleComponentsThemeProvider theme={{ dir: direction }}>
|
||||||
|
<XStyledEmotionThemeProvider theme={theme}>
|
||||||
|
{children}
|
||||||
|
</XStyledEmotionThemeProvider>
|
||||||
|
</StyleComponentsThemeProvider>
|
||||||
</StyleSheetManager>
|
</StyleSheetManager>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import React, { forwardRef, Ref } from 'react';
|
import React, { forwardRef, Ref } from 'react';
|
||||||
import { HTMLDivProps, Props } from '@blueprintjs/core';
|
import { HTMLDivProps, Props } from '@blueprintjs/core';
|
||||||
|
import { SystemProps, x } from '@xstyled/emotion';
|
||||||
|
|
||||||
export interface BoxProps extends Props, HTMLDivProps {
|
export interface BoxProps
|
||||||
className?: string;
|
extends SystemProps,
|
||||||
}
|
Props,
|
||||||
|
Omit<HTMLDivProps, 'color'> {}
|
||||||
|
|
||||||
export const Box = forwardRef(
|
export const Box = forwardRef(
|
||||||
({ className, ...rest }: BoxProps, ref: Ref<HTMLDivElement>) => {
|
({ className, ...rest }: BoxProps, ref: Ref<HTMLDivElement>) => {
|
||||||
const Element = 'div';
|
const Element = x.div;
|
||||||
|
|
||||||
return <Element className={className} ref={ref} {...rest} />;
|
return <Element className={className} ref={ref} {...rest} />;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import { SystemProps } from '@xstyled/emotion';
|
||||||
import { Box } from '../Box';
|
import { Box } from '../Box';
|
||||||
import { filterFalsyChildren } from './_utils';
|
import { filterFalsyChildren } from './_utils';
|
||||||
|
|
||||||
@@ -12,7 +12,9 @@ export const GROUP_POSITIONS = {
|
|||||||
apart: 'space-between',
|
apart: 'space-between',
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface GroupProps extends React.ComponentPropsWithoutRef<'div'> {
|
export interface GroupProps
|
||||||
|
extends SystemProps,
|
||||||
|
Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> {
|
||||||
/** Defines justify-content property */
|
/** Defines justify-content property */
|
||||||
position?: GroupPosition;
|
position?: GroupPosition;
|
||||||
|
|
||||||
@@ -29,28 +31,28 @@ export interface GroupProps extends React.ComponentPropsWithoutRef<'div'> {
|
|||||||
align?: React.CSSProperties['alignItems'];
|
align?: React.CSSProperties['alignItems'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultProps: Partial<GroupProps> = {
|
export function Group({
|
||||||
position: 'left',
|
position = 'left',
|
||||||
spacing: 20,
|
spacing = 20,
|
||||||
};
|
align = 'center',
|
||||||
|
noWrap,
|
||||||
export function Group({ children, ...props }: GroupProps) {
|
children,
|
||||||
const groupProps = {
|
...props
|
||||||
...defaultProps,
|
}: GroupProps) {
|
||||||
...props,
|
|
||||||
};
|
|
||||||
const filteredChildren = filterFalsyChildren(children);
|
const filteredChildren = filterFalsyChildren(children);
|
||||||
|
|
||||||
return <GroupStyled {...groupProps}>{filteredChildren}</GroupStyled>;
|
return (
|
||||||
|
<Box
|
||||||
|
boxSizing={'border-box'}
|
||||||
|
display={'flex'}
|
||||||
|
flexDirection={'row'}
|
||||||
|
alignItems={align}
|
||||||
|
flexWrap={noWrap ? 'nowrap' : 'wrap'}
|
||||||
|
justifyContent={GROUP_POSITIONS[position]}
|
||||||
|
gap={`${spacing}px`}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{filteredChildren}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GroupStyled = styled(Box)`
|
|
||||||
box-sizing: border-box;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: ${(props: GroupProps) => (props.align || 'center')};
|
|
||||||
flex-wrap: ${(props: GroupProps) => (props.noWrap ? 'nowrap' : 'wrap')};
|
|
||||||
justify-content: ${(props: GroupProps) =>
|
|
||||||
GROUP_POSITIONS[props.position || 'left']};
|
|
||||||
gap: ${(props: GroupProps) => props.spacing}px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import { x, SystemProps } from '@xstyled/emotion';
|
||||||
import { Box } from '../Box';
|
|
||||||
|
|
||||||
export interface StackProps extends React.ComponentPropsWithoutRef<'div'> {
|
export interface StackProps
|
||||||
|
extends SystemProps,
|
||||||
|
Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> {
|
||||||
/** Key of theme.spacing or number to set gap in px */
|
/** Key of theme.spacing or number to set gap in px */
|
||||||
spacing?: number;
|
spacing?: number;
|
||||||
|
|
||||||
@@ -13,24 +14,20 @@ export interface StackProps extends React.ComponentPropsWithoutRef<'div'> {
|
|||||||
justify?: React.CSSProperties['justifyContent'];
|
justify?: React.CSSProperties['justifyContent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultProps: Partial<StackProps> = {
|
export function Stack({
|
||||||
spacing: 20,
|
spacing = 20,
|
||||||
align: 'stretch',
|
align = 'stretch',
|
||||||
justify: 'top',
|
justify = 'top',
|
||||||
};
|
...restProps
|
||||||
|
}: StackProps) {
|
||||||
export function Stack(props: StackProps) {
|
return (
|
||||||
const stackProps = {
|
<x.div
|
||||||
...defaultProps,
|
display={'flex'}
|
||||||
...props,
|
flexDirection="column"
|
||||||
};
|
justifyContent="justify"
|
||||||
return <StackStyled {...stackProps} />;
|
gap={`${spacing}px`}
|
||||||
|
alignItems={align}
|
||||||
|
{...restProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const StackStyled = styled(Box)`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: ${(props: StackProps) => props.align};
|
|
||||||
justify-content: justify;
|
|
||||||
gap: ${(props: StackProps) => props.spacing}px;
|
|
||||||
`;
|
|
||||||
|
|||||||
91
packages/webapp/src/components/PageForm/PageForm.tsx
Normal file
91
packages/webapp/src/components/PageForm/PageForm.tsx
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import React, { FC } from 'react';
|
||||||
|
import clsx from 'classnames';
|
||||||
|
import { x, SystemProps } from '@xstyled/emotion';
|
||||||
|
import { css } from '@emotion/css';
|
||||||
|
import { Group, GroupProps } from '@/components';
|
||||||
|
|
||||||
|
interface PageFormProps extends SystemProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page form layout.
|
||||||
|
* @returns {React.ReactNode}
|
||||||
|
*/
|
||||||
|
export const PageForm = ({ children, ...props }: PageFormProps) => {
|
||||||
|
return (
|
||||||
|
<x.div display="flex" flexDirection={'column'} overflow="hidden" {...props}>
|
||||||
|
{children}
|
||||||
|
</x.div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
PageForm.displayName = 'PageFormBody';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page form body layout, by default the content body is scrollable.
|
||||||
|
* @returns {React.ReactNode}
|
||||||
|
*/
|
||||||
|
const PageFormBody: FC<{ children: React.ReactNode } & SystemProps> = ({
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<x.div flex="1" overflow="auto" {...props}>
|
||||||
|
{children}
|
||||||
|
</x.div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
PageFormBody.displayName = 'PageFormBody';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page form footer.
|
||||||
|
* @returns {React.ReactNode}
|
||||||
|
*/
|
||||||
|
const PageFormFooter: FC<{ children: React.ReactNode } & SystemProps> = ({ children }) => {
|
||||||
|
return <x.div>{children} </x.div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
PageFormFooter.displayName = 'PageFormFooter';
|
||||||
|
|
||||||
|
const footerActionsStyle = `
|
||||||
|
width: 100%;
|
||||||
|
background: #fff;
|
||||||
|
padding: 14px 20px;
|
||||||
|
border-top: 1px solid rgb(210, 221, 226);
|
||||||
|
box-shadow: 0px -1px 4px 0px rgba(0, 0, 0, 0.05);
|
||||||
|
|
||||||
|
.bp4-button-group{
|
||||||
|
.bp4-button{
|
||||||
|
&:not(:last-child),
|
||||||
|
&.bp4-popover-wrapper:not(:last-child) {
|
||||||
|
border-right: 1px solid rgba(92, 112, 127, 0.3);
|
||||||
|
margin-right: 0;
|
||||||
|
|
||||||
|
&.bp4-intent-primary{
|
||||||
|
border-right: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const PageFormFooterActions: FC<GroupProps> = ({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
...restProps
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<Group
|
||||||
|
spacing={20}
|
||||||
|
{...restProps}
|
||||||
|
className={clsx(css(footerActionsStyle), className)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
PageFormFooterActions.displayName = 'PageFormFooterActions';
|
||||||
|
|
||||||
|
PageForm.Body = PageFormBody;
|
||||||
|
PageForm.Footer = PageFormFooter;
|
||||||
|
PageForm.FooterActions = PageFormFooterActions;
|
||||||
@@ -2,3 +2,4 @@
|
|||||||
export * from './FormTopbar';
|
export * from './FormTopbar';
|
||||||
export * from './FormTopbarSelectInputs';
|
export * from './FormTopbarSelectInputs';
|
||||||
export * from './PageFormBigNumber';
|
export * from './PageFormBigNumber';
|
||||||
|
export * from './PageForm';
|
||||||
@@ -1,13 +1,20 @@
|
|||||||
// @ts-nocheck
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import { x, SystemProps } from '@xstyled/emotion';
|
||||||
|
|
||||||
export function Paper({ children, className }) {
|
interface PaperProps extends SystemProps {
|
||||||
return <PaperRoot className={className}>{children}</PaperRoot>;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PaperRoot = styled.div`
|
export const Paper = ({ children, ...props }: PaperProps) => {
|
||||||
border: 1px solid #d2dce2;
|
return (
|
||||||
background: #fff;
|
<x.div
|
||||||
padding: 10px;
|
background={'white'}
|
||||||
`;
|
p={'10px'}
|
||||||
|
border={'1px solid #d2dce2'}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</x.div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Paper.displayName = 'Paper';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import { Row, Col, Paper } from '@/components';
|
import { Row, Col, Paper } from '@/components';
|
||||||
@@ -12,7 +11,7 @@ import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmen
|
|||||||
export default function MakeJournalFormFooter() {
|
export default function MakeJournalFormFooter() {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
||||||
<MakeJournalFooterPaper>
|
<Paper p={'20px'}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
<MakeJournalFormFooterLeft />
|
<MakeJournalFormFooterLeft />
|
||||||
@@ -23,10 +22,7 @@ export default function MakeJournalFormFooter() {
|
|||||||
<MakeJournalFormFooterRight />
|
<MakeJournalFormFooterRight />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</MakeJournalFooterPaper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const MakeJournalFooterPaper = styled(Paper)`
|
|
||||||
padding: 20px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
|
import { Spinner } from '@blueprintjs/core';
|
||||||
import {
|
import {
|
||||||
GetPdfTemplateBrandingStateResponse,
|
GetPdfTemplateBrandingStateResponse,
|
||||||
GetPdfTemplateResponse,
|
GetPdfTemplateResponse,
|
||||||
useGetPdfTemplate,
|
useGetPdfTemplate,
|
||||||
useGetPdfTemplateBrandingState,
|
useGetPdfTemplateBrandingState,
|
||||||
} from '@/hooks/query/pdf-templates';
|
} from '@/hooks/query/pdf-templates';
|
||||||
import { Spinner } from '@blueprintjs/core';
|
|
||||||
|
|
||||||
interface PdfTemplateContextValue {
|
interface PdfTemplateContextValue {
|
||||||
templateId: number | string;
|
templateId: number | string;
|
||||||
|
|
||||||
|
// Pdf template.
|
||||||
pdfTemplate: GetPdfTemplateResponse | undefined;
|
pdfTemplate: GetPdfTemplateResponse | undefined;
|
||||||
isPdfTemplateLoading: boolean;
|
isPdfTemplateLoading: boolean;
|
||||||
|
|
||||||
// Branding state.
|
// Branding state.
|
||||||
brandingTemplateState: GetPdfTemplateBrandingStateResponse | undefined;
|
brandingTemplateState: GetPdfTemplateBrandingStateResponse;
|
||||||
isBrandingTemplateLoading: boolean;
|
isBrandingTemplateLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,10 +36,17 @@ export const BrandingTemplateBoot = ({
|
|||||||
useGetPdfTemplate(templateId, {
|
useGetPdfTemplate(templateId, {
|
||||||
enabled: !!templateId,
|
enabled: !!templateId,
|
||||||
});
|
});
|
||||||
// Retreives the branding template state.
|
// Retrieves the branding template state.
|
||||||
const { data: brandingTemplateState, isLoading: isBrandingTemplateLoading } =
|
const { data: brandingTemplateState, isLoading: isBrandingTemplateLoading } =
|
||||||
useGetPdfTemplateBrandingState();
|
useGetPdfTemplateBrandingState();
|
||||||
|
|
||||||
|
const isLoading = isPdfTemplateLoading ||
|
||||||
|
isBrandingTemplateLoading ||
|
||||||
|
!brandingTemplateState;
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <Spinner size={20} />;
|
||||||
|
}
|
||||||
const value = {
|
const value = {
|
||||||
templateId,
|
templateId,
|
||||||
pdfTemplate,
|
pdfTemplate,
|
||||||
@@ -47,11 +56,6 @@ export const BrandingTemplateBoot = ({
|
|||||||
isBrandingTemplateLoading,
|
isBrandingTemplateLoading,
|
||||||
};
|
};
|
||||||
|
|
||||||
const isLoading = isPdfTemplateLoading || isBrandingTemplateLoading;
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spinner size={20} />;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<PdfTemplateContext.Provider value={value}>
|
<PdfTemplateContext.Provider value={value}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
transformToEditRequest,
|
transformToEditRequest,
|
||||||
transformToNewRequest,
|
transformToNewRequest,
|
||||||
|
useBrandingState,
|
||||||
useBrandingTemplateFormInitialValues,
|
useBrandingTemplateFormInitialValues,
|
||||||
} from './_utils';
|
} from './_utils';
|
||||||
import { AppToaster } from '@/components';
|
import { AppToaster } from '@/components';
|
||||||
@@ -17,31 +18,40 @@ import {
|
|||||||
useEditPdfTemplate,
|
useEditPdfTemplate,
|
||||||
} from '@/hooks/query/pdf-templates';
|
} from '@/hooks/query/pdf-templates';
|
||||||
import { FormikHelpers } from 'formik';
|
import { FormikHelpers } from 'formik';
|
||||||
import { BrandingTemplateValues } from './types';
|
import { BrandingTemplateValues, BrandingState } from './types';
|
||||||
import { useUploadAttachments } from '@/hooks/query/attachments';
|
import { useUploadAttachments } from '@/hooks/query/attachments';
|
||||||
import { excludePrivateProps } from '@/utils';
|
import { excludePrivateProps } from '@/utils';
|
||||||
|
|
||||||
interface BrandingTemplateFormProps<T> extends ElementCustomizeProps<T> {
|
interface BrandingTemplateFormProps<
|
||||||
|
T extends BrandingTemplateValues,
|
||||||
|
Y extends BrandingState
|
||||||
|
> extends ElementCustomizeProps<T, Y> {
|
||||||
resource: string;
|
resource: string;
|
||||||
templateId?: number;
|
templateId?: number;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
onError?: () => void;
|
onError?: () => void;
|
||||||
|
|
||||||
|
/* The default values hold the initial values of the form and the values being sent to the server. */
|
||||||
defaultValues?: T;
|
defaultValues?: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BrandingTemplateForm<T extends BrandingTemplateValues>({
|
export function BrandingTemplateForm<
|
||||||
|
T extends BrandingTemplateValues,
|
||||||
|
Y extends BrandingState,
|
||||||
|
>({
|
||||||
templateId,
|
templateId,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
onError,
|
onError,
|
||||||
defaultValues,
|
defaultValues,
|
||||||
resource,
|
resource,
|
||||||
...props
|
...props
|
||||||
}: BrandingTemplateFormProps<T>) {
|
}: BrandingTemplateFormProps<T, Y>) {
|
||||||
|
// Create/edit pdf template mutators.
|
||||||
const { mutateAsync: createPdfTemplate } = useCreatePdfTemplate();
|
const { mutateAsync: createPdfTemplate } = useCreatePdfTemplate();
|
||||||
const { mutateAsync: editPdfTemplate } = useEditPdfTemplate();
|
const { mutateAsync: editPdfTemplate } = useEditPdfTemplate();
|
||||||
|
|
||||||
const initialValues = useBrandingTemplateFormInitialValues<T>(defaultValues);
|
const initialValues = useBrandingTemplateFormInitialValues<T>(defaultValues);
|
||||||
const [isUploading, setIsLoading] = useState<boolean>(false);
|
const [, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
// Uploads the attachments.
|
// Uploads the attachments.
|
||||||
const { mutateAsync: uploadAttachments } = useUploadAttachments({
|
const { mutateAsync: uploadAttachments } = useUploadAttachments({
|
||||||
@@ -122,7 +132,7 @@ export function BrandingTemplateForm<T extends BrandingTemplateValues>({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ElementCustomize<T>
|
<ElementCustomize<T, Y>
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
validationSchema={validationSchema}
|
validationSchema={validationSchema}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Button } from '@blueprintjs/core';
|
import { Button, ButtonProps } from '@blueprintjs/core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { FFormGroup } from '@/components';
|
import { FFormGroup, Icon } from '@/components';
|
||||||
|
|
||||||
export const BrandingThemeFormGroup = styled(FFormGroup)`
|
export const BrandingThemeFormGroup = styled(FFormGroup)`
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
@@ -14,33 +14,21 @@ export const BrandingThemeFormGroup = styled(FFormGroup)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const BrandingThemeSelectButton = styled(Button)`
|
export const BrandingThemeSelectButton = (props: ButtonProps) => {
|
||||||
position: relative;
|
return (
|
||||||
padding-right: 26px;
|
<Button
|
||||||
|
text={props?.text || 'Brand Theme'}
|
||||||
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
|
minimal
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
&::after {
|
export const convertBrandingTemplatesToOptions = (
|
||||||
content: '';
|
brandingTemplates: Array<any>,
|
||||||
display: inline-block;
|
) => {
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
|
|
||||||
border-left: 4px solid transparent;
|
|
||||||
border-right: 4px solid transparent;
|
|
||||||
border-top: 5px solid #98a1ae;
|
|
||||||
|
|
||||||
position: absolute;
|
|
||||||
right: -2px;
|
|
||||||
top: 50%;
|
|
||||||
margin-top: -2px;
|
|
||||||
margin-right: 12px;
|
|
||||||
border-radius: 1px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
|
|
||||||
export const convertBrandingTemplatesToOptions = (brandingTemplates: Array<any>) => {
|
|
||||||
return brandingTemplates?.map(
|
return brandingTemplates?.map(
|
||||||
(template) =>
|
(template) => ({ text: template.template_name, value: template.id } || []),
|
||||||
({ text: template.template_name, value: template.id } || []),
|
);
|
||||||
)
|
};
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
} from '@/hooks/query/pdf-templates';
|
} from '@/hooks/query/pdf-templates';
|
||||||
import { useBrandingTemplateBoot } from './BrandingTemplateBoot';
|
import { useBrandingTemplateBoot } from './BrandingTemplateBoot';
|
||||||
import { transformToForm } from '@/utils';
|
import { transformToForm } from '@/utils';
|
||||||
import { BrandingTemplateValues } from './types';
|
import { BrandingState, BrandingTemplateValues } from './types';
|
||||||
import { DRAWERS } from '@/constants/drawers';
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
|
||||||
const commonExcludedAttrs = ['templateName', 'companyLogoUri'];
|
const commonExcludedAttrs = ['templateName', 'companyLogoUri'];
|
||||||
@@ -44,11 +44,10 @@ export const useBrandingTemplateFormInitialValues = <
|
|||||||
>(
|
>(
|
||||||
initialValues = {},
|
initialValues = {},
|
||||||
) => {
|
) => {
|
||||||
const { pdfTemplate, brandingTemplateState } = useBrandingTemplateBoot();
|
const { pdfTemplate } = useBrandingTemplateBoot();
|
||||||
|
|
||||||
const brandingAttributes = {
|
const brandingAttributes = {
|
||||||
templateName: pdfTemplate?.templateName,
|
templateName: pdfTemplate?.templateName,
|
||||||
...brandingTemplateState,
|
|
||||||
...pdfTemplate?.attributes,
|
...pdfTemplate?.attributes,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -57,6 +56,15 @@ export const useBrandingTemplateFormInitialValues = <
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useBrandingState = (state?: Partial<BrandingState>): BrandingState => {
|
||||||
|
const { brandingTemplateState } = useBrandingTemplateBoot();
|
||||||
|
|
||||||
|
return {
|
||||||
|
...brandingTemplateState,
|
||||||
|
...state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const getCustomizeDrawerNameFromResource = (resource: string) => {
|
export const getCustomizeDrawerNameFromResource = (resource: string) => {
|
||||||
const pairs = {
|
const pairs = {
|
||||||
SaleInvoice: DRAWERS.INVOICE_CUSTOMIZE,
|
SaleInvoice: DRAWERS.INVOICE_CUSTOMIZE,
|
||||||
|
|||||||
@@ -7,3 +7,17 @@ export interface BrandingTemplateValues {
|
|||||||
companyLogoKey?: string;
|
companyLogoKey?: string;
|
||||||
companyLogoUri?: string;
|
companyLogoUri?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BrandingState extends ElementPreviewState {
|
||||||
|
companyName: string;
|
||||||
|
companyAddress: string;
|
||||||
|
|
||||||
|
companyLogoKey: string;
|
||||||
|
companyLogoUri: string;
|
||||||
|
|
||||||
|
primaryColor: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ElementPreviewState {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,17 +9,23 @@ import { ElementCustomizeTabsControllerProvider } from './ElementCustomizeTabsCo
|
|||||||
import { ElementCustomizeFields } from './ElementCustomizeFields';
|
import { ElementCustomizeFields } from './ElementCustomizeFields';
|
||||||
import { ElementCustomizePreview } from './ElementCustomizePreview';
|
import { ElementCustomizePreview } from './ElementCustomizePreview';
|
||||||
import { extractChildren } from '@/utils/extract-children';
|
import { extractChildren } from '@/utils/extract-children';
|
||||||
|
import { ElementPreviewState } from '../BrandingTemplates/types';
|
||||||
|
import { TabProps } from '@blueprintjs/core';
|
||||||
|
import { useBrandingState } from '../BrandingTemplates/_utils';
|
||||||
|
|
||||||
export interface ElementCustomizeProps<T> extends ElementCustomizeFormProps<T> {
|
export interface ElementCustomizeProps<T, Y>
|
||||||
|
extends ElementCustomizeFormProps<T, Y> {
|
||||||
|
brandingState?: Y;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ElementCustomize<T>({
|
export interface ElementCustomizeContentProps {
|
||||||
initialValues,
|
children?: React.ReactNode;
|
||||||
validationSchema,
|
}
|
||||||
onSubmit,
|
|
||||||
|
export function ElementCustomizeContent({
|
||||||
children,
|
children,
|
||||||
}: ElementCustomizeProps<T>) {
|
}: ElementCustomizeContentProps) {
|
||||||
const PaperTemplate = React.useMemo(
|
const PaperTemplate = React.useMemo(
|
||||||
() => extractChildren(children, ElementCustomize.PaperTemplate),
|
() => extractChildren(children, ElementCustomize.PaperTemplate),
|
||||||
[children],
|
[children],
|
||||||
@@ -28,15 +34,10 @@ export function ElementCustomize<T>({
|
|||||||
() => extractChildren(children, ElementCustomize.FieldsTab),
|
() => extractChildren(children, ElementCustomize.FieldsTab),
|
||||||
[children],
|
[children],
|
||||||
);
|
);
|
||||||
|
const brandingState = useBrandingState();
|
||||||
const value = { PaperTemplate, CustomizeTabs };
|
const value = { PaperTemplate, CustomizeTabs, brandingState };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ElementCustomizeForm
|
|
||||||
initialValues={initialValues}
|
|
||||||
validationSchema={validationSchema}
|
|
||||||
onSubmit={onSubmit}
|
|
||||||
>
|
|
||||||
<ElementCustomizeTabsControllerProvider>
|
<ElementCustomizeTabsControllerProvider>
|
||||||
<ElementCustomizeProvider value={value}>
|
<ElementCustomizeProvider value={value}>
|
||||||
<Group spacing={0} align="stretch">
|
<Group spacing={0} align="stretch">
|
||||||
@@ -45,6 +46,22 @@ export function ElementCustomize<T>({
|
|||||||
</Group>
|
</Group>
|
||||||
</ElementCustomizeProvider>
|
</ElementCustomizeProvider>
|
||||||
</ElementCustomizeTabsControllerProvider>
|
</ElementCustomizeTabsControllerProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ElementCustomize<T, Y extends ElementPreviewState>({
|
||||||
|
initialValues,
|
||||||
|
validationSchema,
|
||||||
|
onSubmit,
|
||||||
|
children,
|
||||||
|
}: ElementCustomizeProps<T, Y>) {
|
||||||
|
return (
|
||||||
|
<ElementCustomizeForm
|
||||||
|
initialValues={initialValues}
|
||||||
|
validationSchema={validationSchema}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
</ElementCustomizeForm>
|
</ElementCustomizeForm>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -59,16 +76,17 @@ ElementCustomize.PaperTemplate = ({
|
|||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ElementCustomizeContentProps {
|
export interface ElementCustomizeFieldsTabProps {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
|
tabProps?: Partial<TabProps>;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementCustomize.FieldsTab = ({
|
ElementCustomize.FieldsTab = ({
|
||||||
id,
|
id,
|
||||||
label,
|
label,
|
||||||
children,
|
children,
|
||||||
}: ElementCustomizeContentProps) => {
|
}: ElementCustomizeFieldsTabProps) => {
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
|
import { ElementPreviewState } from '../BrandingTemplates/types';
|
||||||
|
|
||||||
interface ElementCustomizeValue {
|
interface ElementCustomizeValue {
|
||||||
PaperTemplate?: React.ReactNode;
|
PaperTemplate?: React.ReactNode;
|
||||||
CustomizeTabs: React.ReactNode;
|
CustomizeTabs: React.ReactNode;
|
||||||
|
brandingState?: ElementPreviewState;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ElementCustomizeContext = createContext<ElementCustomizeValue>(
|
const ElementCustomizeContext = createContext<ElementCustomizeValue>(
|
||||||
{} as ElementCustomizeValue,
|
{} as ElementCustomizeValue,
|
||||||
);
|
);
|
||||||
|
|
||||||
export const ElementCustomizeProvider: React.FC<{
|
interface ElementCustomizeProviderProps {
|
||||||
value: ElementCustomizeValue;
|
value: ElementCustomizeValue;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}> = ({ value, children }) => {
|
}
|
||||||
|
|
||||||
|
export const ElementCustomizeProvider = ({ value, children }: ElementCustomizeProviderProps) => {
|
||||||
return (
|
return (
|
||||||
<ElementCustomizeContext.Provider value={{ ...value }}>
|
<ElementCustomizeContext.Provider value={{ ...value }}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Stack } from '@/components';
|
import { Box, Stack } from '@/components';
|
||||||
import { Tab, Tabs } from '@blueprintjs/core';
|
import { Tab, TabProps, Tabs } from '@blueprintjs/core';
|
||||||
import { ElementCustomizeHeader } from './ElementCustomizeHeader';
|
import { ElementCustomizeHeader } from './ElementCustomizeHeader';
|
||||||
import {
|
import {
|
||||||
ElementCustomizeTabsEnum,
|
ElementCustomizeTabsEnum,
|
||||||
@@ -11,7 +11,6 @@ import styles from './ElementCustomizeTabs.module.scss';
|
|||||||
|
|
||||||
export function ElementCustomizeTabs() {
|
export function ElementCustomizeTabs() {
|
||||||
const { setCurrentTabId } = useElementCustomizeTabsController();
|
const { setCurrentTabId } = useElementCustomizeTabsController();
|
||||||
|
|
||||||
const { CustomizeTabs } = useElementCustomizeContext();
|
const { CustomizeTabs } = useElementCustomizeContext();
|
||||||
|
|
||||||
const tabItems = React.Children.map(CustomizeTabs, (node) => ({
|
const tabItems = React.Children.map(CustomizeTabs, (node) => ({
|
||||||
@@ -32,9 +31,19 @@ export function ElementCustomizeTabs() {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
className={styles.tabsList}
|
className={styles.tabsList}
|
||||||
>
|
>
|
||||||
{tabItems?.map(({ id, label }: { id: string; label: string }) => (
|
{tabItems?.map(
|
||||||
<Tab id={id} key={id} title={label} />
|
({
|
||||||
))}
|
id,
|
||||||
|
label,
|
||||||
|
tabProps,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
tabProps?: TabProps;
|
||||||
|
}) => (
|
||||||
|
<Tab id={id} key={id} title={label} {...tabProps} />
|
||||||
|
),
|
||||||
|
)}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Formik, Form, FormikHelpers } from 'formik';
|
import { Formik, Form, FormikHelpers } from 'formik';
|
||||||
|
|
||||||
export interface ElementCustomizeFormProps<T> {
|
export interface ElementCustomizeFormProps<T, Y> {
|
||||||
initialValues?: T;
|
initialValues?: T;
|
||||||
validationSchema?: any;
|
validationSchema?: any;
|
||||||
onSubmit?: (values: T, formikHelpers: FormikHelpers<T>) => void;
|
onSubmit?: (values: T, formikHelpers: FormikHelpers<T>) => void;
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ export function BrandingCompanyLogoUploadField() {
|
|||||||
onChange={(file) => {
|
onChange={(file) => {
|
||||||
const imageUrl = file ? URL.createObjectURL(file) : '';
|
const imageUrl = file ? URL.createObjectURL(file) : '';
|
||||||
|
|
||||||
|
// Reset the logo key since it is changed.
|
||||||
|
setFieldValue('companyLogoKey', '');
|
||||||
|
|
||||||
setFieldValue('_companyLogoFile', file);
|
setFieldValue('_companyLogoFile', file);
|
||||||
setFieldValue('companyLogoUri', imageUrl);
|
setFieldValue('companyLogoUri', imageUrl);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import { Row, Col, Paper } from '@/components';
|
import { Row, Col, Paper } from '@/components';
|
||||||
@@ -12,7 +11,7 @@ import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmen
|
|||||||
export default function ExpenseFormFooter() {
|
export default function ExpenseFormFooter() {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
||||||
<ExpensesFooterPaper>
|
<Paper p={'20px'}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
<ExpenseFormFooterLeft />
|
<ExpenseFormFooterLeft />
|
||||||
@@ -23,11 +22,7 @@ export default function ExpenseFormFooter() {
|
|||||||
<ExpenseFormFooterRight />
|
<ExpenseFormFooterRight />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</ExpensesFooterPaper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExpensesFooterPaper = styled(Paper)`
|
|
||||||
padding: 20px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { Text, Classes, Button, Intent, Tag } from '@blueprintjs/core';
|
import { Text, Classes, Button, Intent } from '@blueprintjs/core';
|
||||||
import clsx from 'classnames';
|
import clsx from 'classnames';
|
||||||
import { AppToaster, Box, Group, Stack } from '@/components';
|
import { AppToaster, Box, Group, Stack } from '@/components';
|
||||||
import { usePaymentPortalBoot } from './PaymentPortalBoot';
|
import { usePaymentPortalBoot } from './PaymentPortalBoot';
|
||||||
import { useDrawerActions } from '@/hooks/state';
|
import { useDrawerActions } from '@/hooks/state';
|
||||||
import { useCreateStripeCheckoutSession } from '@/hooks/query/payment-link';
|
import {
|
||||||
|
useCreateStripeCheckoutSession,
|
||||||
|
useGeneratePaymentLinkInvoicePdf,
|
||||||
|
} from '@/hooks/query/payment-link';
|
||||||
import { DRAWERS } from '@/constants/drawers';
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
import { downloadFile } from '@/hooks/useDownloadFile';
|
||||||
import styles from './PaymentPortal.module.scss';
|
import styles from './PaymentPortal.module.scss';
|
||||||
|
|
||||||
export function PaymentPortal() {
|
export function PaymentPortal() {
|
||||||
@@ -15,10 +19,34 @@ export function PaymentPortal() {
|
|||||||
isLoading: isStripeCheckoutLoading,
|
isLoading: isStripeCheckoutLoading,
|
||||||
} = useCreateStripeCheckoutSession();
|
} = useCreateStripeCheckoutSession();
|
||||||
|
|
||||||
|
const {
|
||||||
|
mutateAsync: generatePaymentLinkInvoice,
|
||||||
|
isLoading: isInvoiceGenerating,
|
||||||
|
} = useGeneratePaymentLinkInvoicePdf();
|
||||||
|
|
||||||
// Handles invoice preview button click.
|
// Handles invoice preview button click.
|
||||||
const handleInvoicePreviewBtnClick = () => {
|
const handleInvoicePreviewBtnClick = () => {
|
||||||
openDrawer(DRAWERS.PAYMENT_INVOICE_PREVIEW);
|
openDrawer(DRAWERS.PAYMENT_INVOICE_PREVIEW);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handles invoice download button click.
|
||||||
|
const handleInvoiceDownloadBtnClick = () => {
|
||||||
|
generatePaymentLinkInvoice({ paymentLinkId: linkId })
|
||||||
|
.then((data) => {
|
||||||
|
downloadFile(
|
||||||
|
data,
|
||||||
|
`Invoice ${sharableLinkMeta?.invoiceNo}`,
|
||||||
|
'application/pdf',
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
AppToaster.show({
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
message: 'Something went wrong.',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// handles the pay button click.
|
// handles the pay button click.
|
||||||
const handlePayButtonClick = () => {
|
const handlePayButtonClick = () => {
|
||||||
createStripeCheckoutSession({ linkId })
|
createStripeCheckoutSession({ linkId })
|
||||||
@@ -125,6 +153,8 @@ export function PaymentPortal() {
|
|||||||
<Button
|
<Button
|
||||||
minimal
|
minimal
|
||||||
className={clsx(styles.footerButton, styles.downloadInvoiceButton)}
|
className={clsx(styles.footerButton, styles.downloadInvoiceButton)}
|
||||||
|
onClick={handleInvoiceDownloadBtnClick}
|
||||||
|
loading={isInvoiceGenerating}
|
||||||
>
|
>
|
||||||
Download Invoice
|
Download Invoice
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { PaymentPortal } from './PaymentPortal';
|
import { Helmet } from 'react-helmet';
|
||||||
import { PaymentPortalBoot } from './PaymentPortalBoot';
|
|
||||||
import BodyClassName from 'react-body-classname';
|
import BodyClassName from 'react-body-classname';
|
||||||
import styles from './PaymentPortal.module.scss';
|
import { PaymentPortal } from './PaymentPortal';
|
||||||
|
import { PaymentPortalBoot, usePaymentPortalBoot } from './PaymentPortalBoot';
|
||||||
import { PaymentInvoicePreviewDrawer } from './drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewDrawer';
|
import { PaymentInvoicePreviewDrawer } from './drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewDrawer';
|
||||||
import { DRAWERS } from '@/constants/drawers';
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
import styles from './PaymentPortal.module.scss';
|
||||||
|
|
||||||
export default function PaymentPortalPage() {
|
export default function PaymentPortalPage() {
|
||||||
const { linkId } = useParams<{ linkId: string }>();
|
const { linkId } = useParams<{ linkId: string }>();
|
||||||
@@ -12,9 +13,26 @@ export default function PaymentPortalPage() {
|
|||||||
return (
|
return (
|
||||||
<BodyClassName className={styles.rootBodyPage}>
|
<BodyClassName className={styles.rootBodyPage}>
|
||||||
<PaymentPortalBoot linkId={linkId}>
|
<PaymentPortalBoot linkId={linkId}>
|
||||||
|
<PaymentPortalHelmet />
|
||||||
<PaymentPortal />
|
<PaymentPortal />
|
||||||
<PaymentInvoicePreviewDrawer name={DRAWERS.PAYMENT_INVOICE_PREVIEW} />
|
<PaymentInvoicePreviewDrawer name={DRAWERS.PAYMENT_INVOICE_PREVIEW} />
|
||||||
</PaymentPortalBoot>
|
</PaymentPortalBoot>
|
||||||
</BodyClassName>
|
</BodyClassName>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the document title of the current payment page.
|
||||||
|
* @returns {React.ReactNode}
|
||||||
|
*/
|
||||||
|
function PaymentPortalHelmet() {
|
||||||
|
const { sharableLinkMeta } = usePaymentPortalBoot();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{sharableLinkMeta?.invoiceNo} | {sharableLinkMeta?.organization?.name}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Button, FormGroup, Intent } from '@blueprintjs/core';
|
|||||||
import { TimezonePicker } from '@blueprintjs/timezone';
|
import { TimezonePicker } from '@blueprintjs/timezone';
|
||||||
import { ErrorMessage, FastField } from 'formik';
|
import { ErrorMessage, FastField } from 'formik';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import { getAllCountries } from '@bigcapital/utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FieldRequiredHint,
|
FieldRequiredHint,
|
||||||
@@ -23,7 +24,6 @@ import { getAllCurrenciesOptions } from '@/constants/currencies';
|
|||||||
import { getFiscalYear } from '@/constants/fiscalYearOptions';
|
import { getFiscalYear } from '@/constants/fiscalYearOptions';
|
||||||
import { getLanguages } from '@/constants/languagesOptions';
|
import { getLanguages } from '@/constants/languagesOptions';
|
||||||
import { useGeneralFormContext } from './GeneralFormProvider';
|
import { useGeneralFormContext } from './GeneralFormProvider';
|
||||||
import { getAllCountries } from '@/utils/countries';
|
|
||||||
|
|
||||||
import { shouldBaseCurrencyUpdate } from './utils';
|
import { shouldBaseCurrencyUpdate } from './utils';
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export function StripePaymentMethod() {
|
|||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Button small icon={<MoreIcon size={16} />} />
|
<Button small icon={<MoreIcon height={10} width={10} />} />
|
||||||
</Popover>
|
</Popover>
|
||||||
)}
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmen
|
|||||||
export default function BillFormFooter() {
|
export default function BillFormFooter() {
|
||||||
return (
|
return (
|
||||||
<div class={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
<div class={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
||||||
<BillFooterPaper>
|
<Paper p={'20px'}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
<BillFormFooterLeft />
|
<BillFormFooterLeft />
|
||||||
@@ -24,11 +24,7 @@ export default function BillFormFooter() {
|
|||||||
<BillFormFooterRight />
|
<BillFormFooterRight />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</BillFooterPaper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const BillFooterPaper = styled(Paper)`
|
|
||||||
padding: 20px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmen
|
|||||||
export default function VendorCreditNoteFormFooter() {
|
export default function VendorCreditNoteFormFooter() {
|
||||||
return (
|
return (
|
||||||
<div class={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
<div class={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
||||||
<VendorCreditNoteFooterPaper>
|
<Paper p={'20px'}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
<VendorCreditNoteFormFooterLeft />
|
<VendorCreditNoteFormFooterLeft />
|
||||||
@@ -26,11 +26,7 @@ export default function VendorCreditNoteFormFooter() {
|
|||||||
<VendorCreditNoteFormFooterRight />
|
<VendorCreditNoteFormFooterRight />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</VendorCreditNoteFooterPaper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const VendorCreditNoteFooterPaper = styled(Paper)`
|
|
||||||
padding: 20px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmen
|
|||||||
export default function PaymentMadeFooter() {
|
export default function PaymentMadeFooter() {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
||||||
<PaymentReceiveFooterPaper>
|
<Paper p={'20px'}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
<PaymentMadeFormFooterLeft />
|
<PaymentMadeFormFooterLeft />
|
||||||
@@ -26,11 +26,7 @@ export default function PaymentMadeFooter() {
|
|||||||
<PaymentMadeFormFooterRight />
|
<PaymentMadeFormFooterRight />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</PaymentReceiveFooterPaper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PaymentReceiveFooterPaper = styled(Paper)`
|
|
||||||
padding: 20px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { ElementCustomize } from '../../../ElementCustomize/ElementCustomize';
|
import {
|
||||||
|
ElementCustomize,
|
||||||
|
ElementCustomizeContent,
|
||||||
|
} from '../../../ElementCustomize/ElementCustomize';
|
||||||
import { CreditNoteCustomizeGeneralField } from './CreditNoteCustomizeGeneralFields';
|
import { CreditNoteCustomizeGeneralField } from './CreditNoteCustomizeGeneralFields';
|
||||||
import { CreditNoteCustomizeContentFields } from './CreditNoteCutomizeContentFields';
|
import { CreditNoteCustomizeContentFields } from './CreditNoteCutomizeContentFields';
|
||||||
import { CreditNotePaperTemplate } from './CreditNotePaperTemplate';
|
import {
|
||||||
import { CreditNoteCustomizeValues } from './types';
|
CreditNotePaperTemplate,
|
||||||
|
CreditNotePaperTemplateProps,
|
||||||
|
} from './CreditNotePaperTemplate';
|
||||||
|
import { CreditNoteBrandingState, CreditNoteCustomizeValues } from './types';
|
||||||
import { initialValues } from './constants';
|
import { initialValues } from './constants';
|
||||||
import { BrandingTemplateForm } from '@/containers/BrandingTemplates/BrandingTemplateForm';
|
import { BrandingTemplateForm } from '@/containers/BrandingTemplates/BrandingTemplateForm';
|
||||||
import { useDrawerActions } from '@/hooks/state';
|
import { useDrawerActions } from '@/hooks/state';
|
||||||
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
||||||
|
import { useElementCustomizeContext } from '@/containers/ElementCustomize/ElementCustomizeProvider';
|
||||||
|
import { useIsTemplateNamedFilled } from '@/containers/BrandingTemplates/utils';
|
||||||
|
|
||||||
export function CreditNoteCustomizeContent() {
|
export function CreditNoteCustomizeContent() {
|
||||||
const { payload, name } = useDrawerContext();
|
const { payload, name } = useDrawerContext();
|
||||||
@@ -20,12 +28,22 @@ export function CreditNoteCustomizeContent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BrandingTemplateForm<CreditNoteCustomizeValues>
|
<BrandingTemplateForm<CreditNoteCustomizeValues, CreditNoteBrandingState>
|
||||||
resource={'CreditNote'}
|
resource={'CreditNote'}
|
||||||
templateId={templateId}
|
templateId={templateId}
|
||||||
defaultValues={initialValues}
|
defaultValues={initialValues}
|
||||||
onSuccess={handleSuccess}
|
onSuccess={handleSuccess}
|
||||||
>
|
>
|
||||||
|
<CreditNoteCustomizeFormContent />
|
||||||
|
</BrandingTemplateForm>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CreditNoteCustomizeFormContent() {
|
||||||
|
const isTemplateNameFilled = useIsTemplateNamedFilled();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ElementCustomizeContent>
|
||||||
<ElementCustomize.PaperTemplate>
|
<ElementCustomize.PaperTemplate>
|
||||||
<CreditNotePaperTemplateFormConnected />
|
<CreditNotePaperTemplateFormConnected />
|
||||||
</ElementCustomize.PaperTemplate>
|
</ElementCustomize.PaperTemplate>
|
||||||
@@ -34,15 +52,25 @@ export function CreditNoteCustomizeContent() {
|
|||||||
<CreditNoteCustomizeGeneralField />
|
<CreditNoteCustomizeGeneralField />
|
||||||
</ElementCustomize.FieldsTab>
|
</ElementCustomize.FieldsTab>
|
||||||
|
|
||||||
<ElementCustomize.FieldsTab id={'content'} label={'Content'}>
|
<ElementCustomize.FieldsTab
|
||||||
|
id={'content'}
|
||||||
|
label={'Content'}
|
||||||
|
tabProps={{ disabled: !isTemplateNameFilled }}
|
||||||
|
>
|
||||||
<CreditNoteCustomizeContentFields />
|
<CreditNoteCustomizeContentFields />
|
||||||
</ElementCustomize.FieldsTab>
|
</ElementCustomize.FieldsTab>
|
||||||
</BrandingTemplateForm>
|
</ElementCustomizeContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CreditNotePaperTemplateFormConnected() {
|
function CreditNotePaperTemplateFormConnected() {
|
||||||
const { values } = useFormikContext<CreditNoteCustomizeValues>();
|
const { values } = useFormikContext<CreditNoteCustomizeValues>();
|
||||||
|
const { brandingState } = useElementCustomizeContext();
|
||||||
|
|
||||||
return <CreditNotePaperTemplate {...values} />;
|
const mergedProps: CreditNotePaperTemplateProps = {
|
||||||
|
...brandingState,
|
||||||
|
...values,
|
||||||
|
};
|
||||||
|
|
||||||
|
return <CreditNotePaperTemplate {...mergedProps} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box, Stack } from '@/components';
|
import { Box, Group, Stack } from '@/components';
|
||||||
import {
|
import {
|
||||||
PaperTemplate,
|
PaperTemplate,
|
||||||
PaperTemplateProps,
|
PaperTemplateProps,
|
||||||
@@ -13,6 +13,13 @@ import {
|
|||||||
} from '@/constants/PdfTemplates';
|
} from '@/constants/PdfTemplates';
|
||||||
|
|
||||||
export interface CreditNotePaperTemplateProps extends PaperTemplateProps {
|
export interface CreditNotePaperTemplateProps extends PaperTemplateProps {
|
||||||
|
// # Company logo
|
||||||
|
showCompanyLogo?: boolean;
|
||||||
|
companyLogoUri?: string;
|
||||||
|
|
||||||
|
// # Company name
|
||||||
|
companyName?: string;
|
||||||
|
|
||||||
// Address
|
// Address
|
||||||
showCustomerAddress?: boolean;
|
showCustomerAddress?: boolean;
|
||||||
customerAddress?: string;
|
customerAddress?: string;
|
||||||
@@ -122,14 +129,12 @@ export function CreditNotePaperTemplate({
|
|||||||
creditNoteDateLabel = 'Credit Note Date',
|
creditNoteDateLabel = 'Credit Note Date',
|
||||||
}: CreditNotePaperTemplateProps) {
|
}: CreditNotePaperTemplateProps) {
|
||||||
return (
|
return (
|
||||||
<PaperTemplate
|
<PaperTemplate primaryColor={primaryColor} secondaryColor={secondaryColor}>
|
||||||
primaryColor={primaryColor}
|
|
||||||
secondaryColor={secondaryColor}
|
|
||||||
showCompanyLogo={showCompanyLogo}
|
|
||||||
companyLogoUri={companyLogoUri}
|
|
||||||
bigtitle={'Credit Note'}
|
|
||||||
>
|
|
||||||
<Stack spacing={24}>
|
<Stack spacing={24}>
|
||||||
|
<Group align={'start'} spacing={10}>
|
||||||
|
<Stack flex={1}>
|
||||||
|
<PaperTemplate.BigTitle title={'Credit Note'} />
|
||||||
|
|
||||||
<PaperTemplate.TermsList>
|
<PaperTemplate.TermsList>
|
||||||
{showCreditNoteNumber && (
|
{showCreditNoteNumber && (
|
||||||
<PaperTemplate.TermsItem label={creditNoteNumberLabel}>
|
<PaperTemplate.TermsItem label={creditNoteNumberLabel}>
|
||||||
@@ -142,6 +147,12 @@ export function CreditNotePaperTemplate({
|
|||||||
</PaperTemplate.TermsItem>
|
</PaperTemplate.TermsItem>
|
||||||
)}
|
)}
|
||||||
</PaperTemplate.TermsList>
|
</PaperTemplate.TermsList>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{companyLogoUri && showCompanyLogo && (
|
||||||
|
<PaperTemplate.Logo logoUri={companyLogoUri} />
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
|
||||||
<PaperTemplate.AddressesGroup>
|
<PaperTemplate.AddressesGroup>
|
||||||
{showCompanyAddress && (
|
{showCompanyAddress && (
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export const initialValues = {
|
|||||||
// Address
|
// Address
|
||||||
showCustomerAddress: true,
|
showCustomerAddress: true,
|
||||||
showCompanyAddress: true,
|
showCompanyAddress: true,
|
||||||
companyAddress: '',
|
|
||||||
billedToLabel: 'Billed To',
|
billedToLabel: 'Billed To',
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
@@ -62,12 +61,12 @@ export const fieldsGroups = [
|
|||||||
label: 'Credit Note #',
|
label: 'Credit Note #',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enableKey: 'showBilledToAddress',
|
enableKey: 'showCustomerAddress',
|
||||||
labelKey: 'billedToLabel',
|
labelKey: 'billedToLabel',
|
||||||
label: 'Bill To',
|
label: 'Bill To',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enableKey: 'showBilledFromAddress',
|
enableKey: 'showCompanyAddress',
|
||||||
label: 'Billed From',
|
label: 'Billed From',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { BrandingTemplateValues } from '@/containers/BrandingTemplates/types';
|
import { BrandingState, BrandingTemplateValues } from '@/containers/BrandingTemplates/types';
|
||||||
|
|
||||||
|
export interface CreditNoteBrandingState extends BrandingState {}
|
||||||
|
|
||||||
export interface CreditNoteCustomizeValues extends BrandingTemplateValues {
|
export interface CreditNoteCustomizeValues extends BrandingTemplateValues {
|
||||||
// Colors
|
// Colors
|
||||||
|
|||||||
@@ -12,21 +12,30 @@ import {
|
|||||||
Menu,
|
Menu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { If, Icon, FormattedMessage as T, Group, FSelect } from '@/components';
|
import {
|
||||||
import { CLASSES } from '@/constants/classes';
|
If,
|
||||||
import classNames from 'classnames';
|
Icon,
|
||||||
|
FormattedMessage as T,
|
||||||
|
Group,
|
||||||
|
FSelect,
|
||||||
|
PageForm,
|
||||||
|
} from '@/components';
|
||||||
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
||||||
import {
|
import {
|
||||||
BrandingThemeFormGroup,
|
BrandingThemeFormGroup,
|
||||||
BrandingThemeSelectButton,
|
BrandingThemeSelectButton,
|
||||||
} from '@/containers/BrandingTemplates/BrandingTemplatesSelectFields';
|
} from '@/containers/BrandingTemplates/BrandingTemplatesSelectFields';
|
||||||
import { useCreditNoteFormBrandingTemplatesOptions } from './utils';
|
import { useCreditNoteFormBrandingTemplatesOptions } from './utils';
|
||||||
|
import { MoreIcon } from '@/icons/More';
|
||||||
|
import { useDrawerActions } from '@/hooks/state';
|
||||||
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note floating actions.
|
* Credit note floating actions.
|
||||||
*/
|
*/
|
||||||
export default function CreditNoteFloatingActions() {
|
export default function CreditNoteFloatingActions() {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const { openDrawer } = useDrawerActions();
|
||||||
|
|
||||||
// Formik context.
|
// Formik context.
|
||||||
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
||||||
@@ -79,13 +88,16 @@ export default function CreditNoteFloatingActions() {
|
|||||||
resetForm();
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handles the credit note customize button click.
|
||||||
|
const handleCustomizeBtnClick = () => {
|
||||||
|
openDrawer(DRAWERS.BRANDING_TEMPLATES, { resource: 'CreditNote' });
|
||||||
|
};
|
||||||
|
|
||||||
const brandingTemplatesOptions = useCreditNoteFormBrandingTemplatesOptions();
|
const brandingTemplatesOptions = useCreditNoteFormBrandingTemplatesOptions();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group
|
<PageForm.FooterActions position={'apart'} spacing={20}>
|
||||||
spacing={10}
|
<Group spacing={10}>
|
||||||
className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}
|
|
||||||
>
|
|
||||||
{/* ----------- Save And Open ----------- */}
|
{/* ----------- Save And Open ----------- */}
|
||||||
<If condition={!creditNote || !creditNote?.is_open}>
|
<If condition={!creditNote || !creditNote?.is_open}>
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
@@ -197,7 +209,9 @@ export default function CreditNoteFloatingActions() {
|
|||||||
onClick={handleCancelBtnClick}
|
onClick={handleCancelBtnClick}
|
||||||
text={<T id={'cancel'} />}
|
text={<T id={'cancel'} />}
|
||||||
/>
|
/>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Group spacing={0}>
|
||||||
{/* ----------- Branding Template Select ----------- */}
|
{/* ----------- Branding Template Select ----------- */}
|
||||||
<BrandingThemeFormGroup
|
<BrandingThemeFormGroup
|
||||||
name={'pdf_template_id'}
|
name={'pdf_template_id'}
|
||||||
@@ -216,6 +230,27 @@ export default function CreditNoteFloatingActions() {
|
|||||||
popoverProps={{ minimal: true }}
|
popoverProps={{ minimal: true }}
|
||||||
/>
|
/>
|
||||||
</BrandingThemeFormGroup>
|
</BrandingThemeFormGroup>
|
||||||
|
|
||||||
|
{/* ----------- Setting Select ----------- */}
|
||||||
|
<Popover
|
||||||
|
minimal={true}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.TOP_RIGHT}
|
||||||
|
modifiers={{
|
||||||
|
offset: { offset: '0, 4' },
|
||||||
|
}}
|
||||||
|
content={
|
||||||
|
<Menu>
|
||||||
|
<MenuItem
|
||||||
|
text={'Customize Templates'}
|
||||||
|
onClick={handleCustomizeBtnClick}
|
||||||
|
/>
|
||||||
|
</Menu>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button minimal icon={<MoreIcon height={'14px'} width={'14px'} />} />
|
||||||
|
</Popover>
|
||||||
</Group>
|
</Group>
|
||||||
|
</PageForm.FooterActions>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { Formik, Form } from 'formik';
|
import { Formik, Form } from 'formik';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { defaultTo, isEmpty } from 'lodash';
|
import { defaultTo, isEmpty } from 'lodash';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { css } from '@emotion/css';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CreateCreditNoteFormSchema,
|
CreateCreditNoteFormSchema,
|
||||||
EditCreditNoteFormSchema,
|
EditCreditNoteFormSchema,
|
||||||
@@ -42,6 +42,7 @@ import {
|
|||||||
CreditNoteExchangeRateSync,
|
CreditNoteExchangeRateSync,
|
||||||
CreditNoteSyncIncrementSettingsToForm,
|
CreditNoteSyncIncrementSettingsToForm,
|
||||||
} from './components';
|
} from './components';
|
||||||
|
import { PageForm } from '@/components/PageForm';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note form.
|
* Credit note form.
|
||||||
@@ -67,6 +68,7 @@ function CreditNoteForm({
|
|||||||
newCreditNote,
|
newCreditNote,
|
||||||
createCreditNoteMutate,
|
createCreditNoteMutate,
|
||||||
editCreditNoteMutate,
|
editCreditNoteMutate,
|
||||||
|
creditNoteState,
|
||||||
} = useCreditNoteFormContext();
|
} = useCreditNoteFormContext();
|
||||||
|
|
||||||
// Credit number.
|
// Credit number.
|
||||||
@@ -85,6 +87,7 @@ function CreditNoteForm({
|
|||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
terms_conditions: defaultTo(creditTermsConditions, ''),
|
terms_conditions: defaultTo(creditTermsConditions, ''),
|
||||||
note: defaultTo(creditCustomerNotes, ''),
|
note: defaultTo(creditCustomerNotes, ''),
|
||||||
|
pdf_template_id: creditNoteState?.defaultTemplateId,
|
||||||
...newCreditNote,
|
...newCreditNote,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -146,13 +149,6 @@ function CreditNoteForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
CLASSES.PAGE_FORM,
|
|
||||||
CLASSES.PAGE_FORM_STRIP_STYLE,
|
|
||||||
CLASSES.PAGE_FORM_CREDIT_NOTE,
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Formik
|
<Formik
|
||||||
validationSchema={
|
validationSchema={
|
||||||
isNewMode ? CreateCreditNoteFormSchema : EditCreditNoteFormSchema
|
isNewMode ? CreateCreditNoteFormSchema : EditCreditNoteFormSchema
|
||||||
@@ -160,12 +156,26 @@ function CreditNoteForm({
|
|||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
<Form>
|
<Form
|
||||||
|
className={css({
|
||||||
|
overflow: 'hidden',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
flex: 1,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<PageForm flex="1">
|
||||||
|
<PageForm.Body>
|
||||||
<CreditNoteFormTopBar />
|
<CreditNoteFormTopBar />
|
||||||
<CreditNoteFormHeader />
|
<CreditNoteFormHeader />
|
||||||
<CreditNoteItemsEntriesEditorField />
|
<CreditNoteItemsEntriesEditorField />
|
||||||
<CreditNoteFormFooter />
|
<CreditNoteFormFooter />
|
||||||
|
</PageForm.Body>
|
||||||
|
|
||||||
|
<PageForm.Footer>
|
||||||
<CreditNoteFloatingActions />
|
<CreditNoteFloatingActions />
|
||||||
|
</PageForm.Footer>
|
||||||
|
</PageForm>
|
||||||
|
|
||||||
{/*-------- Dialogs --------*/}
|
{/*-------- Dialogs --------*/}
|
||||||
<CreditNoteFormDialogs />
|
<CreditNoteFormDialogs />
|
||||||
@@ -175,7 +185,6 @@ function CreditNoteForm({
|
|||||||
<CreditNoteExchangeRateSync />
|
<CreditNoteExchangeRateSync />
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default compose(
|
export default compose(
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { Row, Col, Paper, Stack } from '@/components';
|
||||||
import { Row, Col, Paper } from '@/components';
|
|
||||||
import { CreditNoteFormFooterLeft } from './CreditNoteFormFooterLeft';
|
import { CreditNoteFormFooterLeft } from './CreditNoteFormFooterLeft';
|
||||||
import { CreditNoteFormFooterRight } from './CreditNoteFormFooterRight';
|
import { CreditNoteFormFooterRight } from './CreditNoteFormFooterRight';
|
||||||
import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmentButton';
|
import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmentButton';
|
||||||
@@ -14,8 +11,8 @@ import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmen
|
|||||||
*/
|
*/
|
||||||
export default function CreditNoteFormFooter() {
|
export default function CreditNoteFormFooter() {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
<Stack mt={'20px'} px={'32px'} pb={'20px'} flex={1}>
|
||||||
<CreditNoteFooterPaper>
|
<Paper p={'20px'}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
<CreditNoteFormFooterLeft />
|
<CreditNoteFormFooterLeft />
|
||||||
@@ -26,10 +23,7 @@ export default function CreditNoteFormFooter() {
|
|||||||
<CreditNoteFormFooterRight />
|
<CreditNoteFormFooterRight />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</CreditNoteFooterPaper>
|
</Paper>
|
||||||
</div>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const CreditNoteFooterPaper = styled(Paper)`
|
|
||||||
padding: 20px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,23 +1,28 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { CLASSES } from '@/constants/classes';
|
|
||||||
import CreditNoteFormHeaderFields from './CreditNoteFormHeaderFields';
|
import CreditNoteFormHeaderFields from './CreditNoteFormHeaderFields';
|
||||||
|
|
||||||
import { getEntriesTotal } from '@/containers/Entries/utils';
|
import { getEntriesTotal } from '@/containers/Entries/utils';
|
||||||
import { PageFormBigNumber } from '@/components';
|
import { Group, PageFormBigNumber } from '@/components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note header.
|
* Credit note header.
|
||||||
*/
|
*/
|
||||||
function CreditNoteFormHeader() {
|
function CreditNoteFormHeader() {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
<Group
|
||||||
|
position="apart"
|
||||||
|
align={'flex-start'}
|
||||||
|
display="flex"
|
||||||
|
bg="white"
|
||||||
|
p="25px 32px"
|
||||||
|
borderBottom="1px solid #d2dce2"
|
||||||
|
>
|
||||||
<CreditNoteFormHeaderFields />
|
<CreditNoteFormHeaderFields />
|
||||||
<CreditNoteFormBigNumber />
|
<CreditNoteFormBigNumber />
|
||||||
</div>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import styled from 'styled-components';
|
|||||||
import { FormGroup, InputGroup, Position } from '@blueprintjs/core';
|
import { FormGroup, InputGroup, Position } from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
||||||
|
import { css } from '@emotion/css';
|
||||||
|
import { useTheme } from '@emotion/react';
|
||||||
|
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import {
|
import {
|
||||||
@@ -14,26 +16,41 @@ import {
|
|||||||
CustomerDrawerLink,
|
CustomerDrawerLink,
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
CustomersSelect,
|
CustomersSelect,
|
||||||
|
Stack,
|
||||||
|
FDateInput,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { customerNameFieldShouldUpdate } from './utils';
|
import { customerNameFieldShouldUpdate } from './utils';
|
||||||
|
|
||||||
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
||||||
import { CreditNoteExchangeRateInputField } from './components';
|
import { CreditNoteExchangeRateInputField } from './components';
|
||||||
import { CreditNoteTransactionNoField } from './CreditNoteTransactionNoField';
|
import { CreditNoteTransactionNoField } from './CreditNoteTransactionNoField';
|
||||||
import {
|
|
||||||
momentFormatter,
|
|
||||||
tansformDateValue,
|
|
||||||
inputIntent,
|
|
||||||
handleDateChange,
|
|
||||||
} from '@/utils';
|
|
||||||
import { useCustomerUpdateExRate } from '@/containers/Entries/withExRateItemEntriesPriceRecalc';
|
import { useCustomerUpdateExRate } from '@/containers/Entries/withExRateItemEntriesPriceRecalc';
|
||||||
|
|
||||||
|
const getCreditNoteFieldsStyle = (theme: Theme) => css`
|
||||||
|
.${theme.bpPrefix}-form-group {
|
||||||
|
margin-bottom: 0;
|
||||||
|
|
||||||
|
&.${theme.bpPrefix}-inline {
|
||||||
|
max-width: 450px;
|
||||||
|
}
|
||||||
|
.${theme.bpPrefix}-label {
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
|
.${theme.bpPrefix}-form-content {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note form header fields.
|
* Credit note form header fields.
|
||||||
*/
|
*/
|
||||||
export default function CreditNoteFormHeaderFields({}) {
|
export default function CreditNoteFormHeaderFields() {
|
||||||
|
const theme = useTheme();
|
||||||
|
const styleClassName = getCreditNoteFieldsStyle(theme);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER_FIELDS)}>
|
<Stack spacing={18} flex={1} className={styleClassName}>
|
||||||
{/* ----------- Customer name ----------- */}
|
{/* ----------- Customer name ----------- */}
|
||||||
<CreditNoteCustomersSelect />
|
<CreditNoteCustomersSelect />
|
||||||
|
|
||||||
@@ -41,48 +58,35 @@ export default function CreditNoteFormHeaderFields({}) {
|
|||||||
<CreditNoteExchangeRateInputField />
|
<CreditNoteExchangeRateInputField />
|
||||||
|
|
||||||
{/* ----------- Credit note date ----------- */}
|
{/* ----------- Credit note date ----------- */}
|
||||||
<FastField name={'credit_note_date'}>
|
<FFormGroup
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
name={'credit_note_date'}
|
||||||
<FormGroup
|
|
||||||
label={<T id={'credit_note.label_credit_note_date'} />}
|
label={<T id={'credit_note.label_credit_note_date'} />}
|
||||||
inline={true}
|
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
className={classNames('form-group--credit_note_date', CLASSES.FILL)}
|
inline
|
||||||
intent={inputIntent({ error, touched })}
|
fastField
|
||||||
helperText={<ErrorMessage name="credit_note_date" />}
|
|
||||||
>
|
>
|
||||||
<DateInput
|
<FDateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
name={'credit_note_date'}
|
||||||
value={tansformDateValue(value)}
|
formatDate={(date) => date.toLocaleDateString()}
|
||||||
onChange={handleDateChange((formattedDate) => {
|
parseDate={(str) => new Date(str)}
|
||||||
form.setFieldValue('credit_note_date', formattedDate);
|
|
||||||
})}
|
|
||||||
popoverProps={{ position: Position.BOTTOM_LEFT, minimal: true }}
|
popoverProps={{ position: Position.BOTTOM_LEFT, minimal: true }}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
leftIcon: <Icon icon={'date-range'} />,
|
leftIcon: <Icon icon={'date-range'} />,
|
||||||
|
fill: true
|
||||||
}}
|
}}
|
||||||
|
fill
|
||||||
|
fastField
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FFormGroup>
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
{/* ----------- Credit note # ----------- */}
|
{/* ----------- Credit note # ----------- */}
|
||||||
<CreditNoteTransactionNoField />
|
<CreditNoteTransactionNoField />
|
||||||
|
|
||||||
{/* ----------- Reference ----------- */}
|
{/* ----------- Reference ----------- */}
|
||||||
<FastField name={'reference_no'}>
|
<FormGroup label={<T id={'reference_no'} />} name={'reference_no'} inline>
|
||||||
{({ field, meta: { error, touched } }) => (
|
<InputGroup name={'reference_no'} minimal />
|
||||||
<FormGroup
|
|
||||||
label={<T id={'reference_no'} />}
|
|
||||||
inline={true}
|
|
||||||
className={classNames('form-group--reference', CLASSES.FILL)}
|
|
||||||
intent={inputIntent({ error, touched })}
|
|
||||||
helperText={<ErrorMessage name="reference_no" />}
|
|
||||||
>
|
|
||||||
<InputGroup minimal={true} {...field} />
|
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
</Stack>
|
||||||
</FastField>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
import { css } from '@emotion/css';
|
||||||
import '@/style/pages/CreditNote/PageForm.scss';
|
|
||||||
|
|
||||||
import CreditNoteForm from './CreditNoteForm';
|
import CreditNoteForm from './CreditNoteForm';
|
||||||
import { CreditNoteFormProvider } from './CreditNoteFormProvider';
|
import {
|
||||||
|
CreditNoteFormProvider,
|
||||||
|
useCreditNoteFormContext,
|
||||||
|
} from './CreditNoteFormProvider';
|
||||||
import { AutoExchangeRateProvider } from '@/containers/Entries/AutoExchangeProvider';
|
import { AutoExchangeRateProvider } from '@/containers/Entries/AutoExchangeProvider';
|
||||||
|
import { DashboardInsider } from '@/components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note form page.
|
* Credit note form page.
|
||||||
@@ -18,8 +20,24 @@ export default function CreditNoteFormPage() {
|
|||||||
return (
|
return (
|
||||||
<CreditNoteFormProvider creditNoteId={idAsInteger}>
|
<CreditNoteFormProvider creditNoteId={idAsInteger}>
|
||||||
<AutoExchangeRateProvider>
|
<AutoExchangeRateProvider>
|
||||||
<CreditNoteForm />
|
<CreditNoteFormPageContent />
|
||||||
</AutoExchangeRateProvider>
|
</AutoExchangeRateProvider>
|
||||||
</CreditNoteFormProvider>
|
</CreditNoteFormProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CreditNoteFormPageContent() {
|
||||||
|
const { isBootLoading } = useCreditNoteFormContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DashboardInsider
|
||||||
|
loading={isBootLoading}
|
||||||
|
className={css`
|
||||||
|
min-height: calc(100vh - var(--top-offset));
|
||||||
|
max-height: calc(100vh - var(--top-offset));
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
<CreditNoteForm />
|
||||||
|
</DashboardInsider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,10 +17,19 @@ import {
|
|||||||
useBranches,
|
useBranches,
|
||||||
useSettingsCreditNotes,
|
useSettingsCreditNotes,
|
||||||
useInvoice,
|
useInvoice,
|
||||||
|
useGetCreditNoteState,
|
||||||
|
CreditNoteStateResponse,
|
||||||
} from '@/hooks/query';
|
} from '@/hooks/query';
|
||||||
import { useGetPdfTemplates } from '@/hooks/query/pdf-templates';
|
import { useGetPdfTemplates } from '@/hooks/query/pdf-templates';
|
||||||
|
|
||||||
const CreditNoteFormContext = React.createContext();
|
interface CreditNoteFormProviderValue {
|
||||||
|
creditNoteState: CreditNoteStateResponse;
|
||||||
|
isCreditNoteStateLoading: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreditNoteFormContext = React.createContext<CreditNoteFormProviderValue>(
|
||||||
|
{} as CreditNoteFormProviderValue,
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note data provider.
|
* Credit note data provider.
|
||||||
@@ -76,7 +85,11 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
|
|||||||
|
|
||||||
// Fetches branding templates of invoice.
|
// Fetches branding templates of invoice.
|
||||||
const { data: brandingTemplates, isLoading: isBrandingTemplatesLoading } =
|
const { data: brandingTemplates, isLoading: isBrandingTemplatesLoading } =
|
||||||
useGetPdfTemplates({ resource: 'PaymentReceive' });
|
useGetPdfTemplates({ resource: 'CreditNote' });
|
||||||
|
|
||||||
|
// Fetches the credit note state.
|
||||||
|
const { data: creditNoteState, isLoading: isCreditNoteStateLoading } =
|
||||||
|
useGetCreditNoteState();
|
||||||
|
|
||||||
// Handle fetching settings.
|
// Handle fetching settings.
|
||||||
useSettingsCreditNotes();
|
useSettingsCreditNotes();
|
||||||
@@ -100,6 +113,13 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
|
|||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
const isBootLoading =
|
||||||
|
isItemsLoading ||
|
||||||
|
isCustomersLoading ||
|
||||||
|
isCreditNoteLoading ||
|
||||||
|
isInvoiceLoading ||
|
||||||
|
isBrandingTemplatesLoading;
|
||||||
|
|
||||||
// Provider payload.
|
// Provider payload.
|
||||||
const provider = {
|
const provider = {
|
||||||
items,
|
items,
|
||||||
@@ -124,22 +144,18 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
|
|||||||
// Branding templates.
|
// Branding templates.
|
||||||
brandingTemplates,
|
brandingTemplates,
|
||||||
isBrandingTemplatesLoading,
|
isBrandingTemplatesLoading,
|
||||||
|
|
||||||
|
// Credit note state
|
||||||
|
creditNoteState,
|
||||||
|
isCreditNoteStateLoading,
|
||||||
|
|
||||||
|
isBootLoading,
|
||||||
};
|
};
|
||||||
|
|
||||||
const isLoading =
|
return <CreditNoteFormContext.Provider value={provider} {...props} />;
|
||||||
isItemsLoading ||
|
|
||||||
isCustomersLoading ||
|
|
||||||
isCreditNoteLoading ||
|
|
||||||
isInvoiceLoading ||
|
|
||||||
isBrandingTemplatesLoading;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DashboardInsider loading={isLoading} name={'credit-note-form'}>
|
|
||||||
<CreditNoteFormContext.Provider value={provider} {...props} />
|
|
||||||
</DashboardInsider>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const useCreditNoteFormContext = () => React.useContext(CreditNoteFormContext);
|
const useCreditNoteFormContext = () =>
|
||||||
|
React.useContext<CreditNoteFormProviderValue>(CreditNoteFormContext);
|
||||||
|
|
||||||
export { CreditNoteFormProvider, useCreditNoteFormContext };
|
export { CreditNoteFormProvider, useCreditNoteFormContext };
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { FastField } from 'formik';
|
import { FastField } from 'formik';
|
||||||
import { CLASSES } from '@/constants/classes';
|
|
||||||
import ItemsEntriesTable from '@/containers/Entries/ItemsEntriesTable';
|
import ItemsEntriesTable from '@/containers/Entries/ItemsEntriesTable';
|
||||||
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
||||||
import { entriesFieldShouldUpdate } from './utils';
|
import { entriesFieldShouldUpdate } from './utils';
|
||||||
|
import { Box } from '@/components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note items entries editor field.
|
* Credit note items entries editor field.
|
||||||
@@ -14,7 +13,7 @@ export default function CreditNoteItemsEntriesEditorField() {
|
|||||||
const { items } = useCreditNoteFormContext();
|
const { items } = useCreditNoteFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
<Box p="18px 32px 0">
|
||||||
<FastField
|
<FastField
|
||||||
name={'entries'}
|
name={'entries'}
|
||||||
items={items}
|
items={items}
|
||||||
@@ -38,6 +37,6 @@ export default function CreditNoteItemsEntriesEditorField() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
</div>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { ElementCustomize } from '../../../ElementCustomize/ElementCustomize';
|
import {
|
||||||
|
ElementCustomize,
|
||||||
|
ElementCustomizeContent,
|
||||||
|
} from '../../../ElementCustomize/ElementCustomize';
|
||||||
import { EstimateCustomizeGeneralField } from './EstimateCustomizeFieldsGeneral';
|
import { EstimateCustomizeGeneralField } from './EstimateCustomizeFieldsGeneral';
|
||||||
import { EstimateCustomizeContentFields } from './EstimateCustomizeFieldsContent';
|
import { EstimateCustomizeContentFields } from './EstimateCustomizeFieldsContent';
|
||||||
import { EstimatePaperTemplate } from './EstimatePaperTemplate';
|
import {
|
||||||
import { EstimateCustomizeValues } from './types';
|
EstimatePaperTemplate,
|
||||||
|
EstimatePaperTemplateProps,
|
||||||
|
} from './EstimatePaperTemplate';
|
||||||
|
import { EstimateBrandingState, EstimateCustomizeValues } from './types';
|
||||||
import { initialValues } from './constants';
|
import { initialValues } from './constants';
|
||||||
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
||||||
import { useDrawerActions } from '@/hooks/state';
|
import { useDrawerActions } from '@/hooks/state';
|
||||||
import { BrandingTemplateForm } from '@/containers/BrandingTemplates/BrandingTemplateForm';
|
import { BrandingTemplateForm } from '@/containers/BrandingTemplates/BrandingTemplateForm';
|
||||||
|
import { useElementCustomizeContext } from '@/containers/ElementCustomize/ElementCustomizeProvider';
|
||||||
|
import { useIsTemplateNamedFilled } from '@/containers/BrandingTemplates/utils';
|
||||||
|
|
||||||
export function EstimateCustomizeContent() {
|
export function EstimateCustomizeContent() {
|
||||||
const { payload, name } = useDrawerContext();
|
const { payload, name } = useDrawerContext();
|
||||||
@@ -19,12 +27,22 @@ export function EstimateCustomizeContent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BrandingTemplateForm<EstimateCustomizeValues>
|
<BrandingTemplateForm<EstimateCustomizeValues, EstimateBrandingState>
|
||||||
templateId={templateId}
|
templateId={templateId}
|
||||||
defaultValues={initialValues}
|
defaultValues={initialValues}
|
||||||
onSuccess={handleSuccess}
|
onSuccess={handleSuccess}
|
||||||
resource={'SaleEstimate'}
|
resource={'SaleEstimate'}
|
||||||
>
|
>
|
||||||
|
<EstimateCustomizeFormContent />
|
||||||
|
</BrandingTemplateForm>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function EstimateCustomizeFormContent() {
|
||||||
|
const isTemplateNameFilled = useIsTemplateNamedFilled();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ElementCustomizeContent>
|
||||||
<ElementCustomize.PaperTemplate>
|
<ElementCustomize.PaperTemplate>
|
||||||
<EstimatePaperTemplateFormConnected />
|
<EstimatePaperTemplateFormConnected />
|
||||||
</ElementCustomize.PaperTemplate>
|
</ElementCustomize.PaperTemplate>
|
||||||
@@ -33,15 +51,29 @@ export function EstimateCustomizeContent() {
|
|||||||
<EstimateCustomizeGeneralField />
|
<EstimateCustomizeGeneralField />
|
||||||
</ElementCustomize.FieldsTab>
|
</ElementCustomize.FieldsTab>
|
||||||
|
|
||||||
<ElementCustomize.FieldsTab id={'content'} label={'Content'}>
|
<ElementCustomize.FieldsTab
|
||||||
|
id={'content'}
|
||||||
|
label={'Content'}
|
||||||
|
tabProps={{ disabled: !isTemplateNameFilled }}
|
||||||
|
>
|
||||||
<EstimateCustomizeContentFields />
|
<EstimateCustomizeContentFields />
|
||||||
</ElementCustomize.FieldsTab>
|
</ElementCustomize.FieldsTab>
|
||||||
</BrandingTemplateForm>
|
</ElementCustomizeContent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injects the `EstimatePaperTemplate` component props from the form and branding states.
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
function EstimatePaperTemplateFormConnected() {
|
function EstimatePaperTemplateFormConnected() {
|
||||||
const { values } = useFormikContext<EstimateCustomizeValues>();
|
const { values } = useFormikContext<EstimateCustomizeValues>();
|
||||||
|
const { brandingState } = useElementCustomizeContext();
|
||||||
|
|
||||||
return <EstimatePaperTemplate {...values} />;
|
const mergedProps: EstimatePaperTemplateProps = {
|
||||||
|
...brandingState,
|
||||||
|
...values,
|
||||||
|
};
|
||||||
|
|
||||||
|
return <EstimatePaperTemplate {...mergedProps} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box, Stack } from '@/components';
|
import { Box, Group, Stack } from '@/components';
|
||||||
import {
|
import {
|
||||||
PaperTemplate,
|
PaperTemplate,
|
||||||
PaperTemplateProps,
|
PaperTemplateProps,
|
||||||
@@ -13,6 +13,10 @@ import {
|
|||||||
} from '@/constants/PdfTemplates';
|
} from '@/constants/PdfTemplates';
|
||||||
|
|
||||||
export interface EstimatePaperTemplateProps extends PaperTemplateProps {
|
export interface EstimatePaperTemplateProps extends PaperTemplateProps {
|
||||||
|
// # Company
|
||||||
|
showCompanyLogo?: boolean;
|
||||||
|
companyLogoUri?: string;
|
||||||
|
|
||||||
// # Estimate number
|
// # Estimate number
|
||||||
estimateNumebr?: string;
|
estimateNumebr?: string;
|
||||||
estimateNumberLabel?: string;
|
estimateNumberLabel?: string;
|
||||||
@@ -132,14 +136,12 @@ export function EstimatePaperTemplate({
|
|||||||
expirationDate = 'September 3, 2024',
|
expirationDate = 'September 3, 2024',
|
||||||
}: EstimatePaperTemplateProps) {
|
}: EstimatePaperTemplateProps) {
|
||||||
return (
|
return (
|
||||||
<PaperTemplate
|
<PaperTemplate primaryColor={primaryColor} secondaryColor={secondaryColor}>
|
||||||
primaryColor={primaryColor}
|
|
||||||
secondaryColor={secondaryColor}
|
|
||||||
showCompanyLogo={showCompanyLogo}
|
|
||||||
companyLogoUri={companyLogoUri}
|
|
||||||
bigtitle={'Estimate'}
|
|
||||||
>
|
|
||||||
<Stack spacing={24}>
|
<Stack spacing={24}>
|
||||||
|
<Group align={'start'} spacing={10}>
|
||||||
|
<Stack flex={1}>
|
||||||
|
<PaperTemplate.BigTitle title={'Estimate'} />
|
||||||
|
|
||||||
<PaperTemplate.TermsList>
|
<PaperTemplate.TermsList>
|
||||||
{showEstimateNumber && (
|
{showEstimateNumber && (
|
||||||
<PaperTemplate.TermsItem label={estimateNumberLabel}>
|
<PaperTemplate.TermsItem label={estimateNumberLabel}>
|
||||||
@@ -157,6 +159,12 @@ export function EstimatePaperTemplate({
|
|||||||
</PaperTemplate.TermsItem>
|
</PaperTemplate.TermsItem>
|
||||||
)}
|
)}
|
||||||
</PaperTemplate.TermsList>
|
</PaperTemplate.TermsList>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{companyLogoUri && showCompanyLogo && (
|
||||||
|
<PaperTemplate.Logo logoUri={companyLogoUri} />
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
|
||||||
<PaperTemplate.AddressesGroup>
|
<PaperTemplate.AddressesGroup>
|
||||||
{showCompanyAddress && (
|
{showCompanyAddress && (
|
||||||
|
|||||||
@@ -20,15 +20,11 @@ export const initialValues = {
|
|||||||
showExpirationDate: true,
|
showExpirationDate: true,
|
||||||
expirationDateLabel: 'Expiration Date',
|
expirationDateLabel: 'Expiration Date',
|
||||||
|
|
||||||
// Company name
|
|
||||||
companyName: 'Bigcapital Technology, Inc.',
|
|
||||||
|
|
||||||
// Customer address
|
// Customer address
|
||||||
showCustomerAddress: true,
|
showCustomerAddress: true,
|
||||||
|
|
||||||
// Company address
|
// Company address
|
||||||
showCompanyAddress: true,
|
showCompanyAddress: true,
|
||||||
companyAddress: '',
|
|
||||||
billedToLabel: 'Billed To',
|
billedToLabel: 'Billed To',
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
@@ -73,12 +69,12 @@ export const fieldsGroups = [
|
|||||||
label: 'Expiration Date',
|
label: 'Expiration Date',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enableKey: 'showBilledToAddress',
|
enableKey: 'showCustomerAddress',
|
||||||
labelKey: 'billedToLabel',
|
labelKey: 'billedToLabel',
|
||||||
label: 'Bill To',
|
label: 'Bill To',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enableKey: 'showBilledFromAddress',
|
enableKey: 'showCompanyAddress',
|
||||||
label: 'Billed From',
|
label: 'Billed From',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { BrandingTemplateValues } from '@/containers/BrandingTemplates/types';
|
import { BrandingState, BrandingTemplateValues } from '@/containers/BrandingTemplates/types';
|
||||||
|
|
||||||
|
export interface EstimateBrandingState extends BrandingState {}
|
||||||
|
|
||||||
export interface EstimateCustomizeValues extends BrandingTemplateValues {
|
export interface EstimateCustomizeValues extends BrandingTemplateValues {
|
||||||
// Colors
|
// Colors
|
||||||
@@ -20,9 +22,6 @@ export interface EstimateCustomizeValues extends BrandingTemplateValues {
|
|||||||
estimateDateLabel?: string;
|
estimateDateLabel?: string;
|
||||||
showEstimateDate?: boolean;
|
showEstimateDate?: boolean;
|
||||||
|
|
||||||
// Company name
|
|
||||||
companyName?: string;
|
|
||||||
|
|
||||||
// Addresses
|
// Addresses
|
||||||
showBilledFromAddress?: boolean;
|
showBilledFromAddress?: boolean;
|
||||||
showBillingToAddress?: boolean;
|
showBillingToAddress?: boolean;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
|
||||||
import {
|
import {
|
||||||
Intent,
|
Intent,
|
||||||
Button,
|
Button,
|
||||||
@@ -12,21 +11,25 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { If, Icon, FormattedMessage as T, Group, FSelect } from '@/components';
|
import { If, Icon, FormattedMessage as T, Group, FSelect } from '@/components';
|
||||||
import { CLASSES } from '@/constants/classes';
|
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { useEstimateFormContext } from './EstimateFormProvider';
|
import { useEstimateFormContext } from './EstimateFormProvider';
|
||||||
import { useEstimateFormBrandingTemplatesOptions } from './utils';
|
import { useEstimateFormBrandingTemplatesOptions } from './utils';
|
||||||
|
import { useDrawerActions } from '@/hooks/state';
|
||||||
import {
|
import {
|
||||||
BrandingThemeFormGroup,
|
BrandingThemeFormGroup,
|
||||||
BrandingThemeSelectButton,
|
BrandingThemeSelectButton,
|
||||||
} from '@/containers/BrandingTemplates/BrandingTemplatesSelectFields';
|
} from '@/containers/BrandingTemplates/BrandingTemplatesSelectFields';
|
||||||
|
import { PageForm } from '@/components/PageForm';
|
||||||
|
import { MoreIcon } from '@/icons/More';
|
||||||
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate floating actions bar.
|
* Estimate floating actions bar.
|
||||||
*/
|
*/
|
||||||
export default function EstimateFloatingActions() {
|
export default function EstimateFloatingActions() {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const { openDrawer } = useDrawerActions();
|
||||||
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
||||||
|
|
||||||
// Estimate form context.
|
// Estimate form context.
|
||||||
@@ -78,13 +81,16 @@ export default function EstimateFloatingActions() {
|
|||||||
resetForm();
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handles the invoice customize button click.
|
||||||
|
const handleCustomizeBtnClick = () => {
|
||||||
|
openDrawer(DRAWERS.BRANDING_TEMPLATES, { resource: 'SaleEstimate' });
|
||||||
|
};
|
||||||
|
|
||||||
const brandingTemplatesOptions = useEstimateFormBrandingTemplatesOptions();
|
const brandingTemplatesOptions = useEstimateFormBrandingTemplatesOptions();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group
|
<PageForm.FooterActions position={'apart'} spacing={10}>
|
||||||
spacing={10}
|
<Group spacing={10}>
|
||||||
className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}
|
|
||||||
>
|
|
||||||
{/* ----------- Save And Deliver ----------- */}
|
{/* ----------- Save And Deliver ----------- */}
|
||||||
<If condition={!estimate || !estimate?.is_delivered}>
|
<If condition={!estimate || !estimate?.is_delivered}>
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
@@ -200,7 +206,9 @@ export default function EstimateFloatingActions() {
|
|||||||
onClick={handleCancelBtnClick}
|
onClick={handleCancelBtnClick}
|
||||||
text={<T id={'cancel'} />}
|
text={<T id={'cancel'} />}
|
||||||
/>
|
/>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Group spacing={0}>
|
||||||
{/* ----------- Branding Template Select ----------- */}
|
{/* ----------- Branding Template Select ----------- */}
|
||||||
<BrandingThemeFormGroup
|
<BrandingThemeFormGroup
|
||||||
name={'pdf_template_id'}
|
name={'pdf_template_id'}
|
||||||
@@ -219,6 +227,27 @@ export default function EstimateFloatingActions() {
|
|||||||
popoverProps={{ minimal: true }}
|
popoverProps={{ minimal: true }}
|
||||||
/>
|
/>
|
||||||
</BrandingThemeFormGroup>
|
</BrandingThemeFormGroup>
|
||||||
|
|
||||||
|
{/* ----------- More Select ----------- */}
|
||||||
|
<Popover
|
||||||
|
minimal={true}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.TOP_RIGHT}
|
||||||
|
modifiers={{
|
||||||
|
offset: { offset: '0, 4' },
|
||||||
|
}}
|
||||||
|
content={
|
||||||
|
<Menu>
|
||||||
|
<MenuItem
|
||||||
|
text={'Customize Templates'}
|
||||||
|
onClick={handleCustomizeBtnClick}
|
||||||
|
/>
|
||||||
|
</Menu>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button minimal icon={<MoreIcon height={'14px'} width={'14px'} />} />
|
||||||
|
</Popover>
|
||||||
</Group>
|
</Group>
|
||||||
|
</PageForm.FooterActions>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import classNames from 'classnames';
|
import { css } from '@emotion/css';
|
||||||
import { Formik, Form } from 'formik';
|
import { Formik, Form } from 'formik';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { sumBy, isEmpty, defaultTo } from 'lodash';
|
import { sumBy, isEmpty, defaultTo } from 'lodash';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { CLASSES } from '@/constants/classes';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CreateEstimateFormSchema,
|
CreateEstimateFormSchema,
|
||||||
@@ -36,8 +35,9 @@ import {
|
|||||||
handleErrors,
|
handleErrors,
|
||||||
resetFormState,
|
resetFormState,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
import { PageForm } from '@/components/PageForm';
|
||||||
|
|
||||||
/**
|
/**6
|
||||||
* Estimate form.
|
* Estimate form.
|
||||||
*/
|
*/
|
||||||
function EstimateForm({
|
function EstimateForm({
|
||||||
@@ -58,6 +58,7 @@ function EstimateForm({
|
|||||||
submitPayload,
|
submitPayload,
|
||||||
createEstimateMutate,
|
createEstimateMutate,
|
||||||
editEstimateMutate,
|
editEstimateMutate,
|
||||||
|
saleEstimateState,
|
||||||
} = useEstimateFormContext();
|
} = useEstimateFormContext();
|
||||||
|
|
||||||
const estimateNumber = transactionNumber(
|
const estimateNumber = transactionNumber(
|
||||||
@@ -79,6 +80,7 @@ function EstimateForm({
|
|||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
terms_conditions: defaultTo(estimateTermsConditions, ''),
|
terms_conditions: defaultTo(estimateTermsConditions, ''),
|
||||||
note: defaultTo(estimateCustomerNotes, ''),
|
note: defaultTo(estimateCustomerNotes, ''),
|
||||||
|
pdf_template_id: saleEstimateState?.defaultTemplateId,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -146,13 +148,6 @@ function EstimateForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
CLASSES.PAGE_FORM,
|
|
||||||
CLASSES.PAGE_FORM_STRIP_STYLE,
|
|
||||||
CLASSES.PAGE_FORM_ESTIMATE,
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Formik
|
<Formik
|
||||||
validationSchema={
|
validationSchema={
|
||||||
isNewMode ? CreateEstimateFormSchema : EditEstimateFormSchema
|
isNewMode ? CreateEstimateFormSchema : EditEstimateFormSchema
|
||||||
@@ -160,12 +155,26 @@ function EstimateForm({
|
|||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
<Form>
|
<Form
|
||||||
|
className={css({
|
||||||
|
overflow: 'hidden',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
flex: 1
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<PageForm flex={1}>
|
||||||
|
<PageForm.Body>
|
||||||
<EstimtaeFormTopBar />
|
<EstimtaeFormTopBar />
|
||||||
<EstimateFormHeader />
|
<EstimateFormHeader />
|
||||||
<EstimateItemsEntriesField />
|
<EstimateItemsEntriesField />
|
||||||
<EstimateFormFooter />
|
<EstimateFormFooter />
|
||||||
|
</PageForm.Body>
|
||||||
|
|
||||||
|
<PageForm.Footer>
|
||||||
<EstimateFloatingActions />
|
<EstimateFloatingActions />
|
||||||
|
</PageForm.Footer>
|
||||||
|
</PageForm>
|
||||||
|
|
||||||
{/*------- Dialogs -------*/}
|
{/*------- Dialogs -------*/}
|
||||||
<EstimateFormDialogs />
|
<EstimateFormDialogs />
|
||||||
@@ -175,7 +184,6 @@ function EstimateForm({
|
|||||||
<EstimateSyncAutoExRateToForm />
|
<EstimateSyncAutoExRateToForm />
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import { x } from '@xstyled/emotion';
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import { CLASSES } from '@/constants/classes';
|
|
||||||
import { Row, Col, Paper } from '@/components';
|
import { Row, Col, Paper } from '@/components';
|
||||||
import { EstimateFormFooterLeft } from './EstimateFormFooterLeft';
|
import { EstimateFormFooterLeft } from './EstimateFormFooterLeft';
|
||||||
import { EstimateFormFooterRight } from './EstimateFormFooterRight';
|
import { EstimateFormFooterRight } from './EstimateFormFooterRight';
|
||||||
@@ -14,8 +12,8 @@ import { UploadAttachmentButton } from '@/containers/Attachments/UploadAttachmen
|
|||||||
*/
|
*/
|
||||||
export default function EstiamteFormFooter() {
|
export default function EstiamteFormFooter() {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
|
<x.div mt={'20px'} px={'32px'} pb={'20px'} flex={1}>
|
||||||
<EstimateFooterPaper>
|
<Paper p={'20px'}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
<EstimateFormFooterLeft />
|
<EstimateFormFooterLeft />
|
||||||
@@ -26,11 +24,7 @@ export default function EstiamteFormFooter() {
|
|||||||
<EstimateFormFooterRight />
|
<EstimateFormFooterRight />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</EstimateFooterPaper>
|
</Paper>
|
||||||
</div>
|
</x.div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const EstimateFooterPaper = styled(Paper)`
|
|
||||||
padding: 20px;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { x } from '@xstyled/emotion';
|
||||||
|
|
||||||
import EstimateFormHeaderFields from './EstimateFormHeaderFields';
|
import EstimateFormHeaderFields from './EstimateFormHeaderFields';
|
||||||
|
|
||||||
import { getEntriesTotal } from '@/containers/Entries/utils';
|
import { getEntriesTotal } from '@/containers/Entries/utils';
|
||||||
import { PageFormBigNumber } from '@/components';
|
import { Group, PageFormBigNumber } from '@/components';
|
||||||
|
|
||||||
// Estimate form top header.
|
// Estimate form top header.
|
||||||
function EstimateFormHeader() {
|
function EstimateFormHeader() {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
<Group
|
||||||
|
position="apart"
|
||||||
|
align={'flex-start'}
|
||||||
|
bg="white"
|
||||||
|
p="25px 32px"
|
||||||
|
borderBottom="1px solid #d2dce2"
|
||||||
|
>
|
||||||
<EstimateFormHeaderFields />
|
<EstimateFormHeaderFields />
|
||||||
<EstimateFormBigTotal />
|
<EstimateFormBigTotal />
|
||||||
</div>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormGroup, InputGroup, Position, Classes } from '@blueprintjs/core';
|
import { Position, Classes } from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { useFormikContext } from 'formik';
|
||||||
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
import { css } from '@emotion/css';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FeatureCan,
|
FeatureCan,
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
@@ -13,15 +12,11 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
CustomerDrawerLink,
|
CustomerDrawerLink,
|
||||||
CustomersSelect,
|
CustomersSelect,
|
||||||
|
FInputGroup,
|
||||||
|
Stack,
|
||||||
|
FDateInput,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import {
|
|
||||||
momentFormatter,
|
|
||||||
tansformDateValue,
|
|
||||||
inputIntent,
|
|
||||||
handleDateChange,
|
|
||||||
} from '@/utils';
|
|
||||||
import { customersFieldShouldUpdate } from './utils';
|
import { customersFieldShouldUpdate } from './utils';
|
||||||
import { CLASSES } from '@/constants/classes';
|
|
||||||
import { Features } from '@/constants';
|
import { Features } from '@/constants';
|
||||||
import { ProjectsSelect } from '@/containers/Projects/components';
|
import { ProjectsSelect } from '@/containers/Projects/components';
|
||||||
import {
|
import {
|
||||||
@@ -31,15 +26,36 @@ import {
|
|||||||
import { EstimateFormEstimateNumberField } from './EstimateFormEstimateNumberField';
|
import { EstimateFormEstimateNumberField } from './EstimateFormEstimateNumberField';
|
||||||
import { useEstimateFormContext } from './EstimateFormProvider';
|
import { useEstimateFormContext } from './EstimateFormProvider';
|
||||||
import { useCustomerUpdateExRate } from '@/containers/Entries/withExRateItemEntriesPriceRecalc';
|
import { useCustomerUpdateExRate } from '@/containers/Entries/withExRateItemEntriesPriceRecalc';
|
||||||
|
import { useTheme } from '@emotion/react';
|
||||||
|
import { Theme } from '@xstyled/emotion';
|
||||||
|
|
||||||
|
const getEstimateFieldsStyle = (theme: Theme) => css`
|
||||||
|
.${theme.bpPrefix}-form-group {
|
||||||
|
margin-bottom: 0;
|
||||||
|
|
||||||
|
&.${theme.bpPrefix}-inline {
|
||||||
|
max-width: 470px;
|
||||||
|
}
|
||||||
|
.${theme.bpPrefix}-label {
|
||||||
|
min-width: 160px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.${theme.bpPrefix}-form-content {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate form header.
|
* Estimate form header.
|
||||||
*/
|
*/
|
||||||
export default function EstimateFormHeader() {
|
export default function EstimateFormHeader() {
|
||||||
|
const theme = useTheme();
|
||||||
const { projects } = useEstimateFormContext();
|
const { projects } = useEstimateFormContext();
|
||||||
|
const styleClassName = getEstimateFieldsStyle(theme);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER_FIELDS)}>
|
<Stack spacing={18} flex={1} className={styleClassName}>
|
||||||
{/* ----------- Customer name ----------- */}
|
{/* ----------- Customer name ----------- */}
|
||||||
<EstimateFormCustomerSelect />
|
<EstimateFormCustomerSelect />
|
||||||
|
|
||||||
@@ -47,78 +63,55 @@ export default function EstimateFormHeader() {
|
|||||||
<EstimateExchangeRateInputField />
|
<EstimateExchangeRateInputField />
|
||||||
|
|
||||||
{/* ----------- Estimate Date ----------- */}
|
{/* ----------- Estimate Date ----------- */}
|
||||||
<FastField name={'estimate_date'}>
|
<FFormGroup
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
name={'estimate_date'}
|
||||||
<FormGroup
|
|
||||||
label={<T id={'estimate_date'} />}
|
label={<T id={'estimate_date'} />}
|
||||||
inline={true}
|
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
className={classNames(CLASSES.FILL, 'form-group--estimate-date')}
|
inline
|
||||||
intent={inputIntent({ error, touched })}
|
fastField
|
||||||
helperText={<ErrorMessage name="estimate_date" />}
|
|
||||||
>
|
>
|
||||||
<DateInput
|
<FDateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
name={'estimate_date'}
|
||||||
value={tansformDateValue(value)}
|
formatDate={(date) => date.toLocaleDateString()}
|
||||||
onChange={handleDateChange((formattedDate) => {
|
parseDate={(str) => new Date(str)}
|
||||||
form.setFieldValue('estimate_date', formattedDate);
|
popoverProps={{ position: Position.BOTTOM_LEFT, minimal: true }}
|
||||||
})}
|
|
||||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
|
||||||
inputProps={{
|
inputProps={{
|
||||||
leftIcon: <Icon icon={'date-range'} />,
|
leftIcon: <Icon icon={'date-range'} />,
|
||||||
|
fill: true,
|
||||||
}}
|
}}
|
||||||
|
fill
|
||||||
|
fastField
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FFormGroup>
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
{/* ----------- Expiration date ----------- */}
|
{/* ----------- Expiration date ----------- */}
|
||||||
<FastField name={'expiration_date'}>
|
<FFormGroup
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
name={'expiration_date'}
|
||||||
<FormGroup
|
|
||||||
label={<T id={'expiration_date'} />}
|
label={<T id={'expiration_date'} />}
|
||||||
labelInfo={<FieldRequiredHint />}
|
inline
|
||||||
inline={true}
|
fastField
|
||||||
className={classNames(
|
|
||||||
CLASSES.FORM_GROUP_LIST_SELECT,
|
|
||||||
CLASSES.FILL,
|
|
||||||
'form-group--expiration-date',
|
|
||||||
)}
|
|
||||||
intent={inputIntent({ error, touched })}
|
|
||||||
helperText={<ErrorMessage name="expiration_date" />}
|
|
||||||
>
|
>
|
||||||
<DateInput
|
<FDateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
name={'expiration_date'}
|
||||||
value={tansformDateValue(value)}
|
formatDate={(date) => date.toLocaleDateString()}
|
||||||
onChange={handleDateChange((formattedDate) => {
|
parseDate={(str) => new Date(str)}
|
||||||
form.setFieldValue('expiration_date', formattedDate);
|
popoverProps={{ position: Position.BOTTOM_LEFT, minimal: true }}
|
||||||
})}
|
|
||||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
|
||||||
inputProps={{
|
inputProps={{
|
||||||
leftIcon: <Icon icon={'date-range'} />,
|
leftIcon: <Icon icon={'date-range'} />,
|
||||||
|
fill: true,
|
||||||
}}
|
}}
|
||||||
|
fill
|
||||||
|
fastField
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FFormGroup>
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
{/* ----------- Estimate number ----------- */}
|
{/* ----------- Estimate number ----------- */}
|
||||||
<EstimateFormEstimateNumberField />
|
<EstimateFormEstimateNumberField />
|
||||||
|
|
||||||
{/* ----------- Reference ----------- */}
|
{/* ----------- Reference ----------- */}
|
||||||
<FastField name={'reference'}>
|
<FFormGroup name={'reference'} label={<T id={'reference'} />} inline fill>
|
||||||
{({ form, field, meta: { error, touched } }) => (
|
<FInputGroup name={'reference'} minimal={true} />
|
||||||
<FormGroup
|
</FFormGroup>
|
||||||
label={<T id={'reference'} />}
|
|
||||||
inline={true}
|
|
||||||
className={classNames('form-group--reference', CLASSES.FILL)}
|
|
||||||
intent={inputIntent({ error, touched })}
|
|
||||||
helperText={<ErrorMessage name="reference" />}
|
|
||||||
>
|
|
||||||
<InputGroup minimal={true} {...field} />
|
|
||||||
</FormGroup>
|
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
{/*------------ Project name -----------*/}
|
{/*------------ Project name -----------*/}
|
||||||
<FeatureCan feature={Features.Projects}>
|
<FeatureCan feature={Features.Projects}>
|
||||||
@@ -136,7 +129,7 @@ export default function EstimateFormHeader() {
|
|||||||
/>
|
/>
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
</FeatureCan>
|
</FeatureCan>
|
||||||
</div>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user