select "Name", "Inn", "PartnersGrpID", "Enabled", "PhoneNumber", "ExtCode" from "dcPartners"
Наименование, инн, группа, вкл/выкл, номер телефона, внешний код.


select "PartnersGrpID", "Enabled", "PhoneNumber", "ExtCode", " IsSeparateRests" from "dcPartners" where "Inn" = :"Inn"

Группа, вкл/выкл, номер телефона, внешний код, тип системы расчетов(балансовая, ограничения), балансы на доступных кошельках, кредитные ограничения на кошельках.


select "dcPartners"."PartnerID", "dcAmounts"."Name" as "AmountName", "dcAmounts"."AmountID" as "AmountID",
        "sysCreditTypes"."Name" as "CreditName",
        "dcCreditRestrictions"."Credit", "dcCreditRestrictions"."Period", "dcCreditRestrictions"."Price",
        "dcCreditRestrictions"."AutoMigration", "GetCreditRest"."Rest" from "dcPartners"
        left join "dcCreditRestrictions" on "dcCreditRestrictions"."PartnerID" = "dcPartners"."PartnerID"
        left join "dcAmounts" on "dcAmounts"."AmountID" = "dcCreditRestrictions"."AmountID"
        left join "sysCreditTypes" on "sysCreditTypes"."CreditTypeID" = "dcCreditRestrictions"."CreditTypeID"
        left join "GetCreditRest"("dcCreditRestrictions"."PartnerID", "dcCreditRestrictions"."AmountID") on 1=1
        where "dcPartners"."PartnerID" = :"PartnerID"; 


select "Name", "Code", "Enabled", "ExpireDate", "ExtCode", "CarNumber", "CarModel", "PhoneNumber", "Rem" from "dcCards"
where "PartnerID" = (select "PartnerID" from "dcPartners" where "Inn" = :"Inn")

Наименование карты, номер карты, вкл/выкл, использовать до, внешний код, номер ТС, модель ТС, номер телефона, отметки.


select "Name", "Enabled", "ExpireDate", "ExtCode", "CarNumber", "CarModel", "PhoneNumber"  from "dcCards" where "Code" = : "Code"

Наименование карты, вкл/выкл, использовать до, внешний код, номер ТС, модель ТС, номер телефона, балансы на доступных кошельках, кредитные ограничения на кошельках


select "dcCards"."CardID", "dcAmounts"."AmountID", "dcAmounts"."Name" as "AmountName", "sysLimitTypes"."Name" as "LimitName",
            "dcLimitRestrictions"."Limit", "dcLimitRestrictions"."Period", "dcLimitRestrictions"."StartPeriod",
            "GetCreditRest_byCard"."Rest" as "Rest"
            from "dcCards"
            left join "dcLimitRestrictions" on "dcLimitRestrictions"."CardID" = "dcCards"."CardID"
            left join "dcAmounts" on "dcAmounts"."AmountID" = "dcLimitRestrictions"."AmountID"
            left join "sysLimitTypes" on "sysLimitTypes"."LimitTypeID" = "dcLimitRestrictions"."LimitTypeID"
            left join "GetCreditRest_byCard"("dcLimitRestrictions"."CardID", "dcLimitRestrictions"."AmountID") on 1=1
            where "dcCards"."CardID" = :"CardID"


select "dcCards"."CardID", "dcAmounts"."AmountID", "dcAmounts"."Name" as "AmountName", "sysLimitTypes"."Name" as "LimitName",
        "dcLimitRestrictions"."Limit", "dcLimitRestrictions"."Period", "dcLimitRestrictions"."StartPeriod",
        case when "GetLimitRest"."Rest" < 0 then "GetCreditRest"."Rest"
         else case when "GetCreditRest"."Rest" > "GetLimitRest"."Rest" then "GetLimitRest"."Rest"
        else "GetCreditRest"."Rest" end end as "Rest"
        from "dcCards"
        left join "dcLimitRestrictions" on "dcLimitRestrictions"."CardID" = "dcCards"."CardID"
        left join "dcAmounts" on "dcAmounts"."AmountID" = "dcLimitRestrictions"."AmountID"
        left join "sysLimitTypes" on "sysLimitTypes"."LimitTypeID" = "dcLimitRestrictions"."LimitTypeID"
        left join "GetLimitRest"("dcLimitRestrictions"."CardID", "dcLimitRestrictions"."AmountID") on 1=1
        left join "GetCreditRest"("dcCards"."PartnerID", "dcLimitRestrictions"."AmountID") on 1=1
        where "dcCards"."CardID" = :"CardID";


select "rgAmountRests"."Quantity",
        "rgAmountRests"."Amount",
        "rgAmountRests"."Price",
        "rgAmountRests"."Date",
        "rgAmountRests"."AZSCode",
        "dcCards"."Name"
        from "dcPartners"
        left join "rgAmountRests" on "rgAmountRests"."PartnerID" = "dcPartners"."PartnerID"
        left join "dcCards" on "rgAmountRests"."CardID" = "dcCards"."CardID"
        left join "dcAmounts" on "dcAmounts"."AmountID" = "rgAmountRests"."AmountID"
        where  "dcPartners"."PartnerID" = :"PartnerID" AND "rgAmountRests"."DocTypeID" = 3 order by "rgAmountRests"."Date" desc;

Литраж, сумма, цена, дата, азс, наименование карты


select "rgAmountRests"."Quantity",
        "rgAmountRests"."Amount",
        "rgAmountRests"."Price",
        "rgAmountRests"."Date",
        "rgAmountRests"."AZSCode",
        "dcCards"."Name"
        from "dcCards"
        left join "rgAmountRests" on "rgAmountRests"."CardID" = "dcCards"."CardID"
        left join "dcAmounts" on "dcAmounts"."AmountID" = "rgAmountRests"."AmountID"
        where  "dcCards"."Code" = :"Code" AND "rgAmountRests"."DocTypeID" = 3 order by "rgAmountRests"."Date" desc;

Литраж, сумма, цена, дата, азс. 


update "dcCards"set "Name" = :"Name",
"Enabled" = :"Enabled",
"ExpireDate" = :"ExpireDate",
"Rem" = :"Rem",
"AllowInOffline" = :"AllowInOffline",
"PIN" = :"PIN",
"ExtCode" = :"ExtCode",
"PhoneNumber" = :"PhoneNumber",
"CarNumber" = :"CarNumber",
"CarModel" = :"CarModel",
"Email" = :"Email"
where "Code"  = :"Code"


update "dcFuels" set "Price" = :price where "FuelID" = :fuleId


insert into "dcCards" (""PartnerID",
    "Name",
    "Code",
    "Enabled",
    "ExpireDate",
    "Rem",
    "AllowInOffline",
    "TransactionID",
    PIN,
    "ExtCode",
    "PhoneNumber",
    "CarNumber",
    "CarModel",
    "Email")
valuee (...)


update "dcLimitRestrictions" set "LimitTypeID" = ?, "Limit" = ?, "Period" = ?, "StartPeriod" = ? where ("CardID" = ?) and ("AmountID" = ?)


select "dcCards"."CardID", "dcAmounts"."AmountID", "dcAmounts"."Name" as "AmountName", "sysLimitTypes"."Name" as "LimitName",
        "dcLimitRestrictions"."Limit", "dcLimitRestrictions"."Period", "dcLimitRestrictions"."StartPeriod",
        case when "GetLimitRest"."Rest" < 0 then "GetCreditRest"."Rest"
         else case when "GetCreditRest"."Rest" > "GetLimitRest"."Rest" then "GetLimitRest"."Rest"
        else "GetCreditRest"."Rest" end end as "Rest"
        from "dcCards"
        left join "dcLimitRestrictions" on "dcLimitRestrictions"."CardID" = "dcCards"."CardID"
        left join "dcAmounts" on "dcAmounts"."AmountID" = "dcLimitRestrictions"."AmountID"
        left join "sysLimitTypes" on "sysLimitTypes"."LimitTypeID" = "dcLimitRestrictions"."LimitTypeID"
        left join "GetLimitRest"("dcLimitRestrictions"."CardID", "dcLimitRestrictions"."AmountID") on 1=1
        left join "GetCreditRest"("dcCards"."PartnerID", "dcLimitRestrictions"."AmountID") on 1=1
        where "dcCards"."CardID" = ид карты;


insert into "dcPartners" (   "Name",
    "Rem",
    "WithNDS",
    "Inn",
    "PartnersGrpID",
    "DiscountSchemaID",
    "Enabled",
    "ExtCode",
    "PhoneNumber")
values (...)


select "dcPartners"."PartnerID", "dcAmounts"."Name" as "AmountName",
        "sysCreditTypes"."Name" as "CreditName",
        "dcCreditRestrictions"."Credit", "dcCreditRestrictions"."Period", "dcCreditRestrictions"."Price",
        "dcCreditRestrictions"."AutoMigration", "GetCreditRest"."Rest" from "dcPartners"
        left join "dcCreditRestrictions" on "dcCreditRestrictions"."PartnerID" = "dcPartners"."PartnerID"
        left join "dcAmounts" on "dcAmounts"."AmountID" = "dcCreditRestrictions"."AmountID"
        left join "sysCreditTypes" on "sysCreditTypes"."CreditTypeID" = "dcCreditRestrictions"."CreditTypeID"
        left join "GetCreditRest"("dcCreditRestrictions"."PartnerID", "dcCreditRestrictions"."AmountID") on 1=1
        where "dcPartners"."PartnerID" = ид контрагента