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(
|
||||
id: string,
|
||||
relatedId: string,
|
||||
|
|
|
@ -3,7 +3,12 @@ import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
|||
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
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 { TransactionJournal } from './entities/transaction-journal.entity';
|
||||
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 { ProductHistoryPriceService } from '../product/history-price/history-price.service';
|
||||
import { CommissionService } from '../configurable/commission.service';
|
||||
import { catchError } from 'rxjs';
|
||||
|
||||
interface JournalEntry {
|
||||
coa_id: string;
|
||||
|
@ -134,14 +140,16 @@ export class TransactionService {
|
|||
);
|
||||
}
|
||||
|
||||
try {
|
||||
//GET Supplier
|
||||
const supplier = await this.supplierService.findByCode(
|
||||
distributeTransactionDto.supplier,
|
||||
);
|
||||
|
||||
// GET COA
|
||||
const coaAR = await this.coaService.findByUser(
|
||||
const coaAR = await this.coaService.findByTwoUser(
|
||||
distributeTransactionDto.destination,
|
||||
currentUser.userId,
|
||||
coaType.ACCOUNT_RECEIVABLE,
|
||||
);
|
||||
const coaWallet = await this.coaService.findByUser(
|
||||
|
@ -193,6 +201,9 @@ export class TransactionService {
|
|||
],
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user