fix: add saldo member
This commit is contained in:
parent
8f5b3588d2
commit
e7db0073c5
|
@ -76,6 +76,28 @@ export class CoaService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findByTwoUser(from: string, destination: string, typeOfCoa: coaType) {
|
||||||
|
try {
|
||||||
|
return await this.coaRepository.findOneOrFail({
|
||||||
|
user: from,
|
||||||
|
relatedUser: destination,
|
||||||
|
type: typeOfCoa,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof EntityNotFoundError) {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'COA not found',
|
||||||
|
},
|
||||||
|
HttpStatus.NOT_FOUND,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async findByUserWithRelated(
|
async findByUserWithRelated(
|
||||||
id: string,
|
id: string,
|
||||||
relatedId: string,
|
relatedId: string,
|
||||||
|
|
|
@ -3,7 +3,12 @@ import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
||||||
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Transactions } from './entities/transactions.entity';
|
import { Transactions } from './entities/transactions.entity';
|
||||||
import { Connection, EntityManager, Repository } from 'typeorm';
|
import {
|
||||||
|
Connection,
|
||||||
|
EntityManager,
|
||||||
|
EntityNotFoundError,
|
||||||
|
Repository,
|
||||||
|
} from 'typeorm';
|
||||||
import { COA } from './entities/coa.entity';
|
import { COA } from './entities/coa.entity';
|
||||||
import { TransactionJournal } from './entities/transaction-journal.entity';
|
import { TransactionJournal } from './entities/transaction-journal.entity';
|
||||||
import { CoaService } from './coa.service';
|
import { CoaService } from './coa.service';
|
||||||
|
@ -23,6 +28,7 @@ import { AddSaldoSupplier } from './dto/add-saldo-supplier.dto';
|
||||||
import { SupplierService } from '../users/supplier/supplier.service';
|
import { SupplierService } from '../users/supplier/supplier.service';
|
||||||
import { ProductHistoryPriceService } from '../product/history-price/history-price.service';
|
import { ProductHistoryPriceService } from '../product/history-price/history-price.service';
|
||||||
import { CommissionService } from '../configurable/commission.service';
|
import { CommissionService } from '../configurable/commission.service';
|
||||||
|
import { catchError } from 'rxjs';
|
||||||
|
|
||||||
interface JournalEntry {
|
interface JournalEntry {
|
||||||
coa_id: string;
|
coa_id: string;
|
||||||
|
@ -134,14 +140,16 @@ export class TransactionService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
//GET Supplier
|
//GET Supplier
|
||||||
const supplier = await this.supplierService.findByCode(
|
const supplier = await this.supplierService.findByCode(
|
||||||
distributeTransactionDto.supplier,
|
distributeTransactionDto.supplier,
|
||||||
);
|
);
|
||||||
|
|
||||||
// GET COA
|
// GET COA
|
||||||
const coaAR = await this.coaService.findByUser(
|
const coaAR = await this.coaService.findByTwoUser(
|
||||||
distributeTransactionDto.destination,
|
distributeTransactionDto.destination,
|
||||||
|
currentUser.userId,
|
||||||
coaType.ACCOUNT_RECEIVABLE,
|
coaType.ACCOUNT_RECEIVABLE,
|
||||||
);
|
);
|
||||||
const coaWallet = await this.coaService.findByUser(
|
const coaWallet = await this.coaService.findByUser(
|
||||||
|
@ -193,6 +201,9 @@ export class TransactionService {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user