mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
fix: line-level discount
This commit is contained in:
@@ -92,6 +92,10 @@ export interface EstimatePaperTemplateProps extends PaperTemplateProps {
|
|||||||
lineQuantityLabel?: string;
|
lineQuantityLabel?: string;
|
||||||
lineRateLabel?: string;
|
lineRateLabel?: string;
|
||||||
lineTotalLabel?: string;
|
lineTotalLabel?: string;
|
||||||
|
|
||||||
|
// # Line Discount
|
||||||
|
lineDiscountLabel?: string;
|
||||||
|
showLineDiscount?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EstimatePaperTemplate({
|
export function EstimatePaperTemplate({
|
||||||
@@ -173,8 +177,11 @@ export function EstimatePaperTemplate({
|
|||||||
lineQuantityLabel = 'Qty',
|
lineQuantityLabel = 'Qty',
|
||||||
lineRateLabel = 'Rate',
|
lineRateLabel = 'Rate',
|
||||||
lineTotalLabel = 'Total',
|
lineTotalLabel = 'Total',
|
||||||
}: EstimatePaperTemplateProps) {
|
|
||||||
|
|
||||||
|
// # Line Discount
|
||||||
|
lineDiscountLabel = 'Discount',
|
||||||
|
showLineDiscount = false,
|
||||||
|
}: EstimatePaperTemplateProps) {
|
||||||
return (
|
return (
|
||||||
<PaperTemplate primaryColor={primaryColor} secondaryColor={secondaryColor}>
|
<PaperTemplate primaryColor={primaryColor} secondaryColor={secondaryColor}>
|
||||||
<Stack spacing={24}>
|
<Stack spacing={24}>
|
||||||
@@ -240,6 +247,12 @@ export function EstimatePaperTemplate({
|
|||||||
},
|
},
|
||||||
{ label: lineQuantityLabel, accessor: 'quantity' },
|
{ label: lineQuantityLabel, accessor: 'quantity' },
|
||||||
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
||||||
|
{
|
||||||
|
label: lineDiscountLabel,
|
||||||
|
accessor: 'discount',
|
||||||
|
align: 'right',
|
||||||
|
visible: showLineDiscount,
|
||||||
|
},
|
||||||
{ label: lineTotalLabel, accessor: 'total', align: 'right' },
|
{ label: lineTotalLabel, accessor: 'total', align: 'right' },
|
||||||
]}
|
]}
|
||||||
data={lines}
|
data={lines}
|
||||||
|
|||||||
@@ -17,15 +17,16 @@ import {
|
|||||||
DefaultPdfTemplateAddressBilledFrom,
|
DefaultPdfTemplateAddressBilledFrom,
|
||||||
} from './_constants';
|
} from './_constants';
|
||||||
|
|
||||||
interface PapaerLine {
|
interface InvoiceLine {
|
||||||
item?: string;
|
item?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
quantity?: string;
|
quantity?: string;
|
||||||
rate?: string;
|
rate?: string;
|
||||||
total?: string;
|
total?: string;
|
||||||
|
discount?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PaperTax {
|
interface InvoiceTaxLine {
|
||||||
label: string;
|
label: string;
|
||||||
amount: string;
|
amount: string;
|
||||||
}
|
}
|
||||||
@@ -71,6 +72,10 @@ export interface InvoicePaperTemplateProps extends PaperTemplateProps {
|
|||||||
lineRateLabel?: string;
|
lineRateLabel?: string;
|
||||||
lineTotalLabel?: string;
|
lineTotalLabel?: string;
|
||||||
|
|
||||||
|
// # Line Discount
|
||||||
|
lineDiscountLabel?: string;
|
||||||
|
showLineDiscount?: boolean;
|
||||||
|
|
||||||
// Total
|
// Total
|
||||||
showTotal?: boolean;
|
showTotal?: boolean;
|
||||||
totalLabel?: string;
|
totalLabel?: string;
|
||||||
@@ -113,8 +118,8 @@ export interface InvoicePaperTemplateProps extends PaperTemplateProps {
|
|||||||
showStatement?: boolean;
|
showStatement?: boolean;
|
||||||
statement?: string;
|
statement?: string;
|
||||||
|
|
||||||
lines?: Array<PapaerLine>;
|
lines?: Array<InvoiceLine>;
|
||||||
taxes?: Array<PaperTax>;
|
taxes?: Array<InvoiceTaxLine>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InvoicePaperTemplate({
|
export function InvoicePaperTemplate({
|
||||||
@@ -165,6 +170,10 @@ export function InvoicePaperTemplate({
|
|||||||
paymentMadeLabel = 'Payment Made',
|
paymentMadeLabel = 'Payment Made',
|
||||||
dueAmountLabel = 'Balance Due',
|
dueAmountLabel = 'Balance Due',
|
||||||
|
|
||||||
|
// # Line Discount
|
||||||
|
lineDiscountLabel = 'Discount',
|
||||||
|
showLineDiscount = false,
|
||||||
|
|
||||||
// Totals
|
// Totals
|
||||||
showTotal = true,
|
showTotal = true,
|
||||||
total = '$662.75',
|
total = '$662.75',
|
||||||
@@ -277,6 +286,12 @@ export function InvoicePaperTemplate({
|
|||||||
align: 'right',
|
align: 'right',
|
||||||
},
|
},
|
||||||
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
||||||
|
{
|
||||||
|
label: lineDiscountLabel,
|
||||||
|
accessor: 'discount',
|
||||||
|
align: 'right',
|
||||||
|
visible: showLineDiscount,
|
||||||
|
},
|
||||||
{ label: lineTotalLabel, accessor: 'total', align: 'right' },
|
{ label: lineTotalLabel, accessor: 'total', align: 'right' },
|
||||||
]}
|
]}
|
||||||
data={lines}
|
data={lines}
|
||||||
|
|||||||
@@ -90,11 +90,14 @@ interface PaperTemplateTableProps {
|
|||||||
value?: JSX.Element;
|
value?: JSX.Element;
|
||||||
align?: 'left' | 'center' | 'right';
|
align?: 'left' | 'center' | 'right';
|
||||||
thStyle?: React.CSSProperties;
|
thStyle?: React.CSSProperties;
|
||||||
|
visible?: boolean;
|
||||||
}>;
|
}>;
|
||||||
data: Array<Record<string, any>>;
|
data: Array<Record<string, any>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaperTemplate.Table = ({ columns, data }: PaperTemplateTableProps) => {
|
PaperTemplate.Table = ({ columns, data }: PaperTemplateTableProps) => {
|
||||||
|
const filteredColumns = columns.filter((col) => col.visible !== false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table
|
<table
|
||||||
className={css`
|
className={css`
|
||||||
@@ -140,7 +143,7 @@ PaperTemplate.Table = ({ columns, data }: PaperTemplateTableProps) => {
|
|||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
{columns.map((col, index) => (
|
{filteredColumns.map((col, index) => (
|
||||||
<x.th key={index} textAlign={col.align} style={col.thStyle}>
|
<x.th key={index} textAlign={col.align} style={col.thStyle}>
|
||||||
{col.label}
|
{col.label}
|
||||||
</x.th>
|
</x.th>
|
||||||
@@ -151,7 +154,7 @@ PaperTemplate.Table = ({ columns, data }: PaperTemplateTableProps) => {
|
|||||||
<tbody>
|
<tbody>
|
||||||
{data.map((_data: any) => (
|
{data.map((_data: any) => (
|
||||||
<tr>
|
<tr>
|
||||||
{columns.map((column, index) => (
|
{filteredColumns.map((column, index) => (
|
||||||
<x.td textAlign={column.align} key={index}>
|
<x.td textAlign={column.align} key={index}>
|
||||||
{isFunction(column?.accessor)
|
{isFunction(column?.accessor)
|
||||||
? column?.accessor(_data)
|
? column?.accessor(_data)
|
||||||
|
|||||||
@@ -71,9 +71,14 @@ export interface ReceiptPaperTemplateProps extends PaperTemplateProps {
|
|||||||
description: string;
|
description: string;
|
||||||
rate: string;
|
rate: string;
|
||||||
quantity: string;
|
quantity: string;
|
||||||
|
discount?: string;
|
||||||
total: string;
|
total: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
// # Line Discount
|
||||||
|
lineDiscountLabel?: string;
|
||||||
|
showLineDiscount?: boolean;
|
||||||
|
|
||||||
// Receipt Date.
|
// Receipt Date.
|
||||||
receiptDateLabel?: string;
|
receiptDateLabel?: string;
|
||||||
showReceiptDate?: boolean;
|
showReceiptDate?: boolean;
|
||||||
@@ -165,6 +170,10 @@ export function ReceiptPaperTemplate({
|
|||||||
lineQuantityLabel = 'Qty',
|
lineQuantityLabel = 'Qty',
|
||||||
lineRateLabel = 'Rate',
|
lineRateLabel = 'Rate',
|
||||||
lineTotalLabel = 'Total',
|
lineTotalLabel = 'Total',
|
||||||
|
|
||||||
|
// # Line Discount
|
||||||
|
lineDiscountLabel = 'Discount',
|
||||||
|
showLineDiscount = false,
|
||||||
}: ReceiptPaperTemplateProps) {
|
}: ReceiptPaperTemplateProps) {
|
||||||
return (
|
return (
|
||||||
<PaperTemplate primaryColor={primaryColor} secondaryColor={secondaryColor}>
|
<PaperTemplate primaryColor={primaryColor} secondaryColor={secondaryColor}>
|
||||||
@@ -226,6 +235,12 @@ export function ReceiptPaperTemplate({
|
|||||||
},
|
},
|
||||||
{ label: lineQuantityLabel, accessor: 'quantity' },
|
{ label: lineQuantityLabel, accessor: 'quantity' },
|
||||||
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
||||||
|
{
|
||||||
|
label: lineDiscountLabel,
|
||||||
|
accessor: 'discount',
|
||||||
|
align: 'right',
|
||||||
|
visible: showLineDiscount,
|
||||||
|
},
|
||||||
{ label: lineTotalLabel, accessor: 'total', align: 'right' },
|
{ label: lineTotalLabel, accessor: 'total', align: 'right' },
|
||||||
]}
|
]}
|
||||||
data={lines}
|
data={lines}
|
||||||
|
|||||||
Reference in New Issue
Block a user