Stored Procedures [dbo].[MssWebGetUngroupedLineItemsByQuoteId]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inOrderIdint4
@inQuoteIdint4
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
CREATE procedure [dbo].[MssWebGetUngroupedLineItemsByQuoteId]
    @inOrderId int,
    @inQuoteId int
as
begin
    set nocount on;

    select
        QuoteGroup.QuoteGroupID as LineItemId,
        QuoteGroup.ItemCodeFID as ItemCodeId,
        ItemCode.Description as ItemCodeDescription,
        ItemCode.ItemCode as ItemCodeValue,
        QuoteGroup.Description as Description,
        QuoteGroup.RateTypeFID as RateTypeId,
        LaborRatingType.TypeName as RateAs,
        QuoteGroup.Quantity2 as Quantity2,
        QuoteGroup.Quantity as Quantity1,
        QuoteGroup.Rate as Rate,
        QuoteGroup.Charge as Charge,
        QuoteGroup.NoteText as AccountingNote,
        QuoteGroup.QuoteServiceProviderBillToFID as ThirdPartyPayableQuoteServiceProviderBillToId,
        QuoteGroup.QuoteServiceProviderTypeFID as ThirdPartyPayableQuoteServiceProviderTypeId,
        QuoteServiceProviderType.TypeName as ThirdPartyPayableQuoteServiceProviderTypeName,
        dbo.GetQuoteServiceProvider( @inOrderId, QuoteServiceProviderType.TypeName ) as ThirdPartyPayableQuoteServiceProviderName,
        QuoteServiceProviderType.InternationalProviderFlag as ThirdPartyPayableQuoteServiceProviderInternationalFlag,


        QuoteGroup.VendorID as ThirdPartyPayableVendorId,
        Vendor_Synonym.Name as ThirdPartyPayableVendorName,
        Vendor_Synonym.City as ThirdPartyPayableVendorCity,
        Vendor_Synonym.State as ThirdPartyPayableVendorState,
        CAST(
            case
                when exists(select 1 from Vendor_Synonym where Vendor_Synonym.Hold = 'On Hold') then 1 else 0
            end
        as bit)  as ThirdPartyPayableVendorOnHold,

        QuoteGroup.VendorQuotedCharge as ThirdPartyPayableVendorQuotedCharge,
        QuoteGroup.VendorActualCharge as ThirdPartyPayableVendorActualCharge,
        QuoteGroup.PONumber as ThirdPartyPayablePONumber,
        QuoteGroup.InvoiceNumber as ThirdPartyPayableInvoiceNumber,
        QuoteGroup.ServiceDate as ThirdPartyPayableServiceDate,
        QuoteGroup.RateSource as RateSourceType,
        QuoteGroup.RateSourceRecord as RateSourceRecordId,
        
        -- Is Revenue Imported?
        CAST(
            case
                when exists(select 1 from QuoteRevenueImport where QuoteGroupFID = QuoteGroup.QuoteGroupID) then 1 else 0
            end
        as bit) as IsRevenueImported,
        
        ISNULL(QuoteGroup.SortOrder, 0) as SortOrder
    from dbo.QuoteGroup
    left outer join LaborRatingType on
        LaborRatingType.LaborRatingTypeID = QuoteGroup.LaborRatingTypeFID
    left outer join ItemCode on
        ItemCode.ICPriKey = QuoteGroup.ItemCodeFID
    left outer join QuoteServiceProviderType on
        QuoteServiceProviderType.QuoteServiceProviderTypeID = QuoteGroup.QuoteServiceProviderTypeFID
    left outer join Vendor_Synonym on
        Vendor_Synonym.VendorID = QuoteGroup.VendorID
    where QuoteHeaderFID = @inQuoteId
        and not exists(
            select 1
            from QuoteDetail
            where QuoteDetail.QuoteGroupFID = QuoteGroup.QuoteGroupID
        )
    order by SortOrder;
end
GO
GRANT EXECUTE ON  [dbo].[MssWebGetUngroupedLineItemsByQuoteId] TO [MssExec]
GO
Uses