Skip to content

Usunięcie, kasowanie dokumentu

1 KASOWANIE DOKUMENTU KOREKTY

Kasowanie korekty wymaga:

  • Sprawdzenie jakiego dokumentu dotyczy korekta
  • Sprawdzenia wszystkich dokumentów powiązanych z partia która jest korygowana

select d.documentFullNR,d.documentdate from document.documentline dl inner join document.document d on d.documentID =dl.documentID where initialIncomeSourceLineID ='C6774A52-1206-EA11-8424-7ED30A52F64F' --<<partia ktorej dotyczy documentlineid order by d.documentdate

2 Kasowanie wydania

brak procedury

3 Kasowanie dokumentu przychodowego

SQL
BEGIN TRANSACTION
    declare @documentid uniqueidentifier  = '114ca0e5-9d8d-e911-80d8-9c8e994dc647'
    declare @itemid uniqueidentifier

    declare @documentLineToRemove table(documentLineID uniqueidentifier, sourceDocumentLineID uniqueidentifier, itemID uniqueidentifier
            , itemQuantity decimal(18,3), sysItemValue decimal(18,2))

    insert into @documentLineToRemove
    select documentLineID, sourceDocumentLineID, itemID, itemQuantity, sysItemValue from document.documentLine where [status] = 1 and documentID = @documentid

    --Kasowanie naglowka
    update document.document set status = -1 where documentid = @documentid;
    --Kasowanie pozycji
    update document.documentline set status = -1 where documentid = @documentid;

    -- Przeliczenie stanow
            while exists(select * from @documentLineToRemove) begin
                select top 1 @itemid = itemID from @documentLineToRemove
                delete from @documentLineToRemove where itemID = @itemid

                set nocount off

                exec wms.stockBalanceFix @username = 'admin.admin', @itemID = @itemid

                set nocount on
            end

    -- UWAGA Jesli pw trzeba cofnac ilosc na zleceniu

    -- UWAGA jesli rozchod trzeba cofnac ilosci z dostawy

    -- UWAGa numerator trzeba cofnac
    -- delete from common.numerator where remotesource = 'document' and series like 'wz3000619%'

ROLLBACK TRANSACTION
--COMMIT TRANSACTION

KROK2
-- Cofniecie numeracji
select * from common.numerator  where series like 'MM+13001119%'

Anulowanie dokumentu

Anulowanie to samo co kasowanie

  • document.document.status = -1
  • document.documentline = Pozycje usunięte