Skip to content

Dekretacja

Obiekty bazy danych

  • TETA_ADMIN.RK_API_IMPORT_DOK ( tabela w teta ORACLE z dekretami dla sprzedazy i magazynou)
  • platformERP [accounting].[sales_exportToFinancialSystem] - procedura eksportujaca dla sprzedazy
  • platformaERP [accounting].[warehouse_exportToFinancialSystem] - procedura eksportujaca dla magazynu
  • TETA rk_api_import_dok_pack.wyslij_dokument_z_plaskiej - procedura uruchamiana z sales_exportToFinancialSystem konwertujaca dane z tabeli RK_API_IMPORT_DOK na prawidlowe dekrety
  • [accounting].[customeAccounting] reczne zapisanie
  • platformERP
    • accounting.salesConfiguration
    • accounting.warehouseconfiguration przyklad `select * from accounting.warehouseconfiguration where documenttype like 'KO' and status>-1
    • accounting.customeaccounting

Przykłady

Magazyn

SQL
1
2
3
4
5
6
7
8
9
--eksport dekretu magazynowego 
exec sp_executesql N';exec [accounting].[warehouse_exportToFinancialSystem] @documentID=@0, 
@setStatus = @1, @username=@2',N'@0 nvarchar(4000),@1 nvarchar(4000),@2 nvarchar(4000)',@0=N'a0cf72f6-337f-ef11-95b5-d89d6719e0cb',@1=N'1',@2=N'm.kotynia'

--wyslanie dekretu magazynowego 
exec sp_executesql N'[accounting].[warehouse_exportToFinancialSystem] @documentID=@documentID, @setStatus = @setStatus, @username=@username',N'@username nvarchar(23),@documentID nvarchar(36),@markStatusOnly nvarchar(4000),@setStatus nvarchar(1)',@username=N'marcin@platformaerp.com',@documentID=N'3d5b5daa-b57f-ef11-95b5-d89d6719e0cb',@markStatusOnly=NULL,@setStatus=N'1'

--wycofanie dekretu magazynowego
exec sp_executesql N';exec [accounting].[check_exported_documents] @source=@0, @username=@1',N'@0 nvarchar(4000),@1 nvarchar(4000)',@0=N'warehouse',@1=N'm.kotynia'

Edycja dekretu sprzedazy

Podgląd

SQL
--procedura do podgladu
exec sp_executesql N'EXEC accounting.salesLineList @username=@0,@id = @1',N'@0 nvarchar(4000),@1 nvarchar(40)',@0=N'm.kotynia',@1=N'9be3d707-f186-ef11-95b5-d89d6719e0cb'

--procedura do aktualizaccji

exec sp_executesql N'; exec [accounting].[customAccounting_InsertUpdate]
                            @username= @0,
                            @remoteSource=@1,
                            @remoteId=@2,
                            @ma_account_mask=@3',N'@0 nvarchar(4000),@1 nvarchar(4000),@2 nvarchar(4000),@3 nvarchar(4000)',@0=N'm.kotynia',@1=N'invoiceline',@2=N'b9dbd655-f186-ef11-95b5-d89d6719e0cb',@3=N'740-001'


--resetuj do wartosci systemowych
exec common.deleterecord @source=N'customaccounting',@id=N'b9dbd655-f186-ef11-95b5-d89d6719e0cb',@status=-1,@username=N'm.kotynia'

Edycja dekretu magazynowego

Podgląd

SQL
--procedura podgladu
exec sp_executesql N'EXEC accounting.warehouseLineList @username=@0,@id = @1',N'@0 nvarchar(4000),@1 nvarchar(40)',@0=N'm.kotynia',@1=N'94d5f0aa-b67f-ef11-95b5-d89d6719e0cb'

--procedura pobrania nazwy konta
exec sp_executesql N'EXEC [accounting].[accountName_Get] @accountMask=@0',N'@0 nvarchar(4000)',@0=N'501-34-900'

--aktualizacja
exec sp_executesql N'; exec [accounting].[customAccounting_InsertUpdate]
                            @username= @0,
                            @remoteSource=@1,
                            @remoteId=@2,
                            @ma_account_mask=@3',N'@0 nvarchar(4000),@1 nvarchar(4000),@2 nvarchar(4000),@3 nvarchar(4000)',@0=N'm.kotynia',@1=N'documentline',@2=N'fabff68f-b97f-ef11-9c33-2c768a5328b2',@3=N'603'

FAQ

Linked server ustawienia

jeżeli taki komunikat How to “Unable to enlist in the transaction” with Oracle linked server from MS SQL Server wtedy Enable Promotion of Distributed Transactions for Oracle Linked Server set to False

linked

Scenariusz nie dekretuje się sprzedaż

Komunikat

SQL
OLE DB provider "OraOLEDB.Oracle" for linked server "TETA_CONS_PROD" returned message "ORA-20898: <kod>FK_IMDO_BLEDNE_DANE</kod> Dokumenty nie przeszły pomyślnie procesu weryfikacji.
ORA-06512: at "TETA_ADMIN.PA_BLEDY", line 258
ORA-06512: at "TETA_ADMIN.PA_KOMUNIKAT", line 256
ORA-06512: at "TETA_ADMIN.RK_API_IMPORT_DOK_PACK", line 3831
ORA-06512: at "TETA_ADMIN.RK_API_IMPORT_DOK_PACK", line 3942
ORA-06512: at "TETA_ADMIN.RK_API_IMPORT_DOK_PACK", line 3875
ORA-06512: at line 3".
Msg 7215, Level 17, State 1, Procedure accounting.sales_exportToFinancialSystem, Line 1028 [Batch Start Line 39]
Could not execute statement on remote server 'TETA_CONS_PROD'.

Completion time: 2023-04-06T11:23:31.2241021+02:00

Skrypty

  1. Uzupełnia ręcznie konto przykład
SQL
1
2
3
4
5
exec sp_executesql N'; exec [accounting].[customAccounting_InsertUpdate]
                            @username= @0,
                            @remoteSource=@1,
                            @remoteId=@2,
                            @ma_account_mask=@3',N'@0 nvarchar(4000),@1 nvarchar(4000),@2 nvarchar(4000),@3 nvarchar(4000)',@0=N'm.kotynia',@1=N'documentline',@2=N'c1957b2f-cea8-eb11-9567-d89d6719e0cb',@3=N'310-2'

Interfejs księgowy :: Diagnoza

  • {host_platformacrm}/SD/accounting?new=true# Interfejs Można do niego trafić wybierając z menu: Faktury -> Księgowość dekrety
  1. Sprawdzenie co utknelo w dreketacji.
SQL
select * from OPENQUERY (TETA_CONS_PROD, 'select * from   TETA_ADMIN.RK_API_IMPORT_DOK') x

W wyniku zapytania otrzymujemy liste dokumentów, które utkneły w dekretacji. Prawdopowobnie, przy przeglądaniu listy znajdziemy niezgodność/błąd.

  1. Usuniecie dokumentow czekajacych na dekretacje jest bezpieczne o tym nalezy wyeksportowac z platformy jeszcze raz {host_platformacrm}/SD/accounting?new=true#
SQL
1
2
3
4
5
6
7
8
declare @x nvarchar(max)
 set @x=null
    set @x =
    '
      delete
     from   TETA_ADMIN.RK_API_IMPORT_DOK
    '
 Execute (@x) at TETA_CONS_PROD

Interfejs księgowy :: naprawa, zwykle problem dotyczy faktur które były poprawiane aby to naprawić należy

  1. Wysłać ksiegowej co sie wyeksportowalo do teta dla faktury wynik z poniższego zapytania:
SQL
1
2
3
4
5
select * from OPENQUERY (TETA_CONS_PROD,
'select
    SYMBOL_DOKUMENTU,PODTYP_DOKUMENTU,KOD_WALUTY,WARTOSC_KURSU,NUMER_POZYCJI,KOD_STAWKI_VAT,RODZAJ_ZAKUPU,PARAMETR,SYMBOL_KONTA,
    KWOTA_WN,KWOTA_MA,KWOTA_WN_WALUTA,KWOTA_MA_WALUTA
 from   TETA_ADMIN.RK_API_IMPORT_DOK') x

Przykład analizy rezultatu

Przykład

  1. Nadpisac wartoc na prawidlowa w pozycji linijka ok 372 w procedurze [accounting].[sales_exportToFinancialSystem]

Dokument magazynowy

Księgowa pisze że na dokumencie powinno być są inne konta lub sie nei zapisują

Text Only
Wn 501-20-101
Ma 310-2

Problem dotyczy najprawdodpodobniej braku albo błednej konfiguracji w accounting.warehouseconfiguration

Przykład zapytania

SQL
select * from accounting.warehouseconfiguration  where documenttype like 'ZW' and warehouse1=102

Sprawdzenie jakie konta się generują mozna zapytaniaem

SQL
declare @documentid uniqueidentifier = '71937b2f-cea8-eb11-9567-d89d6719e0cb'
declare @locationcode int = 102
/*Poniżzsez zapytani ejest wyciete z procedury [accounting].[warehouse_exportToFinancialSystem] */
SELECT
  COALESCE(
    cA.wn_account_mask,
    isnull(
      cast(
        [dbo].[fn_accounting_warehouse](
          dc_WN.accountMASK,
          --szablon konta ksiegowego
          x.itemid,
          --itemcode (przekazujemy itemid)
          f.countrycode,
          --countrycode
          CASE
            WHEN D.DOCUMENTTYPE = 'PW' THEN ''
            ELSE isnull(cd.accounting, cd_X.accounting)
          END,
          --@organisationUnit    (tutaj mozna by przekazc od razu jaki kod ksiegowy ale chodzi o spojnosc),
          f.firmNR -- id firmy (podmieniany numer dla spójności)
,
          d.documentType,
          @locationcode,
          null
        ) as varchar(max)
      ),
      '-'
    )
  ) as wn,
  ------------------------TUTAJ
  dc_MA.accountMASK,
  case
    when d.documentType = 'KO_RWP' then 'RW-P'
    when d.documentType = 'ZW' then 'RW-P'
    else REPLACE(d.documentType, 'KO_', '')
  end,
  COALESCE(
    cA.ma_account_mask,
    isnull(
      cast(
        [dbo].[fn_accounting_warehouse](
          dc_MA.accountMASK,
          --szablon konta ksiegowego
          x.itemid,
          --itemcode (przekazujemy itemid)
          f.countrycode,
          --countrycode
          CASE
            WHEN D.DOCUMENTTYPE = 'PW' THEN ''
            ELSE isnull(cd.accounting, cd_X.accounting)
          END,
          --@organisationUnit    (tutaj mozna by przekazc od razu jaki kod ksiegowy ale chodzi o spojnosc),
          f.firmNR --id firmy (podmieniany numer dla spójności)
,
          d.documentType,
          @locationcode,
          null
        ) as varchar(max)
      ),
      '!-'
    )
  ) as ma ------------------------TUTAJ
FROM
  document.documentline x
  inner join document.document d ON d.documentID = x.documentID
  left join wms.itemClass ic on x.itemid = ic.itemid
  and ic.mainGroup = 1
  left join common.dictionary itemsubcategory on ic.itemSubCategoryID = itemsubcategory.dictionaryKey
  and itemsubcategory.dictionaryName = 'itemsubcategory'
  left join document.documentType dt ON dt.documentType = d.documentType
  and dt.componentName in ('documentIn', 'documentOut')
  left join wms.location l on l.locationID = d.warehouseID
  left join wms.location lt on lt.locationID = d.warehouseIDB --   left  join document.invoiceline il ON x.invoiceLineId=il.invoiceLineID and il.status >-1
  left join document.invoice i on i.invoiceFullNR = d.invoiceNR --i.invoiceID = il.invoiceid
  left join common.dictionary cd ON cd.dictionaryKey = d.organisationUnitID
  and cd.dictionaryName = 'organisationUnit'
  and cd.status > -1
  left join wms.commisionLine cl ON cl.commisionLineID = x.commisionLineID
  and cl.status > -1
  left join wms.commision c ON c.commisionID = cl.commisionID
  and c.status > -1
  left join common.dictionary cd_X ON cd_X.dictionaryKey = c.organisationUnitID
  and cd_X.dictionaryName = 'organisationUnit'
  and cd_X.status > -1
  left join firm.firm f on d.firmID = f.firmid
  /*polaczenie z szablonem ksiegowania  DLA STRONY MA!!!!!*/
  left join accounting.warehouseconfiguration dc_MA on dc_MA.documentType = case
    when d.documentType = 'KO_RWP' then 'RW-P'
    when d.documentType = 'ZW' then 'RW-P'
    else REPLACE(d.documentType, 'KO_', '')
  end
  and dc_MA.warehouse1 = l.locationCode
  and dc_MA.status > -1
  and isnull(dc_MA.warehouse2, '') = isnull(lt.locationCode, '')
  and (
    isnull(dc_MA.commisionGroup, '') = isnull(c.commisionGroupID, '')
    or d.documentType not in ('RW-P', 'KO_RWP', 'ZW')
  )
  AND dc_MA.WN_MA = 'MA'
  /*!!!!!*/
  /*polaczenie z szablonem ksiegowania  DLA STRONY WN!!!!!*/
  left join accounting.warehouseconfiguration dc_WN on dc_WN.documentType = case
    when d.documentType = 'KO_RWP' then 'RW-P'
    when d.documentType = 'ZW' then 'RW-P'
    else REPLACE(d.documentType, 'KO_', '')
  end
  and dc_WN.status > -1
  and dc_WN.warehouse1 = l.locationCode
  and isnull(dc_WN.warehouse2, '') = isnull(lt.locationCode, '')
  and (
    isnull(dc_WN.commisionGroup, '') = isnull(c.commisionGroupID, '')
    or d.documentType not in ('RW-P', 'KO_RWP', 'ZW')
  )
  AND dc_WN.WN_MA = 'WN'
  /*!!!!!*/
  /*polaczenie z szablonem konta wpisanym ręcznie!!!*/
  left join accounting.customeAccounting cA ON (
    (
      cA.remoteID = x.documentLineID
      AND (
        d.documentType = 'WZ'
        OR DT.baseDocumentType = 'RWP'
        OR d.documentType = 'RW'
      )
    )
    OR (
      cA.remoteID = isnull(
        isnull(
          x.initialSourceDocumentLineId,
          x.sourceDocumentLineID
        ),
        x.documentLineID
      )
      and (
        d.documentType like 'KO%'
        OR d.documentType IN ('ZW', 'ZWD', 'ZWR')
      )
    )
    or (
      cA.remoteID = x.documentLineID
      AND NOT EXISTS (
        SELECT
          1
        FROM
          accounting.customeAccounting XV
        WHERE
          XV.remoteID = isnull(
            x.initialSourceDocumentLineId,
            x.sourceDocumentLineID
          )
      )
    )
  )
  and cA.remoteSource = 'documentline'
where
  x.status > -1
  and (d.documentID = @documentid) ----<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  and d.status = 1
  and x.status > -1
  and dt.baseDocumentType NOT in ('WMM')