mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
Merge pull request #871 from bigcapitalhq/fix-payment-link-base-url
fix: generated payment link base url
This commit is contained in:
5
packages/server/src/common/config/app.ts
Normal file
5
packages/server/src/common/config/app.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
|
export default registerAs('app', () => ({
|
||||||
|
baseUrl: process.env.BASE_URL,
|
||||||
|
}));
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import app from './app';
|
||||||
import systemDatabase from './system-database';
|
import systemDatabase from './system-database';
|
||||||
import tenantDatabase from './tenant-database';
|
import tenantDatabase from './tenant-database';
|
||||||
import signup from './signup';
|
import signup from './signup';
|
||||||
@@ -18,6 +19,7 @@ import throttle from './throttle';
|
|||||||
import cloud from './cloud';
|
import cloud from './cloud';
|
||||||
|
|
||||||
export const config = [
|
export const config = [
|
||||||
|
app,
|
||||||
systemDatabase,
|
systemDatabase,
|
||||||
cloud,
|
cloud,
|
||||||
tenantDatabase,
|
tenantDatabase,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { PaymentLink } from '@/modules/PaymentLinks/models/PaymentLink';
|
|||||||
import { SaleInvoice } from '../models/SaleInvoice';
|
import { SaleInvoice } from '../models/SaleInvoice';
|
||||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||||
import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service';
|
import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GenerateShareLink {
|
export class GenerateShareLink {
|
||||||
@@ -18,13 +19,14 @@ export class GenerateShareLink {
|
|||||||
private eventPublisher: EventEmitter2,
|
private eventPublisher: EventEmitter2,
|
||||||
private transformer: TransformerInjectable,
|
private transformer: TransformerInjectable,
|
||||||
private tenancyContext: TenancyContext,
|
private tenancyContext: TenancyContext,
|
||||||
|
private configService: ConfigService,
|
||||||
|
|
||||||
@Inject(SaleInvoice.name)
|
@Inject(SaleInvoice.name)
|
||||||
private saleInvoiceModel: TenantModelProxy<typeof SaleInvoice>,
|
private saleInvoiceModel: TenantModelProxy<typeof SaleInvoice>,
|
||||||
|
|
||||||
@Inject(PaymentLink.name)
|
@Inject(PaymentLink.name)
|
||||||
private paymentLinkModel: typeof PaymentLink,
|
private paymentLinkModel: typeof PaymentLink,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates private or public payment link for the given sale invoice.
|
* Generates private or public payment link for the given sale invoice.
|
||||||
@@ -75,6 +77,9 @@ export class GenerateShareLink {
|
|||||||
return this.transformer.transform(
|
return this.transformer.transform(
|
||||||
paymentLink,
|
paymentLink,
|
||||||
new GeneratePaymentLinkTransformer(),
|
new GeneratePaymentLinkTransformer(),
|
||||||
|
{
|
||||||
|
baseUrl: this.configService.get('app.baseUrl'),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import { Transformer } from '@/modules/Transformer/Transformer';
|
import { Transformer } from '@/modules/Transformer/Transformer';
|
||||||
import { PUBLIC_PAYMENT_LINK } from '../constants';
|
import { PUBLIC_PAYMENT_LINK } from '../constants';
|
||||||
|
|
||||||
export class GeneratePaymentLinkTransformer extends Transformer {
|
interface GeneratePaymentLinkTransformerOptions {
|
||||||
|
baseUrl: string;
|
||||||
|
}
|
||||||
|
export class GeneratePaymentLinkTransformer extends Transformer<GeneratePaymentLinkTransformerOptions> {
|
||||||
/**
|
/**
|
||||||
* Exclude these attributes from payment link object.
|
* Exclude these attributes from payment link object.
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
@@ -23,6 +26,9 @@ export class GeneratePaymentLinkTransformer extends Transformer {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
public link(link) {
|
public link(link) {
|
||||||
return PUBLIC_PAYMENT_LINK?.replace('{PAYMENT_LINK_ID}', link.linkId);
|
return PUBLIC_PAYMENT_LINK?.replace(
|
||||||
|
'{BASE_URL}',
|
||||||
|
this.options.baseUrl,
|
||||||
|
).replace('{PAYMENT_LINK_ID}', link.linkId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
export const SendSaleInvoiceQueue = 'SendSaleInvoiceQueue';
|
export const SendSaleInvoiceQueue = 'SendSaleInvoiceQueue';
|
||||||
export const SendSaleInvoiceMailJob = 'SendSaleInvoiceMailJob';
|
export const SendSaleInvoiceMailJob = 'SendSaleInvoiceMailJob';
|
||||||
|
|
||||||
const BASE_URL = 'http://localhost:3000';
|
|
||||||
|
|
||||||
export const DEFAULT_INVOICE_MAIL_SUBJECT =
|
export const DEFAULT_INVOICE_MAIL_SUBJECT =
|
||||||
'Invoice {Invoice Number} from {Company Name} for {Customer Name}';
|
'Invoice {Invoice Number} from {Company Name} for {Customer Name}';
|
||||||
export const DEFAULT_INVOICE_MAIL_CONTENT = `Hi {Customer Name},
|
export const DEFAULT_INVOICE_MAIL_CONTENT = `Hi {Customer Name},
|
||||||
|
|
||||||
Here's invoice # {Invoice Number} for {Invoice Amount}
|
Here's invoice # {Invoice Number} for {Invoice Amount}
|
||||||
@@ -23,8 +22,8 @@ Thanks,
|
|||||||
|
|
||||||
export const DEFAULT_INVOICE_REMINDER_MAIL_SUBJECT =
|
export const DEFAULT_INVOICE_REMINDER_MAIL_SUBJECT =
|
||||||
'Invoice {InvoiceNumber} reminder from {CompanyName}';
|
'Invoice {InvoiceNumber} reminder from {CompanyName}';
|
||||||
export const DEFAULT_INVOICE_REMINDER_MAIL_CONTENT = `
|
export const DEFAULT_INVOICE_REMINDER_MAIL_CONTENT = `
|
||||||
<p>Dear {CustomerName}</p>
|
<p>Dear {CustomerName}</p>
|
||||||
<p>You might have missed the payment date and the invoice is now overdue by {OverdueDays} days.</p>
|
<p>You might have missed the payment date and the invoice is now overdue by {OverdueDays} days.</p>
|
||||||
<p>Invoice <strong>#{InvoiceNumber}</strong><br />
|
<p>Invoice <strong>#{InvoiceNumber}</strong><br />
|
||||||
Due Date : <strong>{InvoiceDueDate}</strong><br />
|
Due Date : <strong>{InvoiceDueDate}</strong><br />
|
||||||
@@ -36,7 +35,7 @@ Amount : <strong>{InvoiceAmount}</strong></p>
|
|||||||
</p>
|
</p>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const PUBLIC_PAYMENT_LINK = `${BASE_URL}/payment/{PAYMENT_LINK_ID}`;
|
export const PUBLIC_PAYMENT_LINK = "{BASE_URL}/payment/{PAYMENT_LINK_ID}";
|
||||||
|
|
||||||
export const ERRORS = {
|
export const ERRORS = {
|
||||||
INVOICE_NUMBER_NOT_UNIQUE: 'INVOICE_NUMBER_NOT_UNIQUE',
|
INVOICE_NUMBER_NOT_UNIQUE: 'INVOICE_NUMBER_NOT_UNIQUE',
|
||||||
|
|||||||
Reference in New Issue
Block a user