mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-24 08:39:49 +00:00
Compare commits
7 Commits
v0.24.12
...
fix/credit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
688b1bfb56 | ||
|
|
0f8147daff | ||
|
|
96b24d4fb9 | ||
|
|
2a87103bc8 | ||
|
|
238b60144f | ||
|
|
fcee85e358 | ||
|
|
75b98c39d8 |
@@ -1,5 +1,5 @@
|
|||||||
import { ModuleRef } from '@nestjs/core';
|
import { ModuleRef } from '@nestjs/core';
|
||||||
import bluebird from 'bluebird';
|
import * as bluebird from 'bluebird';
|
||||||
import { Knex } from 'knex';
|
import { Knex } from 'knex';
|
||||||
import {
|
import {
|
||||||
validateLinkModelEntryExists,
|
validateLinkModelEntryExists,
|
||||||
@@ -53,7 +53,8 @@ export class LinkAttachment {
|
|||||||
const foundLinkModel = await LinkModel().query(trx).findById(modelId);
|
const foundLinkModel = await LinkModel().query(trx).findById(modelId);
|
||||||
validateLinkModelEntryExists(foundLinkModel);
|
validateLinkModelEntryExists(foundLinkModel);
|
||||||
|
|
||||||
const foundLinks = await this.documentLinkModel().query(trx)
|
const foundLinks = await this.documentLinkModel()
|
||||||
|
.query(trx)
|
||||||
.where('modelRef', modelRef)
|
.where('modelRef', modelRef)
|
||||||
.where('modelId', modelId)
|
.where('modelId', modelId)
|
||||||
.where('documentId', foundFile.id);
|
.where('documentId', foundFile.id);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
Param,
|
Param,
|
||||||
Post,
|
Post,
|
||||||
@@ -14,6 +15,10 @@ import { PermissionGuard } from '@/modules/Roles/Permission.guard';
|
|||||||
import { AuthorizationGuard } from '@/modules/Roles/Authorization.guard';
|
import { AuthorizationGuard } from '@/modules/Roles/Authorization.guard';
|
||||||
import { AbilitySubject } from '@/modules/Roles/Roles.types';
|
import { AbilitySubject } from '@/modules/Roles/Roles.types';
|
||||||
import { CreditNoteAction } from '../CreditNotes/types/CreditNotes.types';
|
import { CreditNoteAction } from '../CreditNotes/types/CreditNotes.types';
|
||||||
|
import { GetCreditNoteAssociatedInvoicesToApply } from './queries/GetCreditNoteAssociatedInvoicesToApply.service';
|
||||||
|
import { CreditNoteApplyToInvoices } from './commands/CreditNoteApplyToInvoices.service';
|
||||||
|
import { DeleteCreditNoteApplyToInvoices } from './commands/DeleteCreditNoteApplyToInvoices.service';
|
||||||
|
import { ApplyCreditNoteToInvoicesDto } from './dtos/ApplyCreditNoteToInvoices.dto';
|
||||||
|
|
||||||
@Controller('credit-notes')
|
@Controller('credit-notes')
|
||||||
@ApiTags('Credit Notes Apply Invoice')
|
@ApiTags('Credit Notes Apply Invoice')
|
||||||
@@ -22,6 +27,9 @@ import { CreditNoteAction } from '../CreditNotes/types/CreditNotes.types';
|
|||||||
export class CreditNotesApplyInvoiceController {
|
export class CreditNotesApplyInvoiceController {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly getCreditNoteAssociatedAppliedInvoicesService: GetCreditNoteAssociatedAppliedInvoices,
|
private readonly getCreditNoteAssociatedAppliedInvoicesService: GetCreditNoteAssociatedAppliedInvoices,
|
||||||
|
private readonly getCreditNoteAssociatedInvoicesToApplyService: GetCreditNoteAssociatedInvoicesToApply,
|
||||||
|
private readonly creditNoteApplyToInvoicesService: CreditNoteApplyToInvoices,
|
||||||
|
private readonly deleteCreditNoteApplyToInvoicesService: DeleteCreditNoteApplyToInvoices,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get(':creditNoteId/applied-invoices')
|
@Get(':creditNoteId/applied-invoices')
|
||||||
@@ -39,6 +47,23 @@ export class CreditNotesApplyInvoiceController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get(':creditNoteId/apply-invoices')
|
||||||
|
@RequirePermission(CreditNoteAction.View, AbilitySubject.CreditNote)
|
||||||
|
@ApiOperation({ summary: 'Get credit note associated invoices to apply' })
|
||||||
|
@ApiResponse({
|
||||||
|
status: 200,
|
||||||
|
description: 'Credit note associated invoices to apply',
|
||||||
|
})
|
||||||
|
@ApiResponse({ status: 404, description: 'Credit note not found' })
|
||||||
|
@ApiResponse({ status: 400, description: 'Invalid input data' })
|
||||||
|
getCreditNoteAssociatedInvoicesToApply(
|
||||||
|
@Param('creditNoteId') creditNoteId: number,
|
||||||
|
) {
|
||||||
|
return this.getCreditNoteAssociatedInvoicesToApplyService.getCreditAssociatedInvoicesToApply(
|
||||||
|
creditNoteId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Post(':creditNoteId/apply-invoices')
|
@Post(':creditNoteId/apply-invoices')
|
||||||
@RequirePermission(CreditNoteAction.Edit, AbilitySubject.CreditNote)
|
@RequirePermission(CreditNoteAction.Edit, AbilitySubject.CreditNote)
|
||||||
@ApiOperation({ summary: 'Apply credit note to invoices' })
|
@ApiOperation({ summary: 'Apply credit note to invoices' })
|
||||||
@@ -48,9 +73,32 @@ export class CreditNotesApplyInvoiceController {
|
|||||||
})
|
})
|
||||||
@ApiResponse({ status: 404, description: 'Credit note not found' })
|
@ApiResponse({ status: 404, description: 'Credit note not found' })
|
||||||
@ApiResponse({ status: 400, description: 'Invalid input data' })
|
@ApiResponse({ status: 400, description: 'Invalid input data' })
|
||||||
applyCreditNoteToInvoices(@Param('creditNoteId') creditNoteId: number) {
|
applyCreditNoteToInvoices(
|
||||||
return this.getCreditNoteAssociatedAppliedInvoicesService.getCreditAssociatedAppliedInvoices(
|
@Param('creditNoteId') creditNoteId: number,
|
||||||
|
@Body() applyDto: ApplyCreditNoteToInvoicesDto,
|
||||||
|
) {
|
||||||
|
return this.creditNoteApplyToInvoicesService.applyCreditNoteToInvoices(
|
||||||
creditNoteId,
|
creditNoteId,
|
||||||
|
applyDto,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete('applied-invoices/:applyCreditToInvoicesId')
|
||||||
|
@RequirePermission(CreditNoteAction.Edit, AbilitySubject.CreditNote)
|
||||||
|
@ApiOperation({ summary: 'Delete applied credit note to invoice' })
|
||||||
|
@ApiResponse({
|
||||||
|
status: 200,
|
||||||
|
description: 'Credit note application successfully deleted',
|
||||||
|
})
|
||||||
|
@ApiResponse({
|
||||||
|
status: 404,
|
||||||
|
description: 'Credit note application not found',
|
||||||
|
})
|
||||||
|
deleteApplyCreditNoteToInvoices(
|
||||||
|
@Param('applyCreditToInvoicesId') applyCreditToInvoicesId: number,
|
||||||
|
) {
|
||||||
|
return this.deleteCreditNoteApplyToInvoicesService.deleteApplyCreditNoteToInvoices(
|
||||||
|
applyCreditToInvoicesId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { CreditNotesModule } from '../CreditNotes/CreditNotes.module';
|
|||||||
import { GetCreditNoteAssociatedAppliedInvoices } from './queries/GetCreditNoteAssociatedAppliedInvoices.service';
|
import { GetCreditNoteAssociatedAppliedInvoices } from './queries/GetCreditNoteAssociatedAppliedInvoices.service';
|
||||||
import { GetCreditNoteAssociatedInvoicesToApply } from './queries/GetCreditNoteAssociatedInvoicesToApply.service';
|
import { GetCreditNoteAssociatedInvoicesToApply } from './queries/GetCreditNoteAssociatedInvoicesToApply.service';
|
||||||
import { CreditNotesApplyInvoiceController } from './CreditNotesApplyInvoice.controller';
|
import { CreditNotesApplyInvoiceController } from './CreditNotesApplyInvoice.controller';
|
||||||
|
import { CreditNoteApplySyncCreditSubscriber } from './subscribers/CreditNoteApplySyncCreditSubscriber';
|
||||||
|
import { CreditNoteApplySyncInvoicesCreditedAmountSubscriber } from './subscribers/CreditNoteApplySyncInvoicesSubscriber';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [
|
||||||
@@ -19,6 +21,8 @@ import { CreditNotesApplyInvoiceController } from './CreditNotesApplyInvoice.con
|
|||||||
CreditNoteApplySyncCredit,
|
CreditNoteApplySyncCredit,
|
||||||
GetCreditNoteAssociatedAppliedInvoices,
|
GetCreditNoteAssociatedAppliedInvoices,
|
||||||
GetCreditNoteAssociatedInvoicesToApply,
|
GetCreditNoteAssociatedInvoicesToApply,
|
||||||
|
CreditNoteApplySyncCreditSubscriber,
|
||||||
|
CreditNoteApplySyncInvoicesCreditedAmountSubscriber,
|
||||||
],
|
],
|
||||||
exports: [DeleteCustomerLinkedCreditNoteService],
|
exports: [DeleteCustomerLinkedCreditNoteService],
|
||||||
imports: [PaymentsReceivedModule, forwardRef(() => CreditNotesModule)],
|
imports: [PaymentsReceivedModule, forwardRef(() => CreditNotesModule)],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
import { Knex } from 'knex';
|
||||||
import { Injectable, Inject } from '@nestjs/common';
|
import { Injectable, Inject } from '@nestjs/common';
|
||||||
import Bluebird from 'bluebird';
|
import * as Bluebird from 'bluebird';
|
||||||
import { ICreditNoteAppliedToInvoice } from '../types/CreditNoteApplyInvoice.types';
|
import { ICreditNoteAppliedToInvoice } from '../types/CreditNoteApplyInvoice.types';
|
||||||
import { SaleInvoice } from '@/modules/SaleInvoices/models/SaleInvoice';
|
import { SaleInvoice } from '@/modules/SaleInvoices/models/SaleInvoice';
|
||||||
import { CreditNoteAppliedInvoice } from '../models/CreditNoteAppliedInvoice';
|
import { CreditNoteAppliedInvoice } from '../models/CreditNoteAppliedInvoice';
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
|||||||
import { Knex } from 'knex';
|
import { Knex } from 'knex';
|
||||||
import { sumBy } from 'lodash';
|
import { sumBy } from 'lodash';
|
||||||
import {
|
import {
|
||||||
|
ICreditNoteAppliedToInvoice,
|
||||||
ICreditNoteAppliedToInvoiceModel,
|
ICreditNoteAppliedToInvoiceModel,
|
||||||
IApplyCreditToInvoicesDTO,
|
IApplyCreditToInvoicesDTO,
|
||||||
IApplyCreditToInvoicesCreatedPayload,
|
IApplyCreditToInvoicesCreatedPayload,
|
||||||
@@ -17,6 +18,7 @@ import { CreditNote } from '@/modules/CreditNotes/models/CreditNote';
|
|||||||
import { CreditNoteAppliedInvoice } from '../models/CreditNoteAppliedInvoice';
|
import { CreditNoteAppliedInvoice } from '../models/CreditNoteAppliedInvoice';
|
||||||
import { CommandCreditNoteDTOTransform } from '@/modules/CreditNotes/commands/CommandCreditNoteDTOTransform.service';
|
import { CommandCreditNoteDTOTransform } from '@/modules/CreditNotes/commands/CommandCreditNoteDTOTransform.service';
|
||||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ApplyCreditNoteToInvoicesDto } from '../dtos/ApplyCreditNoteToInvoices.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CreditNoteApplyToInvoices {
|
export class CreditNoteApplyToInvoices {
|
||||||
@@ -48,7 +50,7 @@ export class CreditNoteApplyToInvoices {
|
|||||||
*/
|
*/
|
||||||
public async applyCreditNoteToInvoices(
|
public async applyCreditNoteToInvoices(
|
||||||
creditNoteId: number,
|
creditNoteId: number,
|
||||||
applyCreditToInvoicesDTO: IApplyCreditToInvoicesDTO,
|
applyCreditToInvoicesDTO: ApplyCreditNoteToInvoicesDto,
|
||||||
): Promise<CreditNoteAppliedInvoice[]> {
|
): Promise<CreditNoteAppliedInvoice[]> {
|
||||||
// Saves the credit note or throw not found service error.
|
// Saves the credit note or throw not found service error.
|
||||||
const creditNote = await this.creditNoteModel()
|
const creditNote = await this.creditNoteModel()
|
||||||
@@ -71,7 +73,7 @@ export class CreditNoteApplyToInvoices {
|
|||||||
// Validate invoices has remaining amount to apply.
|
// Validate invoices has remaining amount to apply.
|
||||||
this.validateInvoicesRemainingAmount(
|
this.validateInvoicesRemainingAmount(
|
||||||
appliedInvoicesEntries,
|
appliedInvoicesEntries,
|
||||||
creditNoteAppliedModel.amount,
|
creditNoteAppliedModel.entries,
|
||||||
);
|
);
|
||||||
// Validate the credit note remaining amount.
|
// Validate the credit note remaining amount.
|
||||||
this.creditNoteDTOTransform.validateCreditRemainingAmount(
|
this.creditNoteDTOTransform.validateCreditRemainingAmount(
|
||||||
@@ -122,18 +124,20 @@ export class CreditNoteApplyToInvoices {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the invoice remaining amount.
|
* Validate each invoice has sufficient remaining amount for the applied credit.
|
||||||
* @param {ISaleInvoice[]} invoices
|
* @param {ISaleInvoice[]} invoices
|
||||||
* @param {number} amount
|
* @param {ICreditNoteAppliedToInvoice[]} entries
|
||||||
*/
|
*/
|
||||||
private validateInvoicesRemainingAmount = (
|
private validateInvoicesRemainingAmount = (
|
||||||
invoices: SaleInvoice[],
|
invoices: SaleInvoice[],
|
||||||
amount: number,
|
entries: ICreditNoteAppliedToInvoice[],
|
||||||
) => {
|
) => {
|
||||||
const invalidInvoices = invoices.filter(
|
const invoiceMap = new Map(invoices.map((inv) => [inv.id, inv]));
|
||||||
(invoice) => invoice.dueAmount < amount,
|
const invalidEntries = entries.filter((entry) => {
|
||||||
);
|
const invoice = invoiceMap.get(entry.invoiceId);
|
||||||
if (invalidInvoices.length > 0) {
|
return invoice != null && invoice.dueAmount < entry.amount;
|
||||||
|
});
|
||||||
|
if (invalidEntries.length > 0) {
|
||||||
throw new ServiceError(ERRORS.INVOICES_HAS_NO_REMAINING_AMOUNT);
|
throw new ServiceError(ERRORS.INVOICES_HAS_NO_REMAINING_AMOUNT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import {
|
||||||
|
ArrayMinSize,
|
||||||
|
IsArray,
|
||||||
|
IsInt,
|
||||||
|
IsNotEmpty,
|
||||||
|
IsNumber,
|
||||||
|
ValidateNested,
|
||||||
|
} from 'class-validator';
|
||||||
|
|
||||||
|
export class ApplyCreditNoteInvoiceEntryDto {
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsInt()
|
||||||
|
@ApiProperty({ description: 'Invoice ID to apply credit to', example: 1 })
|
||||||
|
invoiceId: number;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsNumber()
|
||||||
|
@ApiProperty({ description: 'Amount to apply', example: 100.5 })
|
||||||
|
amount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ApplyCreditNoteToInvoicesDto {
|
||||||
|
@IsArray()
|
||||||
|
@ArrayMinSize(1)
|
||||||
|
@ValidateNested({ each: true })
|
||||||
|
@Type(() => ApplyCreditNoteInvoiceEntryDto)
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'Entries of invoice ID and amount to apply',
|
||||||
|
type: [ApplyCreditNoteInvoiceEntryDto],
|
||||||
|
example: [
|
||||||
|
{ invoice_id: 1, amount: 100.5 },
|
||||||
|
{ invoice_id: 2, amount: 50 },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
entries: ApplyCreditNoteInvoiceEntryDto[];
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import { CreditNoteApplySyncInvoicesCreditedAmount } from '../commands/CreditNot
|
|||||||
import { events } from '@/common/events/events';
|
import { events } from '@/common/events/events';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class CreditNoteApplySyncInvoicesCreditedAmountSubscriber {
|
export class CreditNoteApplySyncInvoicesCreditedAmountSubscriber {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly syncInvoicesWithCreditNote: CreditNoteApplySyncInvoicesCreditedAmount,
|
private readonly syncInvoicesWithCreditNote: CreditNoteApplySyncInvoicesCreditedAmount,
|
||||||
) {}
|
) {}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface IApplyCreditToInvoicesDeletedPayload {
|
|||||||
export interface ICreditNoteAppliedToInvoice {
|
export interface ICreditNoteAppliedToInvoice {
|
||||||
amount: number;
|
amount: number;
|
||||||
creditNoteId: number;
|
creditNoteId: number;
|
||||||
|
invoiceId: number;
|
||||||
}
|
}
|
||||||
export interface ICreditNoteAppliedToInvoiceModel {
|
export interface ICreditNoteAppliedToInvoiceModel {
|
||||||
amount: number;
|
amount: number;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import Bluebird from 'bluebird';
|
import * as Bluebird from 'bluebird';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Knex } from 'knex';
|
import { Knex } from 'knex';
|
||||||
import { IVendorCreditAppliedBill } from '../types/VendorCreditApplyBills.types';
|
import { IVendorCreditAppliedBill } from '../types/VendorCreditApplyBills.types';
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
.root {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title{
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 600;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
color: #252A31;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description{
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 1.45;
|
|
||||||
color: #404854;
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { Button, Intent } from '@blueprintjs/core';
|
import { Button, Intent } from '@blueprintjs/core';
|
||||||
|
import { x } from '@xstyled/emotion';
|
||||||
import AuthInsider from './AuthInsider';
|
import AuthInsider from './AuthInsider';
|
||||||
import { AuthInsiderCard } from './_components';
|
import { AuthInsiderCard } from './_components';
|
||||||
import styles from './RegisterVerify.module.scss';
|
|
||||||
import { AppToaster, Stack } from '@/components';
|
import { AppToaster, Stack } from '@/components';
|
||||||
import { useAuthActions, useAuthUserVerifyEmail } from '@/hooks/state';
|
import { useAuthActions, useAuthUserVerifyEmail } from '@/hooks/state';
|
||||||
import { useAuthSignUpVerifyResendMail } from '@/hooks/query';
|
import { useAuthSignUpVerifyResendMail } from '@/hooks/query';
|
||||||
import { AuthContainer } from './AuthContainer';
|
import { AuthContainer } from './AuthContainer';
|
||||||
|
import { useIsDarkMode } from '@/hooks/useDarkMode';
|
||||||
|
|
||||||
export default function RegisterVerify() {
|
export default function RegisterVerify() {
|
||||||
const { setLogout } = useAuthActions();
|
const { setLogout } = useAuthActions();
|
||||||
@@ -14,6 +15,7 @@ export default function RegisterVerify() {
|
|||||||
useAuthSignUpVerifyResendMail();
|
useAuthSignUpVerifyResendMail();
|
||||||
|
|
||||||
const emailAddress = useAuthUserVerifyEmail();
|
const emailAddress = useAuthUserVerifyEmail();
|
||||||
|
const isDarkMode = useIsDarkMode();
|
||||||
|
|
||||||
const handleResendMailBtnClick = () => {
|
const handleResendMailBtnClick = () => {
|
||||||
resendSignUpVerifyMail()
|
resendSignUpVerifyMail()
|
||||||
@@ -37,12 +39,24 @@ export default function RegisterVerify() {
|
|||||||
return (
|
return (
|
||||||
<AuthContainer>
|
<AuthContainer>
|
||||||
<AuthInsider>
|
<AuthInsider>
|
||||||
<AuthInsiderCard className={styles.root}>
|
<AuthInsiderCard textAlign="center">
|
||||||
<h2 className={styles.title}>Please verify your email</h2>
|
<x.h2
|
||||||
<p className={styles.description}>
|
fontSize="18px"
|
||||||
|
fontWeight={600}
|
||||||
|
mb="0.5rem"
|
||||||
|
color={isDarkMode ? 'rgba(255, 255, 255, 0.85)' : '#252A31'}
|
||||||
|
>
|
||||||
|
Please verify your email
|
||||||
|
</x.h2>
|
||||||
|
<x.p
|
||||||
|
mb="1rem"
|
||||||
|
fontSize="15px"
|
||||||
|
lineHeight="1.45"
|
||||||
|
color={isDarkMode ? 'rgba(255, 255, 255, 0.7)' : '#404854'}
|
||||||
|
>
|
||||||
We sent an email to <strong>{emailAddress}</strong> Click the link
|
We sent an email to <strong>{emailAddress}</strong> Click the link
|
||||||
inside to get started.
|
inside to get started.
|
||||||
</p>
|
</x.p>
|
||||||
|
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -58,16 +58,13 @@ export function useCreateCreditNote(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((values) => apiRequest.post('credit-notes', values), {
|
||||||
(values) => apiRequest.post('credit-notes', values),
|
|
||||||
{
|
|
||||||
onSuccess: (res, values) => {
|
onSuccess: (res, values) => {
|
||||||
// Common invalidate queries.
|
// Common invalidate queries.
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
},
|
},
|
||||||
...props,
|
...props,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,8 +215,7 @@ export function useCreateRefundCreditNote(props) {
|
|||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
([id, values]) =>
|
([id, values]) => apiRequest.post(`credit-notes/${id}/refunds`, values),
|
||||||
apiRequest.post(`credit-notes/${id}/refunds`, values),
|
|
||||||
{
|
{
|
||||||
onSuccess: (res, [id, values]) => {
|
onSuccess: (res, [id, values]) => {
|
||||||
// Common invalidate queries.
|
// Common invalidate queries.
|
||||||
@@ -240,9 +236,7 @@ export function useDeleteRefundCreditNote(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((id) => apiRequest.delete(`credit-notes/refunds/${id}`), {
|
||||||
(id) => apiRequest.delete(`credit-notes/refunds/${id}`),
|
|
||||||
{
|
|
||||||
onSuccess: (res, id) => {
|
onSuccess: (res, id) => {
|
||||||
// Common invalidate queries.
|
// Common invalidate queries.
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
@@ -251,8 +245,7 @@ export function useDeleteRefundCreditNote(props) {
|
|||||||
queryClient.invalidateQueries([t.CREDIT_NOTE, id]);
|
queryClient.invalidateQueries([t.CREDIT_NOTE, id]);
|
||||||
},
|
},
|
||||||
...props,
|
...props,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,7 +294,7 @@ export function useReconcileCreditNote(id, props, requestProps) {
|
|||||||
[t.RECONCILE_CREDIT_NOTE, id],
|
[t.RECONCILE_CREDIT_NOTE, id],
|
||||||
{
|
{
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `credit-notes/${id}/applied-invoices`,
|
url: `credit-notes/${id}/apply-invoices`,
|
||||||
...requestProps,
|
...requestProps,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user