/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.summonses_list.tables;


import java.math.BigDecimal;
import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.SQL;
import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Stringly;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.micord.webbpm.ervu.business_metrics.db_beans.summonses_list.SummonsesList;
import ru.micord.webbpm.ervu.business_metrics.db_beans.summonses_list.tables.records.ViewFormedSummonsesRecord;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ViewFormedSummonses extends TableImpl<ViewFormedSummonsesRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>summonses_list.view_formed_summonses</code>
     */
    public static final ViewFormedSummonses VIEW_FORMED_SUMMONSES = new ViewFormedSummonses();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<ViewFormedSummonsesRecord> getRecordType() {
        return ViewFormedSummonsesRecord.class;
    }

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.formed_summonses_id</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, Long> FORMED_SUMMONSES_ID = createField(DSL.name("formed_summonses_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column <code>summonses_list.view_formed_summonses.count_all</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, Long> COUNT_ALL = createField(DSL.name("count_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.percent_formed</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, BigDecimal> PERCENT_FORMED = createField(DSL.name("percent_formed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.percent_signed</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, BigDecimal> PERCENT_SIGNED = createField(DSL.name("percent_signed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.percent_sent</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, BigDecimal> PERCENT_SENT = createField(DSL.name("percent_sent"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.percent_delivered_on_hands</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, BigDecimal> PERCENT_DELIVERED_ON_HANDS = createField(DSL.name("percent_delivered_on_hands"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.percent_delivered_by_letter</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, BigDecimal> PERCENT_DELIVERED_BY_LETTER = createField(DSL.name("percent_delivered_by_letter"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.percent_refused</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, BigDecimal> PERCENT_REFUSED = createField(DSL.name("percent_refused"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_formed_summonses.percent_auto_7_days</code>.
     */
    public final TableField<ViewFormedSummonsesRecord, BigDecimal> PERCENT_AUTO_7_DAYS = createField(DSL.name("percent_auto_7_days"), SQLDataType.NUMERIC, this, "");

    private ViewFormedSummonses(Name alias, Table<ViewFormedSummonsesRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private ViewFormedSummonses(Name alias, Table<ViewFormedSummonsesRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_formed_summonses" as  SELECT formed_summonses.formed_summonses_id,
         ((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days) AS count_all,
         COALESCE(round((((formed_summonses.count_formed)::numeric * (100)::numeric) / NULLIF((((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_formed,
         COALESCE(round((((formed_summonses.count_signed)::numeric * (100)::numeric) / NULLIF((((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_signed,
         COALESCE(round((((formed_summonses.count_sent)::numeric * (100)::numeric) / NULLIF((((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_sent,
         COALESCE(round((((formed_summonses.count_delivered_on_hands)::numeric * (100)::numeric) / NULLIF((((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_delivered_on_hands,
         COALESCE(round((((formed_summonses.count_delivered_by_letter)::numeric * (100)::numeric) / NULLIF((((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_delivered_by_letter,
         COALESCE(round((((formed_summonses.count_refused)::numeric * (100)::numeric) / NULLIF((((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused,
         COALESCE(round((((formed_summonses.count_auto_7_days)::numeric * (100)::numeric) / NULLIF((((((((formed_summonses.count_formed + formed_summonses.count_signed) + formed_summonses.count_sent) + formed_summonses.count_delivered_on_hands) + formed_summonses.count_delivered_by_letter) + formed_summonses.count_refused) + formed_summonses.count_auto_7_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_auto_7_days
        FROM summonses_list.formed_summonses;
        """), where);
    }

    /**
     * Create an aliased <code>summonses_list.view_formed_summonses</code> table
     * reference
     */
    public ViewFormedSummonses(String alias) {
        this(DSL.name(alias), VIEW_FORMED_SUMMONSES);
    }

    /**
     * Create an aliased <code>summonses_list.view_formed_summonses</code> table
     * reference
     */
    public ViewFormedSummonses(Name alias) {
        this(alias, VIEW_FORMED_SUMMONSES);
    }

    /**
     * Create a <code>summonses_list.view_formed_summonses</code> table
     * reference
     */
    public ViewFormedSummonses() {
        this(DSL.name("view_formed_summonses"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : SummonsesList.SUMMONSES_LIST;
    }

    @Override
    public ViewFormedSummonses as(String alias) {
        return new ViewFormedSummonses(DSL.name(alias), this);
    }

    @Override
    public ViewFormedSummonses as(Name alias) {
        return new ViewFormedSummonses(alias, this);
    }

    @Override
    public ViewFormedSummonses as(Table<?> alias) {
        return new ViewFormedSummonses(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewFormedSummonses rename(String name) {
        return new ViewFormedSummonses(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewFormedSummonses rename(Name name) {
        return new ViewFormedSummonses(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewFormedSummonses rename(Table<?> name) {
        return new ViewFormedSummonses(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewFormedSummonses where(Condition condition) {
        return new ViewFormedSummonses(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewFormedSummonses where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewFormedSummonses where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewFormedSummonses where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewFormedSummonses where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewFormedSummonses where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewFormedSummonses where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewFormedSummonses where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewFormedSummonses whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewFormedSummonses whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
