mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix: payment page
This commit is contained in:
@@ -25,6 +25,17 @@ export class PaymentIntegration extends Model {
|
||||
return this.paymentEnabled && this.payoutEnabled;
|
||||
}
|
||||
|
||||
static get modifiers() {
|
||||
return {
|
||||
/**
|
||||
* Query to filter enabled payment and payout.
|
||||
*/
|
||||
fullEnabled(query) {
|
||||
query.where('paymentEnabled', true).andWhere('payoutEnabled', true);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
|
||||
@@ -21,7 +21,7 @@ export class GetPaymentServicesSpecificInvoice {
|
||||
const { PaymentIntegration } = this.tenancy.models(tenantId);
|
||||
|
||||
const paymentGateways = await PaymentIntegration.query()
|
||||
.where('active', true)
|
||||
.modify('fullEnabled')
|
||||
.orderBy('name', 'ASC');
|
||||
|
||||
return this.transform.transform(
|
||||
|
||||
@@ -44,6 +44,7 @@ export class GetInvoicePaymentLinkMetadata {
|
||||
.findById(paymentLink.resourceId)
|
||||
.withGraphFetched('entries.item')
|
||||
.withGraphFetched('customer')
|
||||
.withGraphFetched('taxes.taxRate')
|
||||
.throwIfNotFound();
|
||||
|
||||
return this.transformer.transform(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ItemEntryTransformer } from './ItemEntryTransformer';
|
||||
import { SaleInvoiceTaxEntryTransformer } from './SaleInvoiceTaxEntryTransformer';
|
||||
import { SaleInvoiceTransformer } from './SaleInvoiceTransformer';
|
||||
|
||||
export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer {
|
||||
@@ -37,6 +38,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
||||
'invoiceMessage',
|
||||
'termsConditions',
|
||||
'entries',
|
||||
'taxes',
|
||||
];
|
||||
};
|
||||
|
||||
@@ -62,6 +64,22 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the sale invoice entries.
|
||||
* @returns {}
|
||||
*/
|
||||
protected taxes = (invoice) => {
|
||||
return this.item(
|
||||
invoice.taxes,
|
||||
new GetInvoicePaymentLinkTaxEntryTransformer(),
|
||||
{
|
||||
subtotal: invoice.subtotal,
|
||||
isInclusiveTax: invoice.isInclusiveTax,
|
||||
currencyCode: invoice.currencyCode,
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
class GetInvoicePaymentLinkEntryMetaTransformer extends ItemEntryTransformer {
|
||||
@@ -94,3 +112,13 @@ class GetInvoicePaymentLinkEntryMetaTransformer extends ItemEntryTransformer {
|
||||
return ['*'];
|
||||
};
|
||||
}
|
||||
|
||||
class GetInvoicePaymentLinkTaxEntryTransformer extends SaleInvoiceTaxEntryTransformer {
|
||||
/**
|
||||
* Included attributes.
|
||||
* @returns {Array}
|
||||
*/
|
||||
public includeAttributes = (): string[] => {
|
||||
return ['name', 'taxRateCode', 'taxRateAmount', 'taxRateAmountFormatted'];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
.rootBodyPage {
|
||||
background: #0c103f;
|
||||
background: #1c1d29;
|
||||
}
|
||||
|
||||
.root {
|
||||
|
||||
@@ -83,6 +83,13 @@ export function PaymentPortal() {
|
||||
</Text>
|
||||
</Group>
|
||||
|
||||
{sharableLinkMeta?.taxes?.map((tax, key) => (
|
||||
<Group key={key} position={'apart'} className={styles.totalItem}>
|
||||
<Text>{tax?.name}</Text>
|
||||
<Text>{tax?.taxRateAmountFormatted}</Text>
|
||||
</Group>
|
||||
))}
|
||||
|
||||
<Group
|
||||
position={'apart'}
|
||||
className={clsx(styles.totalItem, styles.borderBottomGray)}
|
||||
|
||||
@@ -30,6 +30,10 @@ export function PaymentInvoicePreviewContent() {
|
||||
rate: entry.rateFormatted,
|
||||
total: entry.totalFormatted,
|
||||
}))}
|
||||
taxes={sharableLinkMeta?.taxes?.map((tax) => ({
|
||||
label: tax.name,
|
||||
amount: tax.taxRateAmountFormatted,
|
||||
}))}
|
||||
/>
|
||||
</Box>
|
||||
</DrawerBody>
|
||||
|
||||
@@ -50,7 +50,6 @@ export function useCreatePaymentLink(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Get Invoice Payment Link
|
||||
// -----------------------------------------
|
||||
export interface GetInvoicePaymentLinkResponse {
|
||||
@@ -82,6 +81,12 @@ export interface GetInvoicePaymentLinkResponse {
|
||||
total: number;
|
||||
totalFormatted: string;
|
||||
}>;
|
||||
taxes: Array<{
|
||||
name: string;
|
||||
taxRateAmount: number;
|
||||
taxRateAmountFormatted: string;
|
||||
taxRateCode: string;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* Fetches the sharable invoice link metadata for a given link ID.
|
||||
|
||||
Reference in New Issue
Block a user