mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
Compare commits
4 Commits
swagger
...
revert-664
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9aa24e6fd | ||
|
|
216a8c1cac | ||
|
|
6d24474162 | ||
|
|
5962b990c4 |
@@ -109,7 +109,6 @@
|
|||||||
"rtl-detect": "^1.0.4",
|
"rtl-detect": "^1.0.4",
|
||||||
"socket.io": "^4.7.4",
|
"socket.io": "^4.7.4",
|
||||||
"source-map-loader": "^4.0.1",
|
"source-map-loader": "^4.0.1",
|
||||||
"swagger-ui-express": "^5.0.1",
|
|
||||||
"tmp-promise": "^3.0.3",
|
"tmp-promise": "^3.0.3",
|
||||||
"ts-transformer-keys": "^0.4.2",
|
"ts-transformer-keys": "^0.4.2",
|
||||||
"tsyringe": "^4.3.0",
|
"tsyringe": "^4.3.0",
|
||||||
|
|||||||
@@ -5,14 +5,7 @@ import { body, param } from 'express-validator';
|
|||||||
import BaseController from '@/api/controllers/BaseController';
|
import BaseController from '@/api/controllers/BaseController';
|
||||||
import { AttachmentsApplication } from '@/services/Attachments/AttachmentsApplication';
|
import { AttachmentsApplication } from '@/services/Attachments/AttachmentsApplication';
|
||||||
import { AttachmentUploadPipeline } from '@/services/Attachments/S3UploadPipeline';
|
import { AttachmentUploadPipeline } from '@/services/Attachments/S3UploadPipeline';
|
||||||
import {
|
|
||||||
ApiOperation,
|
|
||||||
ApiResponse,
|
|
||||||
ApiTags,
|
|
||||||
Route,
|
|
||||||
} from '@/decorators/swagger-decorators';
|
|
||||||
|
|
||||||
@ApiTags('Attachments')
|
|
||||||
@Service()
|
@Service()
|
||||||
export class AttachmentsController extends BaseController {
|
export class AttachmentsController extends BaseController {
|
||||||
@Inject()
|
@Inject()
|
||||||
@@ -128,26 +121,6 @@ export class AttachmentsController extends BaseController {
|
|||||||
* @param {NextFunction} next
|
* @param {NextFunction} next
|
||||||
* @returns {Promise<Response|void>}
|
* @returns {Promise<Response|void>}
|
||||||
*/
|
*/
|
||||||
@ApiResponse({
|
|
||||||
status: 200,
|
|
||||||
description: 'Details of the given attachement',
|
|
||||||
schema: {
|
|
||||||
type: 'array',
|
|
||||||
items: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
id: { type: 'string' },
|
|
||||||
name: { type: 'string' },
|
|
||||||
email: { type: 'string' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@ApiOperation({
|
|
||||||
summary: 'Retrieve a specific details of attachment',
|
|
||||||
description: 'Get all registered users',
|
|
||||||
})
|
|
||||||
@Route('/attachments/:id')
|
|
||||||
private async getAttachment(
|
private async getAttachment(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
|
|||||||
@@ -8,11 +8,6 @@ import { IItemDTO, ItemAction, AbilitySubject } from '@/interfaces';
|
|||||||
import { DATATYPES_LENGTH } from '@/data/DataTypes';
|
import { DATATYPES_LENGTH } from '@/data/DataTypes';
|
||||||
import CheckAbilities from '@/api/middleware/CheckPolicies';
|
import CheckAbilities from '@/api/middleware/CheckPolicies';
|
||||||
import { ItemsApplication } from '@/services/Items/ItemsApplication';
|
import { ItemsApplication } from '@/services/Items/ItemsApplication';
|
||||||
import {
|
|
||||||
ApiOperation,
|
|
||||||
ApiResponse,
|
|
||||||
Route,
|
|
||||||
} from '@/decorators/swagger-decorators';
|
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class ItemsController extends BaseController {
|
export default class ItemsController extends BaseController {
|
||||||
@@ -203,22 +198,6 @@ export default class ItemsController extends BaseController {
|
|||||||
* @param {Request} req
|
* @param {Request} req
|
||||||
* @param {Response} res
|
* @param {Response} res
|
||||||
*/
|
*/
|
||||||
@ApiResponse({
|
|
||||||
status: 200,
|
|
||||||
description: 'Details of the given attachement',
|
|
||||||
schema: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
id: { type: 'string' },
|
|
||||||
name: { type: 'string' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@ApiOperation({
|
|
||||||
summary: 'Creates a new item (inventory or service)',
|
|
||||||
description: 'Get all registered users',
|
|
||||||
})
|
|
||||||
@Route('/items')
|
|
||||||
private async newItem(req: Request, res: Response, next: NextFunction) {
|
private async newItem(req: Request, res: Response, next: NextFunction) {
|
||||||
const { tenantId } = req;
|
const { tenantId } = req;
|
||||||
const itemDTO: IItemDTO = this.matchedBodyData(req);
|
const itemDTO: IItemDTO = this.matchedBodyData(req);
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ export interface ICashflowTransactionUncategorizedPayload {
|
|||||||
tenantId: number;
|
tenantId: number;
|
||||||
uncategorizedTransactionId: number;
|
uncategorizedTransactionId: number;
|
||||||
uncategorizedTransactions: Array<IUncategorizedCashflowTransaction>;
|
uncategorizedTransactions: Array<IUncategorizedCashflowTransaction>;
|
||||||
|
oldMainUncategorizedTransaction: IUncategorizedCashflowTransaction;
|
||||||
oldUncategorizedTransactions: Array<IUncategorizedCashflowTransaction>;
|
oldUncategorizedTransactions: Array<IUncategorizedCashflowTransaction>;
|
||||||
trx: Knex.Transaction;
|
trx: Knex.Transaction;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,22 +33,25 @@ export class UncategorizeCashflowTransaction {
|
|||||||
): Promise<Array<number>> {
|
): Promise<Array<number>> {
|
||||||
const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId);
|
const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
const oldUncategorizedTransaction =
|
const oldMainUncategorizedTransaction =
|
||||||
await UncategorizedCashflowTransaction.query()
|
await UncategorizedCashflowTransaction.query()
|
||||||
.findById(uncategorizedTransactionId)
|
.findById(uncategorizedTransactionId)
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
validateTransactionShouldBeCategorized(oldUncategorizedTransaction);
|
validateTransactionShouldBeCategorized(oldMainUncategorizedTransaction);
|
||||||
|
|
||||||
const associatedUncategorizedTransactions =
|
const associatedUncategorizedTransactions =
|
||||||
await UncategorizedCashflowTransaction.query()
|
await UncategorizedCashflowTransaction.query()
|
||||||
.where('categorizeRefId', oldUncategorizedTransaction.categorizeRefId)
|
.where('categorizeRefId', oldMainUncategorizedTransaction.categorizeRefId)
|
||||||
.where(
|
.where(
|
||||||
'categorizeRefType',
|
'categorizeRefType',
|
||||||
oldUncategorizedTransaction.categorizeRefType
|
oldMainUncategorizedTransaction.categorizeRefType
|
||||||
);
|
)
|
||||||
|
// Exclude the main transaction.
|
||||||
|
.whereNot('id', uncategorizedTransactionId);
|
||||||
|
|
||||||
const oldUncategorizedTransactions = [
|
const oldUncategorizedTransactions = [
|
||||||
oldUncategorizedTransaction,
|
oldMainUncategorizedTransaction,
|
||||||
...associatedUncategorizedTransactions,
|
...associatedUncategorizedTransactions,
|
||||||
];
|
];
|
||||||
const oldUncategoirzedTransactionsIds = oldUncategorizedTransactions.map(
|
const oldUncategoirzedTransactionsIds = oldUncategorizedTransactions.map(
|
||||||
@@ -85,6 +88,7 @@ export class UncategorizeCashflowTransaction {
|
|||||||
{
|
{
|
||||||
tenantId,
|
tenantId,
|
||||||
uncategorizedTransactionId,
|
uncategorizedTransactionId,
|
||||||
|
oldMainUncategorizedTransaction,
|
||||||
uncategorizedTransactions,
|
uncategorizedTransactions,
|
||||||
oldUncategorizedTransactions,
|
oldUncategorizedTransactions,
|
||||||
trx,
|
trx,
|
||||||
|
|||||||
@@ -22,32 +22,25 @@ export class DeleteCashflowTransactionOnUncategorize {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the cashflow transaction on uncategorize transaction.
|
* Deletes the cashflow transaction once uncategorize the bank transaction.
|
||||||
* @param {ICashflowTransactionUncategorizedPayload} payload
|
* @param {ICashflowTransactionUncategorizedPayload} payload
|
||||||
*/
|
*/
|
||||||
public async deleteCashflowTransactionOnUncategorize({
|
public async deleteCashflowTransactionOnUncategorize({
|
||||||
tenantId,
|
tenantId,
|
||||||
oldUncategorizedTransactions,
|
oldMainUncategorizedTransaction,
|
||||||
trx,
|
trx,
|
||||||
}: ICashflowTransactionUncategorizedPayload) {
|
}: ICashflowTransactionUncategorizedPayload) {
|
||||||
const _oldUncategorizedTransactions = oldUncategorizedTransactions.filter(
|
// Cannot continue if the main transaction does not reference to cashflow type.
|
||||||
(transaction) => transaction.categorizeRefType === 'CashflowTransaction'
|
if (
|
||||||
);
|
oldMainUncategorizedTransaction.categorizeRefType !==
|
||||||
|
'CashflowTransaction'
|
||||||
// Deletes the cashflow transaction.
|
) {
|
||||||
if (_oldUncategorizedTransactions.length > 0) {
|
return;
|
||||||
const result = await PromisePool.withConcurrency(1)
|
|
||||||
.for(_oldUncategorizedTransactions)
|
|
||||||
.process(async (oldUncategorizedTransaction) => {
|
|
||||||
await this.deleteCashflowTransactionService.deleteCashflowTransaction(
|
|
||||||
tenantId,
|
|
||||||
oldUncategorizedTransaction.categorizeRefId,
|
|
||||||
trx
|
|
||||||
);
|
|
||||||
});
|
|
||||||
if (result.errors.length > 0) {
|
|
||||||
throw new ServiceError('SOMETHING_WRONG');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
await this.deleteCashflowTransactionService.deleteCashflowTransaction(
|
||||||
|
tenantId,
|
||||||
|
oldMainUncategorizedTransaction.categorizeRefId,
|
||||||
|
trx
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
pnpm-lock.yaml
generated
17
pnpm-lock.yaml
generated
@@ -302,9 +302,6 @@ importers:
|
|||||||
source-map-loader:
|
source-map-loader:
|
||||||
specifier: ^4.0.1
|
specifier: ^4.0.1
|
||||||
version: 4.0.2(webpack@5.91.0)
|
version: 4.0.2(webpack@5.91.0)
|
||||||
swagger-ui-express:
|
|
||||||
specifier: ^5.0.1
|
|
||||||
version: 5.0.1(express@4.19.2)
|
|
||||||
tmp-promise:
|
tmp-promise:
|
||||||
specifier: ^3.0.3
|
specifier: ^3.0.3
|
||||||
version: 3.0.3
|
version: 3.0.3
|
||||||
@@ -24211,20 +24208,6 @@ packages:
|
|||||||
stable: 0.1.8
|
stable: 0.1.8
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/swagger-ui-dist@5.17.14:
|
|
||||||
resolution: {integrity: sha512-CVbSfaLpstV65OnSjbXfVd6Sta3q3F7Cj/yYuvHMp1P90LztOLs6PfUnKEVAeiIVQt9u2SaPwv0LiH/OyMjHRw==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/swagger-ui-express@5.0.1(express@4.19.2):
|
|
||||||
resolution: {integrity: sha512-SrNU3RiBGTLLmFU8GIJdOdanJTl4TOmT27tt3bWWHppqYmAZ6IDuEuBvMU6nZq0zLEe6b/1rACXCgLZqO6ZfrA==}
|
|
||||||
engines: {node: '>= v0.10.32'}
|
|
||||||
peerDependencies:
|
|
||||||
express: '>=4.0.0 || >=5.0.0-beta'
|
|
||||||
dependencies:
|
|
||||||
express: 4.19.2
|
|
||||||
swagger-ui-dist: 5.17.14
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/symbol-observable@1.2.0:
|
/symbol-observable@1.2.0:
|
||||||
resolution: {integrity: sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==}
|
resolution: {integrity: sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|||||||
Reference in New Issue
Block a user