mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: mail receipt preview
This commit is contained in:
@@ -176,6 +176,7 @@ export default class CreditNote extends mixin(TenantModel, [
|
||||
const Branch = require('models/Branch');
|
||||
const Document = require('models/Document');
|
||||
const Warehouse = require('models/Warehouse');
|
||||
const { PdfTemplate } = require('models/PdfTemplate');
|
||||
|
||||
return {
|
||||
/**
|
||||
@@ -266,6 +267,18 @@ export default class CreditNote extends mixin(TenantModel, [
|
||||
query.where('model_ref', 'CreditNote');
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Credit note may belongs to pdf branding template.
|
||||
*/
|
||||
pdfTemplate: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: PdfTemplate,
|
||||
join: {
|
||||
from: 'credit_notes.pdfTemplateId',
|
||||
to: 'pdf_templates.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ export default class PaymentReceive extends mixin(TenantModel, [
|
||||
const Account = require('models/Account');
|
||||
const Branch = require('models/Branch');
|
||||
const Document = require('models/Document');
|
||||
const { PdfTemplate } = require('models/PdfTemplate');
|
||||
|
||||
return {
|
||||
customer: {
|
||||
@@ -135,6 +136,18 @@ export default class PaymentReceive extends mixin(TenantModel, [
|
||||
query.where('model_ref', 'PaymentReceive');
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Payment received may belongs to pdf branding template.
|
||||
*/
|
||||
pdfTemplate: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: PdfTemplate,
|
||||
join: {
|
||||
from: 'payment_receives.pdfTemplateId',
|
||||
to: 'pdf_templates.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Inject } from 'typedi';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { SendSaleEstimateMail } from './SendSaleEstimateMail';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { GetSaleEstimateMailStateTransformer } from './GetSaleEstimateMailStateTransformer';
|
||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||
|
||||
@Service()
|
||||
export class GetSaleEstimateMailState {
|
||||
@Inject()
|
||||
private estimateMail: SendSaleEstimateMail;
|
||||
|
||||
@@ -9,7 +9,10 @@ export class GetSaleEstimateMailStateTransformer extends SaleEstimateTransfromer
|
||||
public includeAttributes = (): string[] => {
|
||||
return [
|
||||
'estimateDate',
|
||||
'formattedEstimateDate',
|
||||
'estimateDateFormatted',
|
||||
|
||||
'expirationDate',
|
||||
'expirationDateFormatted',
|
||||
|
||||
'total',
|
||||
'totalFormatted',
|
||||
@@ -17,8 +20,7 @@ export class GetSaleEstimateMailStateTransformer extends SaleEstimateTransfromer
|
||||
'subtotal',
|
||||
'subtotalFormatted',
|
||||
|
||||
'estimateNo',
|
||||
|
||||
'estimateNumber',
|
||||
'entries',
|
||||
|
||||
'companyName',
|
||||
@@ -62,10 +64,65 @@ export class GetSaleEstimateMailStateTransformer extends SaleEstimateTransfromer
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param invoice
|
||||
* Retrieves the estimate number.
|
||||
*/
|
||||
protected estimateDateFormatted = (estimate) => {
|
||||
return this.formattedEstimateDate(estimate);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the expiration date of the estimate.
|
||||
* @param estimate
|
||||
* @returns {string}
|
||||
*/
|
||||
protected expirationDateFormatted = (estimate) => {
|
||||
return this.formattedExpirationDate(estimate);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the total amount of the estimate.
|
||||
* @param estimate
|
||||
* @returns
|
||||
*/
|
||||
protected total(estimate) {
|
||||
return estimate.amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the subtotal amount of the estimate.
|
||||
* @param estimate
|
||||
* @returns {number}
|
||||
*/
|
||||
protected subtotal(estimate) {
|
||||
return estimate.amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the formatted total of the estimate.
|
||||
* @param estimate
|
||||
* @returns {string}
|
||||
*/
|
||||
protected totalFormatted(estimate) {
|
||||
return this.formatMoney(estimate.amount, {
|
||||
currencyCode: estimate.currencyCode,
|
||||
money: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the formatted subtotal of the estimate.
|
||||
* @param estimate
|
||||
* @returns {string}
|
||||
*/
|
||||
protected subtotalFormatted = (estimate) => {
|
||||
return this.formatNumber(estimate.amount, { money: false });
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the estimate entries.
|
||||
* @param invoice
|
||||
* @returns {Array}
|
||||
*/
|
||||
protected entries = (invoice) => {
|
||||
return this.item(
|
||||
invoice.entries,
|
||||
@@ -92,9 +149,18 @@ class GetSaleEstimateMailStateEntryTransformer extends ItemEntryTransformer {
|
||||
return ['*'];
|
||||
};
|
||||
|
||||
/**
|
||||
* Item name.
|
||||
* @param entry
|
||||
* @returns
|
||||
*/
|
||||
public name = (entry) => {
|
||||
return entry.item.name;
|
||||
};
|
||||
|
||||
public includeAttributes = (): string[] => {
|
||||
return [
|
||||
'description',
|
||||
'name',
|
||||
'quantity',
|
||||
'unitPrice',
|
||||
'unitPriceFormatted',
|
||||
|
||||
@@ -32,6 +32,7 @@ export class GetPaymentReceivedMailState {
|
||||
.findById(paymentId)
|
||||
.withGraphFetched('customer')
|
||||
.withGraphFetched('entries.invoice')
|
||||
.withGraphFetched('pdfTemplate')
|
||||
.throwIfNotFound();
|
||||
|
||||
const mailOptions =
|
||||
|
||||
@@ -26,7 +26,10 @@ export class GetPaymentReceivedMailStateTransformer extends PaymentReceiveTransf
|
||||
'total',
|
||||
'totalFormatted',
|
||||
|
||||
'paymentNo',
|
||||
'subtotal',
|
||||
'subtotalFormatted',
|
||||
|
||||
'paymentNumber',
|
||||
|
||||
'entries',
|
||||
|
||||
@@ -87,6 +90,17 @@ export class GetPaymentReceivedMailStateTransformer extends PaymentReceiveTransf
|
||||
return this.formatMoney(payment.paymentAmount);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the payment amount.
|
||||
* @param payment
|
||||
* @returns {number}
|
||||
*/
|
||||
protected total = (payment) => {
|
||||
return this.formatNumber(payment.amount, {
|
||||
money: false,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted payment amount.
|
||||
* @returns {string}
|
||||
@@ -95,6 +109,34 @@ export class GetPaymentReceivedMailStateTransformer extends PaymentReceiveTransf
|
||||
return this.formatMoney(payment.total);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the payment amount.
|
||||
* @param payment
|
||||
* @returns {number}
|
||||
*/
|
||||
protected subtotal = (payment) => {
|
||||
return this.formatNumber(payment.amount, {
|
||||
money: false,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted payment amount.
|
||||
* @returns {string}
|
||||
*/
|
||||
protected subtotalFormatted = (payment) => {
|
||||
return this.formatMoney(payment.total);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the payment number.
|
||||
* @param payment
|
||||
* @returns {string}
|
||||
*/
|
||||
protected paymentNumber = (payment) => {
|
||||
return payment.paymentReceiveNo;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the payment entries.
|
||||
* @param {IPaymentReceived} payment
|
||||
|
||||
Reference in New Issue
Block a user