mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: e2e test cases
This commit is contained in:
@@ -4,8 +4,6 @@ import { Request, Response, NextFunction } from 'express';
|
||||
@Injectable()
|
||||
export class LoggerMiddleware implements NestMiddleware {
|
||||
use(req: Request, res: Response, next: NextFunction) {
|
||||
console.log(`Request...`);
|
||||
|
||||
// @ts-expect-error
|
||||
req.test = 'test';
|
||||
next();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { forwardRef, Module } from '@nestjs/common';
|
||||
import { CreateBankRuleService } from './commands/CreateBankRule.service';
|
||||
import { EditBankRuleService } from './commands/EditBankRule.service';
|
||||
import { DeleteBankRuleService } from './commands/DeleteBankRule.service';
|
||||
@@ -11,6 +11,7 @@ import { BankRule } from './models/BankRule';
|
||||
import { BankRulesController } from './BankRules.controller';
|
||||
import { UnlinkBankRuleOnDeleteBankRuleSubscriber } from './events/UnlinkBankRuleOnDeleteBankRule';
|
||||
import { DeleteBankRulesService } from './commands/DeleteBankRules.service';
|
||||
import { BankingTransactionsRegonizeModule } from '../BankingTranasctionsRegonize/BankingTransactionsRegonize.module';
|
||||
|
||||
const models = [
|
||||
RegisterTenancyModel(BankRule),
|
||||
@@ -19,7 +20,7 @@ const models = [
|
||||
|
||||
@Module({
|
||||
controllers: [BankRulesController],
|
||||
imports: [],
|
||||
imports: [forwardRef(() => BankingTransactionsRegonizeModule)],
|
||||
providers: [
|
||||
...models,
|
||||
CreateBankRuleService,
|
||||
|
||||
@@ -6,7 +6,9 @@ import { OnEvent } from '@nestjs/event-emitter';
|
||||
|
||||
@Injectable()
|
||||
export class UnlinkBankRuleOnDeleteBankRuleSubscriber {
|
||||
private revertRecognizedTransactionsService: RevertRecognizedTransactionsService;
|
||||
constructor(
|
||||
private readonly revertRecognizedTransactionsService: RevertRecognizedTransactionsService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Unlinks the bank rule out of recognized transactions.
|
||||
@@ -17,7 +19,7 @@ export class UnlinkBankRuleOnDeleteBankRuleSubscriber {
|
||||
oldBankRule,
|
||||
}: IBankRuleEventDeletingPayload) {
|
||||
await this.revertRecognizedTransactionsService.revertRecognizedTransactions(
|
||||
oldBankRule.id
|
||||
oldBankRule.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { forwardRef, Module } from '@nestjs/common';
|
||||
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
||||
import { RecognizedBankTransaction } from './models/RecognizedBankTransaction';
|
||||
import { GetAutofillCategorizeTransactionService } from './queries/GetAutofillCategorizeTransaction.service';
|
||||
@@ -11,7 +11,7 @@ import { BankRulesModule } from '../BankRules/BankRules.module';
|
||||
const models = [RegisterTenancyModel(RecognizedBankTransaction)];
|
||||
|
||||
@Module({
|
||||
imports: [BankingTransactionsModule, BankRulesModule],
|
||||
imports: [BankingTransactionsModule, forwardRef(() => BankRulesModule)],
|
||||
providers: [
|
||||
...models,
|
||||
GetAutofillCategorizeTransactionService,
|
||||
|
||||
@@ -162,9 +162,9 @@ export class CreditNoteGL {
|
||||
public getCreditNoteGLEntries(): ILedgerEntry[] {
|
||||
const AREntry = this.creditNoteAREntry;
|
||||
|
||||
const getItemEntry = this.getCreditNoteItemEntry;
|
||||
const itemsEntries = this.creditNoteModel.entries.map(getItemEntry);
|
||||
|
||||
const itemsEntries = this.creditNoteModel.entries.map((entry, index) =>
|
||||
this.getCreditNoteItemEntry(entry, index),
|
||||
);
|
||||
const discountEntry = this.discountEntry;
|
||||
const adjustmentEntry = this.adjustmentEntry;
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@ import { ITransactionsLockingAllDTO } from './types/TransactionsLocking.types';
|
||||
import { ICancelTransactionsLockingDTO } from './types/TransactionsLocking.types';
|
||||
import { ITransactionLockingPartiallyDTO } from './types/TransactionsLocking.types';
|
||||
import { QueryTransactionsLocking } from './queries/QueryTransactionsLocking';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
|
||||
@Controller('transactions-locking')
|
||||
@PublicRoute()
|
||||
export class TransactionsLockingController {
|
||||
constructor(
|
||||
private readonly transactionsLockingService: TransactionsLockingService,
|
||||
@@ -74,13 +76,15 @@ export class TransactionsLockingController {
|
||||
};
|
||||
}
|
||||
|
||||
// @Get(':module')
|
||||
// async getTransactionLockingMeta(@Param('module') module: string) {
|
||||
// return await this.queryTransactionsLocking.getTransactionsLocking(module);
|
||||
// }
|
||||
|
||||
@Get()
|
||||
@Get('/')
|
||||
async getTransactionLockingMetaList() {
|
||||
return await this.queryTransactionsLocking.getTransactionsLockingAll();
|
||||
}
|
||||
|
||||
@Get(':module')
|
||||
async getTransactionLockingMeta(@Param('module') module: string) {
|
||||
return await this.queryTransactionsLocking.getTransactionsLockingModuleMeta(
|
||||
module as TransactionsLockingGroup,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as moment from 'moment';
|
||||
import { isUndefined } from 'lodash';
|
||||
import {
|
||||
ITransactionMeta,
|
||||
|
||||
@@ -147,9 +147,9 @@ export class VendorCreditGL {
|
||||
*/
|
||||
public getVendorCreditGLEntries(): ILedgerEntry[] {
|
||||
const payableEntry = this.vendorCreditPayableGLEntry;
|
||||
const getItemEntry = this.getVendorCreditGLItemEntry;
|
||||
const itemsEntries = this.vendorCredit.entries.map(getItemEntry);
|
||||
|
||||
const itemsEntries = this.vendorCredit.entries.map((entry, index) =>
|
||||
this.getVendorCreditGLItemEntry(entry, index),
|
||||
);
|
||||
const discountEntry = this.discountEntry;
|
||||
const adjustmentEntry = this.adjustmentEntry;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
export const entriesAmountDiff = (
|
||||
newEntries,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const requestBankRule = () => ({
|
||||
name: faker.company.name(),
|
||||
@@ -24,7 +24,7 @@ describe('Bank Rules (e2e)', () => {
|
||||
it('/banking/rules (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestBankRule())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -32,14 +32,14 @@ describe('Bank Rules (e2e)', () => {
|
||||
it('/banking/rules/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestBankRule())
|
||||
.expect(200);
|
||||
});
|
||||
@@ -47,42 +47,42 @@ describe('Bank Rules (e2e)', () => {
|
||||
it('/banking/rules/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/banking/rules/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/banking/rules (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/rules')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestBankRule());
|
||||
|
||||
const ruleId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/banking/rules/${ruleId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const createOwnerContributionTransaction = () => ({
|
||||
date: '2024-01-01',
|
||||
@@ -22,7 +22,7 @@ describe('Banking Transactions (e2e)', () => {
|
||||
it('/banking/transactions (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/banking/transactions')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(createOwnerContributionTransaction())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -31,7 +31,7 @@ describe('Banking Transactions (e2e)', () => {
|
||||
const transaction = createOwnerContributionTransaction();
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/transactions')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(transaction)
|
||||
.expect(201);
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('Banking Transactions (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/banking/transactions/${transactionId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('Banking Transactions (e2e)', () => {
|
||||
const transaction = createOwnerContributionTransaction();
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/banking/transactions')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(transaction)
|
||||
.expect(201);
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('Banking Transactions (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/banking/transactions/${transactionId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Branches (e2e)', () => {
|
||||
it('/branches (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/branches')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -17,7 +17,7 @@ describe('Branches (e2e)', () => {
|
||||
it('/branches/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/branches')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -26,14 +26,14 @@ describe('Branches (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/branches/${branchId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/branches/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/branches')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -42,14 +42,14 @@ describe('Branches (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/branches/${branchId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/branches/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/branches')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -58,14 +58,14 @@ describe('Branches (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/branches/${branchId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/branches (GET)', async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/branches')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import * as request from 'supertest';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
let customerId;
|
||||
let itemId;
|
||||
|
||||
const requestCreditNote = () => ({
|
||||
customerId: 2,
|
||||
customerId: customerId,
|
||||
creditNoteDate: '2020-02-02',
|
||||
branchId: 1,
|
||||
warehouseId: 1,
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1000,
|
||||
itemId: itemId,
|
||||
quantity: 1,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
@@ -20,10 +24,33 @@ const requestCreditNote = () => ({
|
||||
});
|
||||
|
||||
describe('Credit Notes (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const customer = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ displayName: 'Test Customer' });
|
||||
|
||||
customerId = customer.body.id;
|
||||
|
||||
const item = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
sellable: true,
|
||||
purchasable: true,
|
||||
sellAccountId: 1026,
|
||||
costAccountId: 1019,
|
||||
costPrice: 100,
|
||||
sellPrice: 100,
|
||||
});
|
||||
itemId = parseInt(item.text, 10);
|
||||
});
|
||||
|
||||
it('/credit-notes (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestCreditNote())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -31,13 +58,13 @@ describe('Credit Notes (e2e)', () => {
|
||||
it('/credit-notes/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestCreditNote());
|
||||
const creditNoteId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/credit-notes/${creditNoteId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
@@ -45,13 +72,13 @@ describe('Credit Notes (e2e)', () => {
|
||||
const creditNote = requestCreditNote();
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(creditNote);
|
||||
const creditNoteId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/credit-notes/${creditNoteId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(creditNote)
|
||||
.expect(200);
|
||||
});
|
||||
@@ -59,13 +86,13 @@ describe('Credit Notes (e2e)', () => {
|
||||
it('/credit-notes/:id/open (POST)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestCreditNote());
|
||||
const creditNoteId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/credit-notes/${creditNoteId}/open`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Customers (e2e)', () => {
|
||||
it('/customers (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
@@ -20,7 +20,7 @@ describe('Customers (e2e)', () => {
|
||||
it('/customers/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
@@ -32,14 +32,14 @@ describe('Customers (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/customers/${customerId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/customers/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
@@ -51,14 +51,14 @@ describe('Customers (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/customers/${customerId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/customers/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
@@ -70,7 +70,7 @@ describe('Customers (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/customers/${customerId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const makeExpenseRequest = () => ({
|
||||
exchangeRate: 1,
|
||||
@@ -11,7 +11,7 @@ const makeExpenseRequest = () => ({
|
||||
paymentDate: faker.date.recent(),
|
||||
categories: [
|
||||
{
|
||||
expenseAccountId: 1045,
|
||||
expenseAccountId: 1021,
|
||||
amount: faker.number.float({ min: 10, max: 1000, precision: 0.01 }),
|
||||
description: faker.lorem.sentence(),
|
||||
},
|
||||
@@ -23,7 +23,7 @@ describe('Expenses (e2e)', () => {
|
||||
it('/expenses (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/expenses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeExpenseRequest())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -31,14 +31,14 @@ describe('Expenses (e2e)', () => {
|
||||
it('/expenses/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/expenses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeExpenseRequest());
|
||||
|
||||
const expenseId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/expenses/${expenseId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeExpenseRequest())
|
||||
.expect(200);
|
||||
});
|
||||
@@ -46,28 +46,28 @@ describe('Expenses (e2e)', () => {
|
||||
it('/expenses/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/expenses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeExpenseRequest());
|
||||
|
||||
const expenseId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/expenses/${expenseId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/expenses/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/expenses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeExpenseRequest());
|
||||
|
||||
const expenseId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/expenses/${expenseId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,14 +4,15 @@ import { AppModule } from '../src/modules/App/App.module';
|
||||
|
||||
let app: INestApplication;
|
||||
|
||||
let orgainzationId = 'fxdo7u419m5ryy4tb';
|
||||
let authenticationToken = '';
|
||||
|
||||
beforeAll(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
app.useLogger(new Logger());
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
@@ -19,4 +20,6 @@ afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
export { app };
|
||||
jest.retryTimes(3, { logErrorsBeforeRetry: true });
|
||||
|
||||
export { app, orgainzationId, authenticationToken };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
export const createInventoryAdjustment = ({ itemId }) => ({
|
||||
date: '2020-01-01',
|
||||
@@ -28,7 +28,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
||||
it('/inventory-adjustments/quick (POST)', async () => {
|
||||
const itemResponse = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest())
|
||||
.expect(201);
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.post('/inventory-adjustments/quick')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(createInventoryAdjustment({ itemId }))
|
||||
.expect(201);
|
||||
});
|
||||
@@ -44,7 +44,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
||||
it('/inventory-adjustments/:id (DELETE)', async () => {
|
||||
const itemResponse = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest())
|
||||
.expect(201);
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
||||
|
||||
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
||||
.post('/inventory-adjustments/quick')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(createInventoryAdjustment({ itemId }))
|
||||
.expect(201);
|
||||
|
||||
@@ -60,21 +60,21 @@ describe('Inventory Adjustments (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/inventory-adjustments/${inventoryAdjustmentId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/inventory-adjustments/:id (GET)', async () => {
|
||||
const itemResponse = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest())
|
||||
.expect(201);
|
||||
|
||||
const itemId = itemResponse.text;
|
||||
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
||||
.post('/inventory-adjustments/quick')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(createInventoryAdjustment({ itemId }))
|
||||
.expect(201);
|
||||
|
||||
@@ -82,21 +82,21 @@ describe('Inventory Adjustments (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/inventory-adjustments/${inventoryAdjustmentId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/inventory-adjustments/:id/publish (POST)', async () => {
|
||||
const itemResponse = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest())
|
||||
.expect(201);
|
||||
|
||||
const itemId = itemResponse.text;
|
||||
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
||||
.post('/inventory-adjustments/quick')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
...createInventoryAdjustment({ itemId }),
|
||||
publish: false,
|
||||
@@ -107,7 +107,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/inventory-adjustments/${inventoryAdjustmentId}/publish`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Item Categories(e2e)', () => {
|
||||
it('/item-categories (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/item-categories')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.person.fullName(),
|
||||
description: faker.lorem.sentence(),
|
||||
@@ -17,7 +17,7 @@ describe('Item Categories(e2e)', () => {
|
||||
it('/item-categories/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/item-categories')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.person.fullName(),
|
||||
description: faker.lorem.sentence(),
|
||||
@@ -26,14 +26,14 @@ describe('Item Categories(e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/item-categories/${itemCategoryId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/item-categories/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/item-categories')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.person.fullName(),
|
||||
description: faker.lorem.sentence(),
|
||||
@@ -43,7 +43,7 @@ describe('Item Categories(e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/item-categories/${itemCategoryId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const makeItemRequest = () => ({
|
||||
name: faker.commerce.productName(),
|
||||
@@ -11,7 +11,7 @@ describe('Items (e2e)', () => {
|
||||
it('/items (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -19,108 +19,108 @@ describe('Items (e2e)', () => {
|
||||
it('/items/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/items/${itemId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
});
|
||||
|
||||
it('/items/:id/inactivate (PATCH)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.patch(`/items/${itemId}/inactivate`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/activate (PATCH)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.patch(`/items/${itemId}/activate`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/items/${itemId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/invoices (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/invoices`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/bills (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/bills`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/estimates (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/estimates`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/receipts (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/receipts`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,5 +8,7 @@
|
||||
},
|
||||
"moduleNameMapper": {
|
||||
"^@/(.*)$": "<rootDir>/../src/$1"
|
||||
}
|
||||
},
|
||||
"maxWorkers": 1,
|
||||
"maxConcurrency": 1
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const makeManualJournalRequest = () => ({
|
||||
date: '2022-06-01',
|
||||
@@ -27,7 +27,7 @@ describe.only('Manual Journals (e2e)', () => {
|
||||
it('/manual-journals (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeManualJournalRequest())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -35,14 +35,14 @@ describe.only('Manual Journals (e2e)', () => {
|
||||
it('/manual-journals/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeManualJournalRequest());
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/manual-journals/${journalId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send()
|
||||
.expect(200);
|
||||
});
|
||||
@@ -50,14 +50,14 @@ describe.only('Manual Journals (e2e)', () => {
|
||||
it('/manual-journals/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeManualJournalRequest());
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/manual-journals/${journalId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send()
|
||||
.expect(200);
|
||||
});
|
||||
@@ -66,14 +66,14 @@ describe.only('Manual Journals (e2e)', () => {
|
||||
const manualJournal = makeManualJournalRequest();
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(manualJournal);
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/manual-journals/${journalId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(manualJournal)
|
||||
.expect(200);
|
||||
});
|
||||
@@ -81,14 +81,14 @@ describe.only('Manual Journals (e2e)', () => {
|
||||
it('/manual-journals/:id/publish (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeManualJournalRequest());
|
||||
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/manual-journals/${journalId}/publish`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send()
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
let invoice;
|
||||
let customerId;
|
||||
let itemId;
|
||||
|
||||
const requestPaymentReceivedBody = (invoiceId: number) => ({
|
||||
customerId: 2,
|
||||
customerId: customerId,
|
||||
paymentDate: '2023-01-01',
|
||||
exchangeRate: 1,
|
||||
referenceNo: faker.string.uuid(),
|
||||
@@ -15,7 +19,7 @@ const requestPaymentReceivedBody = (invoiceId: number) => ({
|
||||
});
|
||||
|
||||
const requestSaleInvoiceBody = () => ({
|
||||
customerId: 2,
|
||||
customerId: customerId,
|
||||
invoiceDate: '2023-01-01',
|
||||
dueDate: '2023-02-01',
|
||||
invoiceNo: faker.string.uuid(),
|
||||
@@ -28,7 +32,7 @@ const requestSaleInvoiceBody = () => ({
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
itemId: itemId,
|
||||
quantity: 100,
|
||||
rate: 1000,
|
||||
description: 'Item description...',
|
||||
@@ -36,22 +40,43 @@ const requestSaleInvoiceBody = () => ({
|
||||
],
|
||||
});
|
||||
|
||||
let invoice;
|
||||
|
||||
beforeEach(async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
invoice = response.body;
|
||||
});
|
||||
|
||||
describe('Payment Received (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const customer = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ displayName: 'Test Customer' });
|
||||
|
||||
customerId = customer.body.id;
|
||||
|
||||
const item = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
sellable: true,
|
||||
purchasable: true,
|
||||
sellAccountId: 1026,
|
||||
costAccountId: 1019,
|
||||
costPrice: 100,
|
||||
sellPrice: 100,
|
||||
});
|
||||
itemId = parseInt(item.text, 10);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
invoice = response.body;
|
||||
});
|
||||
|
||||
it('/payments-received (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/payments-received')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestPaymentReceivedBody(invoice.id))
|
||||
.expect(201);
|
||||
});
|
||||
@@ -59,49 +84,49 @@ describe('Payment Received (e2e)', () => {
|
||||
it('/payments-received/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/payments-received')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestPaymentReceivedBody(invoice.id));
|
||||
|
||||
const paymentReceivedId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/payments-received/${paymentReceivedId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/payments-received/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/payments-received')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestPaymentReceivedBody(invoice.id));
|
||||
|
||||
const paymentReceivedId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/payments-received/${paymentReceivedId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/payments-received/:id/invoices (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/payments-received')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestPaymentReceivedBody(invoice.id));
|
||||
|
||||
const paymentReceivedId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/payments-received/${paymentReceivedId}/invoices`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/payments-received/state (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/payments-received/state')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Pdf Templates (e2e)', () => {
|
||||
it('/pdf-templates (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/pdf-templates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
template_name: 'Standard',
|
||||
resource: 'SaleInvoice',
|
||||
@@ -18,7 +18,7 @@ describe('Pdf Templates (e2e)', () => {
|
||||
it('/pdf-templates (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/pdf-templates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
template_name: 'Standard',
|
||||
resource: 'SaleInvoice',
|
||||
@@ -28,14 +28,14 @@ describe('Pdf Templates (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/pdf-templates/${pdfTemplateId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/pdf-templates/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/pdf-templates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
template_name: 'Standard',
|
||||
resource: 'SaleInvoice',
|
||||
@@ -45,14 +45,14 @@ describe('Pdf Templates (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/pdf-templates/${pdfTemplateId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/pdf-templates/:id/assign-default (POST)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/pdf-templates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
template_name: 'Standard',
|
||||
resource: 'SaleInvoice',
|
||||
@@ -62,7 +62,7 @@ describe('Pdf Templates (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/pdf-templates/${pdfTemplateId}/assign-default`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const makeEstimateRequest = () => ({
|
||||
customerId: 2,
|
||||
let customerId;
|
||||
let itemId;
|
||||
|
||||
const makeEstimateRequest = ({ ...props } = {}) => ({
|
||||
customerId: customerId,
|
||||
estimateDate: '2022-02-02',
|
||||
expirationDate: '2020-03-02',
|
||||
delivered: false,
|
||||
@@ -13,19 +16,43 @@ const makeEstimateRequest = () => ({
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
itemId: itemId,
|
||||
quantity: 3,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
},
|
||||
],
|
||||
...props,
|
||||
});
|
||||
|
||||
describe('Sale Estimates (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const customer = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ displayName: 'Test Customer' });
|
||||
|
||||
customerId = customer.body.id;
|
||||
|
||||
const item = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
sellable: true,
|
||||
purchasable: true,
|
||||
sellAccountId: 1026,
|
||||
costAccountId: 1019,
|
||||
costPrice: 100,
|
||||
sellPrice: 100,
|
||||
});
|
||||
itemId = parseInt(item.text, 10);
|
||||
});
|
||||
|
||||
it('/sale-estimates (POST)', async () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeEstimateRequest())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -33,63 +60,63 @@ describe('Sale Estimates (e2e)', () => {
|
||||
it('/sale-estimates (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeEstimateRequest());
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/sale-estimates/${estimateId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/state (GET)', async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/sale-estimates/state')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeEstimateRequest());
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/sale-estimates/${estimateId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/:id/approve (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ ...makeEstimateRequest(), delivered: true });
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/sale-estimates/${estimateId}/approve`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/:id/reject (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ ...makeEstimateRequest(), delivered: true });
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/sale-estimates/${estimateId}/reject`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
let customerId;
|
||||
let itemId;
|
||||
|
||||
const requestSaleInvoiceBody = () => ({
|
||||
customerId: 2,
|
||||
customerId: customerId,
|
||||
invoiceDate: '2023-01-01',
|
||||
dueDate: '2023-02-01',
|
||||
invoiceNo: faker.string.uuid(),
|
||||
@@ -16,7 +19,7 @@ const requestSaleInvoiceBody = () => ({
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
itemId: itemId,
|
||||
quantity: 2,
|
||||
rate: 1000,
|
||||
description: 'Item description...',
|
||||
@@ -25,10 +28,33 @@ const requestSaleInvoiceBody = () => ({
|
||||
});
|
||||
|
||||
describe('Sale Invoices (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const customer = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ displayName: 'Test Customer' });
|
||||
|
||||
customerId = customer.body.id;
|
||||
|
||||
const item = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
sellable: true,
|
||||
purchasable: true,
|
||||
sellAccountId: 1026,
|
||||
costAccountId: 1019,
|
||||
costPrice: 100,
|
||||
sellPrice: 100,
|
||||
});
|
||||
itemId = parseInt(item.text, 10);
|
||||
});
|
||||
|
||||
it('/sale-invoices (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -36,24 +62,24 @@ describe('Sale Invoices (e2e)', () => {
|
||||
it('/sale-invoices/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/sale-invoices/${response.body.id}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-invoices/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/sale-invoices/${response.body.id}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody())
|
||||
.expect(200);
|
||||
});
|
||||
@@ -61,48 +87,48 @@ describe('Sale Invoices (e2e)', () => {
|
||||
it('/sale-invoices/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/sale-invoices/${response.body.id}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-invoices/:id/state (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/sale-invoices/${response.body.id}/state`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-invoices/:id/payments (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/sale-invoices/${response.body.id}/payments`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-invoices/:id/writeoff (POST)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.post(`/sale-invoices/${response.body.id}/writeoff`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
expenseAccountId: 1024,
|
||||
date: '2023-01-01',
|
||||
@@ -114,12 +140,12 @@ describe('Sale Invoices (e2e)', () => {
|
||||
it('/sale-invoices/:id/cancel-writeoff (POST)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestSaleInvoiceBody());
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.post(`/sale-invoices/${response.body.id}/writeoff`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
expenseAccountId: 1024,
|
||||
date: '2023-01-01',
|
||||
@@ -128,14 +154,14 @@ describe('Sale Invoices (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.post(`/sale-invoices/${response.body.id}/cancel-writeoff`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-invoices/:id/deliver (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
...requestSaleInvoiceBody(),
|
||||
delivered: false,
|
||||
@@ -143,7 +169,7 @@ describe('Sale Invoices (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.post(`/sale-invoices/${response.body.id}/deliver`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const receiptRequest = {
|
||||
customerId: 2,
|
||||
let customerId;
|
||||
let itemId;
|
||||
|
||||
const makeReceiptRequest = () => ({
|
||||
customerId: customerId,
|
||||
depositAccountId: 1000,
|
||||
receiptDate: '2022-02-02',
|
||||
referenceNo: '123',
|
||||
@@ -15,50 +18,73 @@ const receiptRequest = {
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
itemId: itemId,
|
||||
quantity: 1,
|
||||
rate: 2000,
|
||||
description: 'asdfsadf',
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
describe('Sale Receipts (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const customer = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ displayName: 'Test Customer' });
|
||||
|
||||
customerId = customer.body.id;
|
||||
|
||||
const item = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
sellable: true,
|
||||
purchasable: true,
|
||||
sellAccountId: 1026,
|
||||
costAccountId: 1019,
|
||||
costPrice: 100,
|
||||
sellPrice: 100,
|
||||
});
|
||||
itemId = parseInt(item.text, 10);
|
||||
});
|
||||
|
||||
it('/sale-reeipts (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest)
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeReceiptRequest())
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/sale-receipts/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest);
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeReceiptRequest());
|
||||
|
||||
const receiptId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/sale-receipts/${receiptId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send();
|
||||
});
|
||||
|
||||
it('/sale-receipts/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest);
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeReceiptRequest());
|
||||
|
||||
const receiptId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/sale-receipts/${receiptId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
...receiptRequest,
|
||||
...makeReceiptRequest(),
|
||||
referenceNo: '321',
|
||||
})
|
||||
.expect(200);
|
||||
@@ -67,14 +93,14 @@ describe('Sale Receipts (e2e)', () => {
|
||||
it('/sale-receipts/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest);
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeReceiptRequest());
|
||||
|
||||
const receiptId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/sale-receipts/${receiptId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as request from 'supertest';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
const makeSettingsRequest = () => ({
|
||||
options: [
|
||||
@@ -20,7 +20,7 @@ describe('Settings (e2e)', () => {
|
||||
it('/settings (PUT)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.put('/settings')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(makeSettingsRequest())
|
||||
.expect(200);
|
||||
});
|
||||
@@ -28,7 +28,7 @@ describe('Settings (e2e)', () => {
|
||||
it('/settings (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/settings')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Item Categories(e2e)', () => {
|
||||
it('/tax-rates (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/tax-rates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.person.fullName(),
|
||||
rate: 2,
|
||||
@@ -19,7 +19,7 @@ describe('Item Categories(e2e)', () => {
|
||||
it('/tax-rates/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/tax-rates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.person.fullName(),
|
||||
rate: 2,
|
||||
@@ -30,7 +30,7 @@ describe('Item Categories(e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/tax-rates/${taxRateId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
import * as request from 'supertest';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Transactions Locking (e2e)', () => {
|
||||
it('/transactions-locking (PUT)', () => {
|
||||
describe.only('Transactions Locking (e2e)', () => {
|
||||
it('/transactions-locking/lock (PUT)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.put('/transactions-locking')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.put('/transactions-locking/lock')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
module: 'all',
|
||||
lock_to_date: '2025-01-01',
|
||||
@@ -14,4 +13,92 @@ describe('Transactions Locking (e2e)', () => {
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
it('/transactions-locking/cancel-lock (PUT)', async () => {
|
||||
await request(app.getHttpServer())
|
||||
.put('/transactions-locking/lock')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
module: 'all',
|
||||
lock_to_date: '2025-01-01',
|
||||
reason: 'test',
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put('/transactions-locking/cancel-lock')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/transactions-locking/unlock-partial (PUT)', async () => {
|
||||
await request(app.getHttpServer())
|
||||
.put('/transactions-locking/lock')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
module: 'all',
|
||||
lock_to_date: '2025-01-01',
|
||||
reason: 'test',
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put('/transactions-locking/cancel-lock')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
module: 'all',
|
||||
unlockFromDate: '2025-01-01',
|
||||
unlockToDate: '2025-12-31',
|
||||
reason: 'test partial unlock',
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/transactions-locking/cancel-unlock-partial (PUT)', async () => {
|
||||
await request(app.getHttpServer())
|
||||
.put('/transactions-locking/lock')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
module: 'all',
|
||||
lock_to_date: '2025-01-01',
|
||||
reason: 'test',
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.put('/transactions-locking/unlock-partial')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
module: 'all',
|
||||
unlockFromDate: '2025-01-01',
|
||||
unlockToDate: '2025-12-31',
|
||||
reason: 'test partial unlock',
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put('/transactions-locking/cancel-unlock-partial')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
module: 'all',
|
||||
unlockFromDate: '2025-01-01',
|
||||
unlockToDate: '2025-12-31',
|
||||
reason: 'test partial unlock',
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/transactions-locking (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/transactions-locking')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/transactions-locking/:module (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/transactions-locking/all')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import * as request from 'supertest';
|
||||
import { app } from './init-app-test';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
let vendorId;
|
||||
let itemId;
|
||||
|
||||
const requestVendorCredit = () => ({
|
||||
vendorId: 3,
|
||||
vendorId: vendorId,
|
||||
exchangeRate: 1,
|
||||
vendorCreditNumber: faker.string.uuid(),
|
||||
vendorCreditDate: '2025-01-01',
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
item_id: 1000,
|
||||
item_id: itemId,
|
||||
quantity: 1,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
@@ -21,10 +24,33 @@ const requestVendorCredit = () => ({
|
||||
});
|
||||
|
||||
describe('Vendor Credits (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const vendor = await request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ displayName: 'Test Customer' });
|
||||
|
||||
vendorId = vendor.body.id;
|
||||
|
||||
const item = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
sellable: true,
|
||||
purchasable: true,
|
||||
sellAccountId: 1026,
|
||||
costAccountId: 1019,
|
||||
costPrice: 100,
|
||||
sellPrice: 100,
|
||||
});
|
||||
itemId = parseInt(item.text, 10);
|
||||
});
|
||||
|
||||
it('/vendor-credits (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestVendorCredit())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -32,42 +58,42 @@ describe('Vendor Credits (e2e)', () => {
|
||||
it('/vendor-credits/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestVendorCredit());
|
||||
|
||||
const vendorCreditId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/vendor-credits/${vendorCreditId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/vendor-credits/:id/open (POST)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestVendorCredit());
|
||||
|
||||
const vendorCreditId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/vendor-credits/${vendorCreditId}/open`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/vendor-credits/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestVendorCredit());
|
||||
|
||||
const vendorCreditId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/vendor-credits/${vendorCreditId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Vendors (e2e)', () => {
|
||||
describe.only('Vendors (e2e)', () => {
|
||||
it('/vendors (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
@@ -19,7 +19,7 @@ describe('Vendors (e2e)', () => {
|
||||
it('/vendors/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
@@ -30,7 +30,7 @@ describe('Vendors (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/vendors/${vendorId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
@@ -43,7 +43,7 @@ describe('Vendors (e2e)', () => {
|
||||
it('/vendors/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
@@ -54,14 +54,14 @@ describe('Vendors (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/vendors/${vendorId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/vendors/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
});
|
||||
@@ -69,7 +69,7 @@ describe('Vendors (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/vendors/${vendorId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
|
||||
describe('Warehouses (e2e)', () => {
|
||||
it('/warehouses (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/warehouses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -17,7 +17,7 @@ describe('Warehouses (e2e)', () => {
|
||||
it('/warehouses/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/warehouses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -26,14 +26,14 @@ describe('Warehouses (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/warehouses/${warehouseId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/warehouses/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/warehouses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -42,14 +42,14 @@ describe('Warehouses (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/warehouses/${warehouseId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/warehouses/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/warehouses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
code: faker.string.alpha(4),
|
||||
@@ -58,14 +58,14 @@ describe('Warehouses (e2e)', () => {
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/warehouses/${warehouseId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/warehouses (GET)', async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/warehouses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user