Skip to content

Problem z zatwierdzeniem KO_WZR

Dokument WZR posiadał 1 pozycje na 4 sztuki która po zatwierdzeniu otrzymała 2 wyceny zgodnie z FIFO. Powstała pozycja nr 1 i 2 Proba korekty pozycji nr 1 powoduje informacje ze brak stanu.

Text Only
1
2
3
Komunikat bledu
Msg 50000, Level 16, State 1, Procedure document_udpateDocumentStatus_test, Line 345 [Batch Start Line 0]
KO_WZR/7/101/2018 #error.documentLine.cannotCorrectDocumentOverItsQuantity MA00014926 #possible 0.000 #position1

Doikument WZR {host_platformacrm}/MM/documentOut/e25e31a4-bbbc-e811-941c-d89d6719e0ca Dokument KO_WZR {host_platformacrm}/MM/documentOut/9e64683b-b3f3-e811-941e-d89d6719e0ca

Analiza

  • itemquantityleft byla pusta dla pozycji nr 1
  • itemquantityleft byla zgodna dla pozycji nr 2 Oznacza to ze jest gdzies prawdodpodbny blad w scenariuszu korekty wzr z 2 wycenmai

Utworzono procedure testowa i odtworzono sciezke

  1. [document].[document_udpateDocumentStatus_test] - zatweirdzenie dokumentu, Uruchamia procedure 2 linia 331
  2. [document].[documentlineOUT_Commit_test]
  3. dla korekty wzr wariant b linia 488 else if @isCorrectiveLine = 1 and @sign = 1 begin
  4. initial B@initialSourceDocumentLineId 70119AA3-BCBC-E811-941C-D89D6719E0CA B@initialSourceDocumentId E25E31A4-BBBC-E811-941C-D89D6719E0CA B@draftDocumentOrdinalNumber 1

Glowne zapytanie ktore decyduje czy jest mozliwosc korekty

SQL
select dl.documentOrdinalNumber,dl.itemQuantityLeft,documentlineid,sysCorrectedItemPrice,documentLineId,locationid, itemSerialNumber
        , case when dl.itemQuantityLeft != dl.correctedItemQuantity then cast(dl.itemQuantityLeft * dl.sysCorrectedItemPrice as decimal(18,2))
            else abs(round(dl.correctedItemValue * isnull(d.currencyExchangeRate, 1), 2)) - (dl.correctedItemQuantity - dl.itemQuantityLeft) * dl.sysCorrectedItemPrice/*sys wyjdzie na to samo co waluta bo to korekta rozchodu a na razie nie ma rozch walutowych*/
            end
        from document.documentLine dl
        inner join document.document d on d.documentID = dl.documentID
        where dl.documentID = 'E25E31A4-BBBC-E811-941C-D89D6719E0CA'
        --and dl.documentOrdinalNumber = @draftDocumentOrdinalNumber
         and dl.[status] > 0
        --and dl.itemQuantityLeft > 0
        order by dl.documentOrdinalNumber

Przyklad wywolania manualnego zatweirdzenia dokumentu

SQL
exec sp_executesql N';EXEC [document].[document_udpateDocumentStatus_test] @username = @0, @documentId = @1, @newStatus = @2, @skipInventoryValidation = @3',N'@0 nvarchar(4000),@1 nvarchar(40),@2 int,@3 int',@0=N'm.kotynia',@1=N'9e64683b-b3f3-e811-941e-d89d6719e0ca',@2=1,@3=0