-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
393 additions
and
9 deletions.
There are no files selected for viewing
148 changes: 147 additions & 1 deletion
148
packages/server/src/services/Sales/Estimates/GetEstimateMailTemplateAttributesTransformer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,149 @@ | ||
import { Transformer } from '@/lib/Transformer/Transformer'; | ||
|
||
export class GetEstimateMailTemplateAttributesTransformer extends Transformer {} | ||
export class GetEstimateMailTemplateAttributesTransformer extends Transformer { | ||
public includeAttributes = (): string[] => { | ||
return [ | ||
'companyLogoUri', | ||
'companyName', | ||
|
||
'estimateAmount', | ||
|
||
'primaryColor', | ||
|
||
'estimateAmount', | ||
'estimateMessage', | ||
|
||
'dueDate', | ||
'dueDateLabel', | ||
|
||
'estimateNumber', | ||
'estimateNumberLabel', | ||
|
||
'total', | ||
'totalLabel', | ||
|
||
'dueAmount', | ||
'dueAmountLabel', | ||
|
||
'viewEstimateButtonLabel', | ||
'viewEstimateButtonUrl', | ||
|
||
'items', | ||
]; | ||
}; | ||
|
||
/** | ||
* Exclude all attributes. | ||
* @returns {string[]} | ||
*/ | ||
public excludeAttributes = (): string[] => { | ||
return ['*']; | ||
}; | ||
|
||
/** | ||
* Company logo uri. | ||
* @returns {string} | ||
*/ | ||
public companyLogoUri(): string { | ||
return this.options.brandingTemplate?.companyLogoUri; | ||
} | ||
|
||
/** | ||
* Company name. | ||
* @returns {string} | ||
*/ | ||
public companyName(): string { | ||
return this.context.organization.name; | ||
} | ||
|
||
/** | ||
* Primary color | ||
* @returns {string} | ||
*/ | ||
public primaryColor(): string { | ||
return this.options?.brandingTemplate?.attributes?.primaryColor; | ||
} | ||
|
||
/** | ||
* Estimate number. | ||
* @returns {string} | ||
*/ | ||
public estimateNumber(): string { | ||
return this.options.estimate.number; | ||
} | ||
|
||
/** | ||
* Estimate number label. | ||
* @returns {string} | ||
*/ | ||
public estimateNumberLabel(): string { | ||
return 'Estimate Number'; | ||
} | ||
|
||
/** | ||
* Expiration date. | ||
* @returns {string} | ||
*/ | ||
public expirationDate(): string { | ||
return this.options.estimate.expirationDate; | ||
} | ||
|
||
/** | ||
* Expiration date label. | ||
* @returns {string} | ||
*/ | ||
public expirationDateLabel(): string { | ||
return 'Expiration Date'; | ||
} | ||
|
||
/** | ||
* Estimate total. | ||
*/ | ||
public total(): string { | ||
return this.options.estimate.totalFormatted; | ||
} | ||
|
||
/** | ||
* Estimate total label. | ||
* @returns {string} | ||
*/ | ||
public totalLabel(): string { | ||
return 'Total'; | ||
} | ||
|
||
/** | ||
* Estimate mail items attributes. | ||
*/ | ||
public items(): any[] { | ||
return this.item( | ||
this.options.estimate.entries, | ||
new GetEstimateMailTemplateEntryAttributesTransformer() | ||
); | ||
} | ||
} | ||
|
||
class GetEstimateMailTemplateEntryAttributesTransformer extends Transformer { | ||
public includeAttributes = (): string[] => { | ||
return ['label', 'quantity', 'rate', 'total']; | ||
}; | ||
|
||
public excludeAttributes = (): string[] => { | ||
return ['*']; | ||
}; | ||
|
||
public label(entry): string { | ||
return entry?.item?.name; | ||
} | ||
|
||
public quantity(entry): string { | ||
return entry?.quantity; | ||
} | ||
|
||
public rate(entry): string { | ||
return entry?.rateFormatted; | ||
} | ||
|
||
public total(entry): string { | ||
return entry?.totalFormatted; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 81 additions & 1 deletion
82
...rver/src/services/Sales/PaymentReceived/GetPaymentReceivedMailTemplateAttrsTransformer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,83 @@ | ||
import { Transformer } from '@/lib/Transformer/Transformer'; | ||
|
||
export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer {} | ||
export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer { | ||
/** | ||
* Included attributes. | ||
* @returns {Array} | ||
*/ | ||
public includeAttributes = (): string[] => { | ||
return [ | ||
'companyLogoUri', | ||
'companyName', | ||
'primaryColor', | ||
'total', | ||
'totalLabel', | ||
'paymentNumberLabel', | ||
'paymentNumber', | ||
]; | ||
}; | ||
|
||
/** | ||
* Exclude all attributes. | ||
* @returns {string[]} | ||
*/ | ||
public excludeAttributes = (): string[] => { | ||
return ['*']; | ||
}; | ||
|
||
/** | ||
* Company logo uri. | ||
* @returns {string} | ||
*/ | ||
public companyLogoUri(): string { | ||
return this.options.brandingTemplate?.companyLogoUri; | ||
} | ||
|
||
/** | ||
* Company name. | ||
* @returns {string} | ||
*/ | ||
public companyName(): string { | ||
return this.context.organization.name; | ||
} | ||
|
||
/** | ||
* Primary color | ||
* @returns {string} | ||
*/ | ||
public primaryColor(): string { | ||
return this.options?.brandingTemplate?.attributes?.primaryColor; | ||
} | ||
|
||
/** | ||
* Total. | ||
* @returns {string} | ||
*/ | ||
public total(): string { | ||
return this.options.paymentReceived.formattedAmount; | ||
} | ||
|
||
/** | ||
* Total label. | ||
* @returns {string} | ||
*/ | ||
public totalLabel(): string { | ||
return 'Total'; | ||
} | ||
|
||
/** | ||
* Payment number label. | ||
* @returns | ||
*/ | ||
public paymentNumberLabel(): string { | ||
return 'Payment # {paymentNumber}'; | ||
} | ||
|
||
/** | ||
* Payment number. | ||
* @returns {string} | ||
*/ | ||
public paymentNumber(): string { | ||
return this.options.paymentReceived.paymentReceiveNumber; | ||
} | ||
} |
Oops, something went wrong.