Skip to content

Commit

Permalink
🐛 Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jun 16, 2024
1 parent 1ff3be3 commit 1dea0ee
Show file tree
Hide file tree
Showing 227 changed files with 3,336 additions and 3,668 deletions.
4 changes: 2 additions & 2 deletions packages/api/scripts/commonObject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ EOF
import { Injectable, OnModuleInit } from '@nestjs/common';
import { LoggerService } from '@@core/logger/logger.service';
import { PrismaService } from '@@core/prisma/prisma.service';
import { ReferenceError } from '@@core/utils/errors';
import { Cron } from '@nestjs/schedule';
import { ApiResponse } from '@@core/utils/types';
import { v4 as uuidv4 } from 'uuid';
Expand Down Expand Up @@ -203,7 +203,7 @@ EOF
cat > "types/mappingsTypes.ts" <<EOF
export const ${objectType}UnificationMapping = {
}; */
};
EOF

cat > "types/model.unified.ts" <<EOF
Expand Down
62 changes: 56 additions & 6 deletions packages/api/src/accounting/@lib/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ import { phonenumberUnificationMapping } from '@accounting/phonenumber/types/map

import { purchaseorderUnificationMapping } from '@accounting/purchaseorder/types/mappingsTypes';

import { ITaxrateService } from '@accounting/taxrate/types';
import { ITaxRateService } from '@accounting/taxrate/types';
import { taxrateUnificationMapping } from '@accounting/taxrate/types/mappingsTypes';
import {
UnifiedTaxrateInput,
UnifiedTaxrateOutput,
UnifiedTaxRateInput,
UnifiedTaxRateOutput,
} from '@accounting/taxrate/types/model.unified';
import { trackingcategoryUnificationMapping } from '@accounting/trackingcategory/types/mappingsTypes';

Expand All @@ -60,6 +60,56 @@ import {
UnifiedContactInput,
UnifiedContactOutput,
} from '@accounting/contact/types/model.unified';
import {
UnifiedBalanceSheetInput,
UnifiedBalanceSheetOutput,
} from '@accounting/balancesheet/types/model.unified';
import {
UnifiedCashflowStatementInput,
UnifiedCashflowStatementOutput,
} from '@accounting/cashflowstatement/types/model.unified';
import {
UnifiedCompanyInfoInput,
UnifiedCompanyInfoOutput,
} from '@accounting/companyinfo/types/model.unified';
import {
UnifiedCreditNoteInput,
UnifiedCreditNoteOutput,
} from '@accounting/creditnote/types/model.unified';
import {
UnifiedIncomeStatementInput,
UnifiedIncomeStatementOutput,
} from '@accounting/incomestatement/types/model.unified';
import {
UnifiedJournalEntryInput,
UnifiedJournalEntryOutput,
} from '@accounting/journalentry/types/model.unified';
import {
UnifiedPhoneNumberInput,
UnifiedPhoneNumberOutput,
} from '@accounting/phonenumber/types/model.unified';
import {
UnifiedPurchaseOrderInput,
UnifiedPurchaseOrderOutput,
} from '@accounting/purchaseorder/types/model.unified';
import {
UnifiedTrackingCategoryInput,
UnifiedTrackingCategoryOutput,
} from '@accounting/trackingcategory/types/model.unified';
import {
UnifiedVendorCreditInput,
UnifiedVendorCreditOutput,
} from '@accounting/vendorcredit/types/model.unified';
import { IBalanceSheetService } from '@accounting/balancesheet/types';
import { ICashflowStatementService } from '@accounting/cashflowstatement/types';
import { ICreditNoteService } from '@accounting/creditnote/types';
import { IJournalEntryService } from '@accounting/journalentry/types';
import { IIncomeStatementService } from '@accounting/incomestatement/types';
import { IPurchaseOrderService } from '@accounting/purchaseorder/types';
import { ITrackingCategoryService } from '@accounting/trackingcategory/types';
import { IVendorCreditService } from '@accounting/vendorcredit/types';
import { ICompanyInfoService } from '@accounting/companyinfo/types';
import { IPhoneNumberService } from '@accounting/phonenumber/types';

export enum AccountingObject {
balancesheet = 'balancesheet',
Expand Down Expand Up @@ -108,8 +158,8 @@ export type UnifiedAccounting =
| UnifiedPhoneNumberOutput
| UnifiedPurchaseOrderInput
| UnifiedPurchaseOrderOutput
| UnifiedTaxrateInput
| UnifiedTaxrateOutput
| UnifiedTaxRateInput
| UnifiedTaxRateOutput
| UnifiedTrackingCategoryInput
| UnifiedTrackingCategoryOutput
| UnifiedTransactionInput
Expand Down Expand Up @@ -151,7 +201,7 @@ export type IAccountingService =
| IPaymentService
| IPhoneNumberService
| IPurchaseOrderService
| ITaxrateService
| ITaxRateService
| ITrackingCategoryService
| ITransactionService
| IVendorCreditService;
2 changes: 1 addition & 1 deletion packages/api/src/accounting/@lib/@unification/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountingObject, unificationMapping } from '@accounting/@lib/@types';
import { Unified, UnifyReturnType } from '@@core/utils/types';
import { UnifySourceType } from '@@core/utils/types/unify.output';
import { UnifySourceType } from '@@core/utils/types/unify.ookl;:utput';
import { AccountingObjectInput } from '@@core/utils/types/original/original.accounting';

export async function desunifyAccounting<T extends Unified>({
Expand Down
46 changes: 17 additions & 29 deletions packages/api/src/accounting/account/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ import {
ApiHeader,
} from '@nestjs/swagger';
import { ApiCustomResponse } from '@@core/utils/types';
import { AccountService } from './services/account.service';
import { UnifiedAccountInput, UnifiedAccountOutput } from './types/model.unified';
import {
UnifiedAccountInput,
UnifiedAccountOutput,
} from './types/model.unified';
import { ConnectionUtils } from '@@core/connections/@utils';
import { AccountService } from './services/account.service';

@ApiTags('accounting/account')
@Controller('accounting/account')
Expand All @@ -38,7 +41,7 @@ export class AccountController {
operationId: 'getAccounts',
summary: 'List a batch of Accounts',
})
@ApiHeader({
@ApiHeader({
name: 'x-connection-token',
required: true,
description: 'The connection token',
Expand All @@ -58,17 +61,17 @@ export class AccountController {
@Headers('x-connection-token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
) {
try{
try {
const { linkedUserId, remoteSource } =
await this.connectionUtils.getConnectionMetadataFromConnectionToken(
connection_token,
);
);
return this.accountService.getAccounts(
remoteSource,
linkedUserId,
remote_data,
);
}catch(error){
} catch (error) {
throw new Error(error);
}
}
Expand Down Expand Up @@ -106,7 +109,7 @@ export class AccountController {
summary: 'Create a Account',
description: 'Create a account in any supported Accounting software',
})
@ApiHeader({
@ApiHeader({
name: 'x-connection-token',
required: true,
description: 'The connection token',
Expand All @@ -128,18 +131,18 @@ export class AccountController {
@Headers('x-connection-token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
) {
try{
try {
const { linkedUserId, remoteSource } =
await this.connectionUtils.getConnectionMetadataFromConnectionToken(
connection_token,
);
);
return this.accountService.addAccount(
unifiedAccountData,
remoteSource,
linkedUserId,
remote_data,
);
}catch(error){
} catch (error) {
throw new Error(error);
}
}
Expand All @@ -148,7 +151,7 @@ export class AccountController {
operationId: 'addAccounts',
summary: 'Add a batch of Accounts',
})
@ApiHeader({
@ApiHeader({
name: 'x-connection-token',
required: true,
description: 'The connection token',
Expand All @@ -170,34 +173,19 @@ export class AccountController {
@Headers('connection_token') connection_token: string,
@Query('remote_data') remote_data?: boolean,
) {
try{
try {
const { linkedUserId, remoteSource } =
await this.connectionUtils.getConnectionMetadataFromConnectionToken(
connection_token,
);
);
return this.accountService.batchAddAccounts(
unfiedAccountData,
remoteSource,
linkedUserId,
remote_data,
);
}catch(error){
} catch (error) {
throw new Error(error);
}

}

@ApiOperation({
operationId: 'updateAccount',
summary: 'Update a Account',
})
@ApiCustomResponse(UnifiedAccountOutput)
//@UseGuards(ApiKeyAuthGuard)
@Patch()
updateAccount(
@Query('id') id: string,
@Body() updateAccountData: Partial<UnifiedAccountInput>,
) {
return this.accountService.updateAccount(id, updateAccountData);
}
}
4 changes: 1 addition & 3 deletions packages/api/src/accounting/account/account.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Module } from '@nestjs/common';
import { AccountController } from './account.controller';
import { SyncService } from './sync/sync.service';
import { LoggerService } from '@@core/logger/logger.service';
import { AccountService } from './services/account.service';
import { ServiceRegistry } from './services/registry.service';
import { EncryptionService } from '@@core/encryption/encryption.service';
import { FieldMappingService } from '@@core/field-mapping/field-mapping.service';
import { PrismaService } from '@@core/prisma/prisma.service';
import { WebhookService } from '@@core/webhook/webhook.service';
import { BullModule } from '@nestjs/bull';
import { AccountService } from './services/account.service';

@Module({
imports: [
Expand All @@ -27,9 +27,7 @@ import { BullModule } from '@nestjs/bull';
FieldMappingService,
ServiceRegistry,
/* PROVIDERS SERVICES */

],
exports: [SyncService],
})
export class AccountModule {}

62 changes: 62 additions & 0 deletions packages/api/src/accounting/account/services/account.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from '@@core/prisma/prisma.service';
import { LoggerService } from '@@core/logger/logger.service';
import { v4 as uuidv4 } from 'uuid';
import { ApiResponse } from '@@core/utils/types';
import { throwTypedError } from '@@core/utils/errors';
import { WebhookService } from '@@core/webhook/webhook.service';
import {
UnifiedAccountInput,
UnifiedAccountOutput,
} from '../types/model.unified';
import { desunify } from '@@core/utils/unification/desunify';
import { FieldMappingService } from '@@core/field-mapping/field-mapping.service';
import { ServiceRegistry } from './registry.service';
import { unify } from '@@core/utils/unification/unify';
import { IAccountService } from '../types';

@Injectable()
export class AccountService {
constructor(
private prisma: PrismaService,
private logger: LoggerService,
private webhook: WebhookService,
private fieldMappingService: FieldMappingService,
private serviceRegistry: ServiceRegistry,
) {
this.logger.setContext(AccountService.name);
}

async batchAddAccounts(
unifiedAccountData: UnifiedAccountInput[],
integrationId: string,
linkedUserId: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput[]> {
return;
}

async addAccount(
unifiedAccountData: UnifiedAccountInput,
integrationId: string,
linkedUserId: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput> {
return;
}

async getAccount(
id_accounting_account: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput> {
return;
}

async getAccounts(
integrationId: string,
linkedUserId: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput[]> {
return;
}
}
66 changes: 0 additions & 66 deletions packages/api/src/accounting/account/services/registry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,69 +21,3 @@ export class ServiceRegistry {
return service;
}
}
EOF

cat > "services/account.service.ts" <<EOF
import { Injectable } from '@nestjs/common';
import { PrismaService } from '@@core/prisma/prisma.service';
import { LoggerService } from '@@core/logger/logger.service';
import { v4 as uuidv4 } from 'uuid';
import { ApiResponse } from '@@core/utils/types';
import { throwTypedError, UnifiedAccountingError } from '@@core/utils/errors';
import { WebhookService } from '@@core/webhook/webhook.service';
import { UnifiedAccountInput, UnifiedAccountOutput } from '../types/model.unified';
import { desunify } from '@@core/utils/unification/desunify';
import { FieldMappingService } from '@@core/field-mapping/field-mapping.service';
import { ServiceRegistry } from './registry.service';
import { OriginalAccountOutput } from '@@core/utils/types/original/original.accounting';
import { unify } from '@@core/utils/unification/unify';
import { IAccountService } from '../types';

@Injectable()
export class AccountService {
constructor(
private prisma: PrismaService,
private logger: LoggerService,
private webhook: WebhookService,
private fieldMappingService: FieldMappingService,
private serviceRegistry: ServiceRegistry,
) {
this.logger.setContext(AccountService.name);
}

async batchAddAccounts(
unifiedAccountData: UnifiedAccountInput[],
integrationId: string,
linkedUserId: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput[]> {
return;
}

async addAccount(
unifiedAccountData: UnifiedAccountInput,
integrationId: string,
linkedUserId: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput> {
return;
}

async getAccount(
id_accounting_account: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput> {
return;

}


async getAccounts(
integrationId: string,
linkedUserId: string,
remote_data?: boolean,
): Promise<UnifiedAccountOutput[]> {
return;

}
}
Loading

0 comments on commit 1dea0ee

Please sign in to comment.