"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPaymentForTransaction = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const LoanPayment_model_1 = require("../models/LoanPayment.model");
const getPaymentForTransaction = async (productId, transactionId) => {
    const payments = await LoanPayment_model_1.LoanPaymentModel.aggregate([
        {
            $match: {
                'productId': new mongoose_1.default.Types.ObjectId(productId),
                'paid.statementId': new mongoose_1.default.Types.ObjectId(transactionId),
            },
        },
    ]);
    if (payments.length === 0) {
        return [];
    }
    return payments;
};
exports.getPaymentForTransaction = getPaymentForTransaction;
