transactions
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-04 12:26:30 +03:30
parent 92e97fa9d2
commit 5b6fb16f5c
14 changed files with 435 additions and 70 deletions
@@ -15,6 +15,8 @@ import { RestaurantCreditRequestStatus } from '../interface/restaurant-credit-re
import { CreateExternalInvoice } from '../interface/external-invoice.interface';
import { ChargeRequestDto } from '../dto/charge-request.dto';
import { FinishChargeRequestDto } from '../dto/finish-charge-request.dto';
import { FindRestaurantWalletTransactionsDto } from '../dto/find-restaurant-wallet-transactions.dto';
import { RestaurantCreditTransactionRepository } from '../repositories/restaurant-credit-transaction.repository';
import { RestMessage } from 'src/common/enums/message.enum';
@Injectable()
@@ -25,6 +27,7 @@ export class RestaurantWalletService {
private readonly defaultEm: EntityManager,
private readonly httpService: HttpService,
private readonly configService: ConfigService,
private readonly restaurantCreditTransactionRepository: RestaurantCreditTransactionRepository,
) {}
async getCurrentBalance(restaurantId: string, em: EntityManager = this.defaultEm): Promise<number> {
@@ -37,6 +40,10 @@ export class RestaurantWalletService {
return Number(latestTransaction?.balance ?? 0);
}
getTransactions(restaurantId: string, dto: FindRestaurantWalletTransactionsDto) {
return this.restaurantCreditTransactionRepository.findAllPaginated(restaurantId, dto);
}
async createTransaction(params: {
restaurant: Restaurant;
amount: number;
@@ -74,7 +81,7 @@ export class RestaurantWalletService {
const restaurant = await this.defaultEm.findOne(Restaurant, { id: restId });
if (!restaurant) {
throw new NotFoundException(RestMessage.NOT_FOUND);
}
}
if (!restaurant.subscriptionId) {
throw new BadRequestException('اشتراک رستوران یافت نشد');