mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
feat: add discount functionality to sales and purchase transactions
- Introduced discount_type and discount fields in Bills and SalesReceipts controllers. - Updated database migrations to include discount and discount_type in estimates and credit notes tables. - Enhanced SaleReceipt and SaleEstimate models to support discount attributes. - Implemented formatting for discount amounts in transformers and PDF templates. - Updated email templates to display discount information. This commit enhances the handling of discounts across various transaction types, improving the overall functionality and user experience.
This commit is contained in:
@@ -48,6 +48,12 @@ export interface EstimatePaperTemplateProps extends PaperTemplateProps {
|
||||
showTotal?: boolean;
|
||||
totalLabel?: string;
|
||||
|
||||
// # Discount
|
||||
discount?: string;
|
||||
showDiscount?: boolean;
|
||||
discountLabel?: string;
|
||||
|
||||
// # Subtotal
|
||||
subtotal?: string;
|
||||
showSubtotal?: boolean;
|
||||
subtotalLabel?: string;
|
||||
@@ -101,6 +107,11 @@ export function EstimatePaperTemplate({
|
||||
totalLabel = 'Total',
|
||||
showTotal = true,
|
||||
|
||||
// # Discount
|
||||
discount = '0.00',
|
||||
discountLabel = 'Discount',
|
||||
showDiscount = true,
|
||||
|
||||
// # Subtotal
|
||||
subtotal = '1000/00',
|
||||
subtotalLabel = 'Subtotal',
|
||||
@@ -202,8 +213,8 @@ export function EstimatePaperTemplate({
|
||||
<Text>{data.item}</Text>
|
||||
<Text
|
||||
fontSize={'12px'}
|
||||
// className={Classes.TEXT_MUTED}
|
||||
// style={{ fontSize: 12 }}
|
||||
// className={Classes.TEXT_MUTED}
|
||||
// style={{ fontSize: 12 }}
|
||||
>
|
||||
{data.description}
|
||||
</Text>
|
||||
@@ -223,6 +234,12 @@ export function EstimatePaperTemplate({
|
||||
amount={subtotal}
|
||||
/>
|
||||
)}
|
||||
{showDiscount && discount && (
|
||||
<PaperTemplate.TotalLine
|
||||
label={discountLabel}
|
||||
amount={discount}
|
||||
/>
|
||||
)}
|
||||
{showTotal && (
|
||||
<PaperTemplate.TotalLine label={totalLabel} amount={total} />
|
||||
)}
|
||||
|
||||
@@ -2,10 +2,7 @@ import { Box } from '../lib/layout/Box';
|
||||
import { Text } from '../lib/text/Text';
|
||||
import { Stack } from '../lib/layout/Stack';
|
||||
import { Group } from '../lib/layout/Group';
|
||||
import {
|
||||
PaperTemplate,
|
||||
PaperTemplateProps,
|
||||
} from './PaperTemplate';
|
||||
import { PaperTemplate, PaperTemplateProps } from './PaperTemplate';
|
||||
import {
|
||||
DefaultPdfTemplateTerms,
|
||||
DefaultPdfTemplateItemDescription,
|
||||
@@ -32,16 +29,21 @@ export interface ReceiptPaperTemplateProps extends PaperTemplateProps {
|
||||
|
||||
billedToLabel?: string;
|
||||
|
||||
// # Subtotal
|
||||
subtotal?: string;
|
||||
showSubtotal?: boolean;
|
||||
subtotalLabel?: string;
|
||||
|
||||
// # Discount
|
||||
discount?: string;
|
||||
showDiscount?: boolean;
|
||||
discountLabel?: string;
|
||||
|
||||
// Total
|
||||
total?: string;
|
||||
showTotal?: boolean;
|
||||
totalLabel?: string;
|
||||
|
||||
// Subtotal
|
||||
subtotal?: string;
|
||||
showSubtotal?: boolean;
|
||||
subtotalLabel?: string;
|
||||
|
||||
// Customer Note
|
||||
showCustomerNote?: boolean;
|
||||
customerNote?: string;
|
||||
@@ -99,10 +101,17 @@ export function ReceiptPaperTemplate({
|
||||
|
||||
billedToLabel = 'Billed To',
|
||||
|
||||
// # Total
|
||||
total = '$1000.00',
|
||||
totalLabel = 'Total',
|
||||
showTotal = true,
|
||||
|
||||
// # Discount
|
||||
discount = '',
|
||||
discountLabel = 'Discount',
|
||||
showDiscount = true,
|
||||
|
||||
// # Subtotal
|
||||
subtotal = '1000/00',
|
||||
subtotalLabel = 'Subtotal',
|
||||
showSubtotal = true,
|
||||
@@ -192,8 +201,8 @@ export function ReceiptPaperTemplate({
|
||||
<Text>{data.item}</Text>
|
||||
<Text
|
||||
fontSize={'12px'}
|
||||
// className={Classes.TEXT_MUTED}
|
||||
// style={{ fontSize: 12 }}
|
||||
// className={Classes.TEXT_MUTED}
|
||||
// style={{ fontSize: 12 }}
|
||||
>
|
||||
{data.description}
|
||||
</Text>
|
||||
@@ -213,6 +222,12 @@ export function ReceiptPaperTemplate({
|
||||
amount={subtotal}
|
||||
/>
|
||||
)}
|
||||
{showDiscount && discount && (
|
||||
<PaperTemplate.TotalLine
|
||||
label={discountLabel}
|
||||
amount={discount}
|
||||
/>
|
||||
)}
|
||||
{showTotal && (
|
||||
<PaperTemplate.TotalLine label={totalLabel} amount={total} />
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user