import { __decorate, __metadata } from "tslib";
import { Injectable, Scope } from 'graphql-modules';
import { sql } from '@pgtyped/runtime';
import { TenantAwareDBClient } from '../../app-providers/tenant-db-client.js';
const getChargesApprovalStatus = sql `
  SELECT COUNT(*) AS total_charges,
         COUNT(*) FILTER (WHERE accountant_status = 'APPROVED') AS approved_charges,
         COUNT(*) FILTER (WHERE accountant_status = 'PENDING') AS pending_charges,
         COUNT(*) FILTER (WHERE accountant_status = 'UNAPPROVED') AS unapproved_charges
  FROM accounter_schema.extended_charges
  WHERE owner_id in $$ownerIds
  AND GREATEST(documents_max_date, transactions_max_event_date, transactions_max_debit_date, ledger_max_invoice_date, ledger_max_value_date)::TEXT::DATE >= date_trunc('day', $fromDate ::DATE)
  AND LEAST(documents_min_date, transactions_min_event_date, transactions_min_debit_date, ledger_min_invoice_date, ledger_min_value_date)::TEXT::DATE <= date_trunc('day', $toDate ::DATE);`;
let AccountantApprovalProvider = class AccountantApprovalProvider {
    db;
    constructor(db) {
        this.db = db;
    }
    getChargesApprovalStatus(params) {
        return getChargesApprovalStatus.run(params, this.db);
    }
};
AccountantApprovalProvider = __decorate([
    Injectable({
        scope: Scope.Operation,
        global: true,
    }),
    __metadata("design:paramtypes", [TenantAwareDBClient])
], AccountantApprovalProvider);
export { AccountantApprovalProvider };
//# sourceMappingURL=accountant-approval.provider.js.map