GpStructuredStorage file  _  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~sqli.vtd7 sqliForm.vtdsqliFormName.vtd= sqliStep.vtd sqliStepFile.vtdKGsqliStepStr.vtdLZsqliStepStrEvent.vtdM sqliVar.vtdN sqliVer.vtdOsqliReports.vtdP7sqliTranslation.vtd^acKeyacNamed acIsDebugacType acVarInINI acAutoStart acAutoClose acEndMessageacLocalization2acFormNameAuthoracActive anVersion acLogType acInstCoded anUserChg anUserIns adTimeChg adTimeIns acIsLocalizedacRunOnInstall acRunOnUpdate acRunOnDelete anOldVersion acCryptPassacCompiledScriptacNote acAresLite acUseCompiled acAutoCompileanQId9999999 Utility ARESFAFFFTRT0CԱBʙ _BFFFFFFF& acKey acFormName2 acDocType acObjectName2acType acKeyShortCut2 anUserChg anUserIns adTimeChg adTimeIns acTabSheetName2 acFormTypeanQId acFormName2acName2anQId!acKeyanNoacViewacSetOfacDescracReportacFileCreateTableanFileDelimiter acFileNameacFileTableName acFileDest acFileType acFileTypeXML acShowIfEmptyacTitleButtons anTitleLinesanBeginFromRecord anUserChg anUserIns adTimeChg adTimeIns acCharSet2 acStyleSheet acUnitNamed acNewThreadacDFMacPAS acSQLExport2acSQLExpacNote acCompiledacPCUanQId9999999GPFAENF8MB _B windows-1250 AresProjectFprogram AresProject; uses SysUtils, Classes, Forms, Dialogs, FForm1, LibFiscRecovery; begin // Init eternal dll FiscRecovery.dll Init(DefDatabase.Connection.ConnectString); ares.executeStep(23); ares.executeStep(7); ares.executeStep(2); Form1 := TForm1.Create(ares); Form1.FormType := ftChild; if Form1.FormStyle = fsnormal then Form1.Visible := True; end. 9999999GFFAENFaEB _B windows-1250FForm1F\object Form1: TForm Tag = 99 Left = 0 Top = 0 Caption = 'Utility ARES' ClientHeight = 491 ClientWidth = 1417 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqClearType OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object PageControl: TdlcxPageControl Left = 0 Top = 0 Width = 1417 Height = 491 Align = alClient TabOrder = 0 Properties.ActivePage = tabFursXml Properties.CustomButtons.Buttons = <> ShowMinimizeButton = False Minimized = False ExplicitWidth = 955 ExplicitHeight = 461 ClientRectBottom = 488 ClientRectLeft = 3 ClientRectRight = 1414 ClientRectTop = 26 object tabFursXml: TdlcxTabSheet Caption = 'Furs CSV' Color = 15131095 ImageIndex = 6 ParentColor = False object pFursXmlFilters: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 41 Align = alTop Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object btnFursXml: TdlcxButton Left = 0 Top = 9 Width = 156 Height = 23 Caption = 'Uvozi FURS CSV datoteko' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end end object cxGrid1: TcxGrid Left = 0 Top = 41 Width = 1411 Height = 421 Align = alClient TabOrder = 1 object cxGrid1DBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsFursXml DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.GroupByBox = False object cxGrid1DBTableView1Column1: TcxGridDBColumn Caption = 'Datum fisk,' DataBinding.FieldName = 'adDateTimePrint' Width = 151 end object cxGrid1DBTableView1Column2: TcxGridDBColumn Caption = 'Fisk. '#353'tevilka' DataBinding.FieldName = 'acFiscalKey' Width = 160 end object cxGrid1DBTableView1Column3: TcxGridDBColumn Caption = 'Vrednost dok.' DataBinding.FieldName = 'anValue' Width = 143 end object cxGrid1DBTableView1Column4: TcxGridDBColumn Caption = 'ZOI' DataBinding.FieldName = 'acZIK' Width = 309 end object cxGrid1DBTableView1Column5: TcxGridDBColumn Caption = 'EOR' DataBinding.FieldName = 'acJIR' Width = 412 end end object cxGrid1Level1: TcxGridLevel GridView = cxGrid1DBTableView1 end end end object tabDeleted: TdlcxTabSheet Caption = 'Brisani' Color = 15131095 ImageIndex = 0 ParentColor = False object pFilterD: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 41 Align = alTop Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 DesignSize = ( 1411 41) object btnCreateD: TdlcxButton Left = 4 Top = 7 Width = 75 Height = 25 Caption = 'Kreiraj' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end object btnFillZoi: TdlcxButton Left = 1336 Top = 12 Width = 75 Height = 25 Anchors = [akTop, akRight] Caption = 'Napolni ZOI' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 1 end object btnDeletedZoiDetails: TdlcxButton Left = 1233 Top = 12 Width = 99 Height = 25 Anchors = [akTop, akRight] Caption = 'Podrobnosti ZOI' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 2 end object lSessionID: TdlcxLabeledTextEdit Left = 944 Top = 9 Properties.ReadOnly = True TabOrder = 3 Visible = False LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Caption = 'ID Seje' EditLabel.Color = clWindowText EditLabel.FocusControl = lSessionID EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Visible = False ComponentSize = csSmall Templatable = False Caption = 'ID Seje' ReadOnly = True Width = 121 end object btnRefresh: TdlcxButton Left = 93 Top = 7 Width = 75 Height = 25 Caption = 'Osve'#382'i' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 5 end object rgDDV: TdlcxRadioGroup Left = 189 Top = 2 Properties.Columns = 2 Properties.DefaultValue = 'T' Properties.Items = < item Caption = 'DDV v teko'#269'em obdobju' Value = 'T' end> ItemIndex = 0 TabOrder = 4 ComponentSize = csSmall Templatable = False Height = 37 Width = 407 end end object pDeleted: TdlcxPanel Left = 0 Top = 41 Width = 1411 Height = 421 Align = alClient Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 object pHeadsD: TdlcxPanel Left = 0 Top = 0 Width = 1224 Height = 421 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object grdHeadsDel: TcxGrid Left = 0 Top = 0 Width = 1224 Height = 421 Align = alClient TabOrder = 0 object grdHeadsDelDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsHeadsDel DataController.DetailKeyFieldNames = 'acKey;ChgNum;acType' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Inserting = False OptionsView.GroupByBox = False object grdHeadsDelDBTableView1Column1: TcxGridDBColumn Caption = 'Ozn.' DataBinding.FieldName = 'acMarked' PropertiesClassName = 'TcxCheckBoxProperties' Properties.ImmediatePost = True Properties.NullStyle = nssUnchecked Properties.ValueChecked = 'T' Properties.ValueUnchecked = 'F' end object grdHeadsDelDBTableView1_adDateTimePrint: TcxGridDBColumn Caption = 'Datum printa' DataBinding.FieldName = 'adDateTimePrint' Options.Editing = False end object grdHeadsDelDBTableView1_acKey: TcxGridDBColumn Caption = 'Klju'#269 DataBinding.FieldName = 'acKey' Options.Editing = False end object grdHeadsDelDBTableView1_acZIK: TcxGridDBColumn Caption = 'ZOI' DataBinding.FieldName = 'acZIKFisc' Options.Editing = False Width = 100 end object grdHeadsDelDBTableView1_acJIR: TcxGridDBColumn Caption = 'EOR' DataBinding.FieldName = 'acJIRFisc' Width = 100 end object grdHeadsDelDBTableView1_anFiscalNumber: TcxGridDBColumn Caption = 'Fiskalna '#353't.' DataBinding.FieldName = 'anFiscalNOFisc' Width = 76 end object grdHeadsDelDBTableView1_anForPay: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anForPay' Options.Editing = False end object grdHeadsDelDBTableView1_acCurrency: TcxGridDBColumn Caption = 'Valuta' DataBinding.FieldName = 'acCurrency' end object grdHeadsDelDBTableView1_adDateFiscalised: TcxGridDBColumn Caption = 'Datum Fiskalizacije' DataBinding.FieldName = 'adDateTimePrintFiscalized' Options.Editing = False end object grdHeadsDelDBTableView1_acATIKey: TcxGridDBColumn Caption = 'Knji'#382'enje ra'#269'una' DataBinding.FieldName = 'acATIKey' Options.Editing = False Width = 78 end object grdHeadsDelDBTableView1_acLMATKey: TcxGridDBColumn Caption = 'Knji'#382'enje POS ra'#269'una' DataBinding.FieldName = 'acLMATKey' Options.Editing = False Width = 74 end object grdHeadsDelDBTableView1_acLMATIKey: TcxGridDBColumn Caption = 'Knji'#382'enje porabe materiala' DataBinding.FieldName = 'acLMATIKey' Options.Editing = False Width = 74 end object grdHeadsDelDBTableView1_acLMCRKey: TcxGridDBColumn Caption = 'Blagajna' DataBinding.FieldName = 'acLMCRKey' Options.Editing = False end object grdHeadsDelDBTableView1Column2: TcxGridDBColumn Caption = 'Vrednost DDV-O' DataBinding.FieldName = 'anForPayDDVO' Visible = False Width = 90 end object grdHeadsDelDBTableView1Column3: TcxGridDBColumn Caption = 'Znesek FURS' DataBinding.FieldName = 'anFiscValue' Width = 78 end end object grdHeadsDelLevel1: TcxGridLevel GridView = grdHeadsDelDBTableView1 end end end object pItemsD: TdlcxPanel Left = 1226 Top = 0 Width = 185 Height = 421 Align = alRight Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 object grdItemsDel: TcxGrid Left = 0 Top = 0 Width = 185 Height = 421 Align = alClient TabOrder = 0 object grdItemsDelDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsItemsDel DataController.DetailKeyFieldNames = 'acKey;anNo;ChgNum' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Editing = False OptionsData.Inserting = False OptionsView.Footer = True OptionsView.GroupByBox = False object grdItemsDelDBTableView1_ChgNum: TcxGridDBColumn Caption = #352't.spremembe' DataBinding.FieldName = 'ChgNum' Options.Editing = False end object grdItemsDelDBTableView1_anNo: TcxGridDBColumn Caption = 'Poz.' DataBinding.FieldName = 'anNo' Options.Editing = False end object grdItemsDelDBTableView1_acIdent: TcxGridDBColumn Caption = 'Ident' DataBinding.FieldName = 'acIdent' Options.Editing = False end object grdItemsDelDBTableView1_acName: TcxGridDBColumn Caption = 'Naziv' DataBinding.FieldName = 'acName' Options.Editing = False end object grdItemsDelDBTableView1_anPrice: TcxGridDBColumn Caption = 'Cena' DataBinding.FieldName = 'anPrice' Options.Editing = False end object grdItemsDelDBTableView1_anQty: TcxGridDBColumn Caption = 'Koli'#269'ina' DataBinding.FieldName = 'anQty' Options.Editing = False end object grdItemsDelDBTableView1_anPVOCForPay: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anPVOCForPay' Options.Editing = False end object grdItemsDelDBTableView1Column1: TcxGridDBColumn Caption = 'Popust' DataBinding.FieldName = 'anRebate' end object grdItemsDelDBTableView1Column2: TcxGridDBColumn Caption = 'Tip ser. '#353'tevilke' DataBinding.FieldName = 'acSerialNoType' end end object grdItemsDelLevel1: TcxGridLevel GridView = grdItemsDelDBTableView1 end end end object cxSplitter2: TcxSplitter Left = 1224 Top = 0 Width = 2 Height = 421 AlignSplitter = salRight Control = pItemsD end end end object tabUpdated: TdlcxTabSheet Caption = 'Spremenjeni' Color = 15131095 ImageIndex = 1 ParentColor = False object pChanged: TdlcxPanel Left = 0 Top = 41 Width = 1411 Height = 421 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object pHeadsU: TdlcxPanel Left = 0 Top = 0 Width = 1023 Height = 421 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object grdHeadsUpd: TcxGrid Left = 0 Top = 0 Width = 1023 Height = 421 Align = alClient TabOrder = 0 object grdHeadsUpdDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsHeadsUpd DataController.DetailKeyFieldNames = 'acKey;ChgNum;acType' DataController.MasterKeyFieldNames = 'acKey;ChgNum;acType' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Inserting = False OptionsView.GroupByBox = False object grdHeadsUpdDBTableView1Column5: TcxGridDBColumn Caption = 'Izb.' DataBinding.FieldName = 'acMarked' PropertiesClassName = 'TdlcxCustomCheckBoxProperties' Properties.ValueChecked = 'T' Properties.ValueUnchecked = 'F' end object cxGridDBColumn0: TcxGridDBColumn Caption = 'Vrsta' DataBinding.FieldName = 'acType' Options.Editing = False end object grdHeadsUpdDBTableView1Column7: TcxGridDBColumn Caption = 'Status' DataBinding.FieldName = 'acStatusDescr' Options.Editing = False Width = 54 end object cxGridDBColumn1: TcxGridDBColumn Caption = 'Datum printa' DataBinding.FieldName = 'adDateTimePrint' Options.Editing = False end object cxGridDBColumn2: TcxGridDBColumn Caption = 'Klju'#269 DataBinding.FieldName = 'acKey' Options.Editing = False end object grdHeadsUpdDBTableView1Column6: TcxGridDBColumn Caption = #268'as spremembe' DataBinding.FieldName = '_dl_LastCh' Options.Editing = False Width = 90 end object cxGridDBColumn3: TcxGridDBColumn Caption = 'ZOI' DataBinding.FieldName = 'acZIKFisc' Options.Editing = False Width = 100 end object cxGridDBColumn4: TcxGridDBColumn Caption = 'EOR' DataBinding.FieldName = 'acJIRFisc' Options.Editing = False Width = 100 end object grdHeadsUpdDBTableView1_anFiscalNumber: TcxGridDBColumn Caption = 'Fiskalna '#353't.' DataBinding.FieldName = 'anFiscalNOFisc' end object cxGridDBColumn5: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anForPay' Options.Editing = False end object grdHeadsUpdDBTableView1Column12: TcxGridDBColumn Caption = 'Valuta' DataBinding.FieldName = 'acCurrency' end object cxGridDBColumn6: TcxGridDBColumn Caption = 'Datum Fiskalizacije' DataBinding.FieldName = 'adDateTimePrintFiscalized' Options.Editing = False end object grdHeadsUpdDBTableView1Column1: TcxGridDBColumn Caption = 'Knji'#382'enje ra'#269'una' DataBinding.FieldName = 'acATIKey' Options.Editing = False end object grdHeadsUpdDBTableView1Column2: TcxGridDBColumn Caption = 'Knji'#382'enje POS ra'#269'una' DataBinding.FieldName = 'acLMATKey' Options.Editing = False end object grdHeadsUpdDBTableView1Column3: TcxGridDBColumn Caption = 'Knji'#382'enje porabe materiala' DataBinding.FieldName = 'acLMATIKey' Options.Editing = False end object grdHeadsUpdDBTableView1Column4: TcxGridDBColumn Caption = 'Blagajna' DataBinding.FieldName = 'acLMCRKey' Options.Editing = False end object grdHeadsUpdDBTableView1Column8: TcxGridDBColumn Caption = 'Vrednost DDV-O' DataBinding.FieldName = 'anForPayDDVO' Visible = False end object grdHeadsUpdDBTableView1Column9: TcxGridDBColumn Caption = 'Znesek FURS' DataBinding.FieldName = 'anFiscValue' Width = 78 end object grdHeadsUpdDBTableView1Column10: TcxGridDBColumn Caption = 'Uporabnik (kreiranje)' DataBinding.FieldName = 'acUserIns' end object grdHeadsUpdDBTableView1Column11: TcxGridDBColumn Caption = 'Uporabnik (sprememba)' DataBinding.FieldName = 'acUserUpd' end end object grdHeadsUpdLevel1: TcxGridLevel GridView = grdHeadsUpdDBTableView1 end end end object pItemsU: TdlcxPanel Left = 1027 Top = 0 Width = 384 Height = 421 Align = alRight Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 object grdItemsUpd: TcxGrid Left = 0 Top = 0 Width = 384 Height = 421 Align = alClient TabOrder = 0 object grdItemsUpdDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsItemsUpd DataController.DetailKeyFieldNames = 'acKey;anNo;ChgNum' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Editing = False OptionsData.Inserting = False OptionsView.Footer = True OptionsView.GroupByBox = False object cxGridDBColumn8: TcxGridDBColumn Caption = #352't.spremembe' DataBinding.FieldName = 'ChgNum' Options.Editing = False end object cxGridDBColumn9: TcxGridDBColumn Caption = 'Poz.' DataBinding.FieldName = 'anNo' Options.Editing = False end object cxGridDBColumn10: TcxGridDBColumn Caption = 'Ident' DataBinding.FieldName = 'acIdent' Options.Editing = False end object cxGridDBColumn11: TcxGridDBColumn Caption = 'Naziv' DataBinding.FieldName = 'acName' Options.Editing = False end object cxGridDBColumn12: TcxGridDBColumn Caption = 'Cena' DataBinding.FieldName = 'anPrice' Options.Editing = False end object cxGridDBColumn14: TcxGridDBColumn Caption = 'Koli'#269'ina' DataBinding.FieldName = 'anQty' Options.Editing = False end object cxGridDBColumn13: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anPVOCForPay' Options.Editing = False end object grdItemsUpdDBTableView1Column1: TcxGridDBColumn Caption = 'Popust' DataBinding.FieldName = 'anRebate' end object grdItemsUpdDBTableView1Column3: TcxGridDBColumn Caption = 'Tip ser. '#353'tevilke' DataBinding.FieldName = 'acSerialNoType' end object grdItemsUpdDBTableView1Column2: TcxGridDBColumn Caption = 'Serisjke '#353'tevilke' DataBinding.FieldName = 'acSerialNo' end end object grdItemsUpdLevel1: TcxGridLevel GridView = grdItemsUpdDBTableView1 end end end object cxSplitter1: TcxSplitter Left = 1023 Top = 0 Width = 4 Height = 421 AlignSplitter = salRight Control = pItemsU end end object pFilterU: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 41 Align = alTop Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 DesignSize = ( 1411 41) object lKeyUpd: TdlcxLabel Left = 860 Top = 23 Width = 44 Height = 14 Caption = 'lKeyUpd' Visible = False end object btnCreateU: TdlcxButton Left = 4 Top = 7 Width = 113 Height = 25 Caption = 'Posodobi original' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end object btnChangedZoiDetails: TdlcxButton Left = 1307 Top = 13 Width = 104 Height = 25 Anchors = [akTop, akRight] Caption = 'Podrobnosti ZOI' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 1 end object btnCreateOthers: TdlcxButton Left = 123 Top = 7 Width = 128 Height = 25 Caption = 'Kreiraj spremembe' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 2 end object cbVATExclude: TdlcxCheckBox Left = 656 Top = 9 Caption = 'Ne gre v DDV' Properties.ValueChecked = 'T' Properties.ValueUnchecked = 'F' State = cbsGrayed TabOrder = 3 Transparent = True Width = 121 end object cbFiscExclude: TdlcxCheckBox Left = 740 Top = 17 Caption = 'Se NE fiskalizira' Properties.ValueChecked = 'T' Properties.ValueUnchecked = 'F' State = cbsGrayed TabOrder = 4 Transparent = True Visible = False Width = 121 end object lSurrogateIdent: TdlcxLabeledLookupComboBox Left = 435 Top = 10 Properties.DropDownListStyle = lsEditList Properties.IncrementalFiltering = False Properties.ListColumns = <> Properties.ListOptions.SyncMode = True Properties.ReadOnly = False TabOrder = 5 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Caption = 'Ident za kreiranje spremembe' EditLabel.Color = clWindowText EditLabel.FocusControl = lSurrogateIdent EditLabel.ParentColor = False EditLabel.ParentFont = False ComponentSize = csSmall Templatable = False Caption = 'Ident za kreiranje spremembe' ReadOnly = False LookupType = ltMSService VisibleButtons = [lbDropDown, lbEllipsisButton] LookupTypeIndividualSettings = False Width = 145 end object cbUse: TdlcxCheckBox Left = 580 Top = 9 Caption = 'Uporabi' Properties.ValueChecked = 'T' Properties.ValueUnchecked = 'F' State = cbsGrayed TabOrder = 6 Transparent = True Width = 121 end object bRemove: TdlcxButton Left = 1023 Top = 9 Width = 182 Height = 25 Caption = 'Odstrani ra'#269'un iz seznama' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 8 end object fDocTypeU: TdlcxLabeledLookupComboBox Left = 871 Top = 10 Properties.DropDownListStyle = lsEditList Properties.IncrementalFiltering = False Properties.KeyFieldNames = 'acDocType' Properties.ListColumns = < item Caption = 'Poslovni dogodek' Fixed = True Width = 50 FieldName = 'acDocType' end item Caption = 'Naziv' Fixed = True Width = 150 FieldName = 'acName' end> Properties.ListOptions.SyncMode = True Properties.ListSource = dsDocTypeU Properties.ReadOnly = False TabOrder = 7 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Caption = 'VD za kreiranje' EditLabel.Color = clWindowText EditLabel.FocusControl = fDocTypeU EditLabel.ParentColor = False EditLabel.ParentFont = False ComponentSize = csSmall Templatable = False Caption = 'VD za kreiranje' ReadOnly = False LookupType = ltEmpty VisibleButtons = [lbDropDown, lbEllipsisButton] LookupTypeIndividualSettings = False Width = 145 end end end object tabMoved: TdlcxTabSheet Caption = 'Premaknjeni' Color = 15131095 ImageIndex = 2 ParentColor = False object pMoved: TdlcxPanel Left = 0 Top = 41 Width = 1411 Height = 421 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object grdMoved: TcxGrid Left = 0 Top = 0 Width = 1411 Height = 421 Align = alClient TabOrder = 0 object grdMovedDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsMoved DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Editing = False OptionsView.GroupByBox = False object grdMovedDBTableView1Column1: TcxGridDBColumn Caption = 'Fiskalna '#353'tevilka' DataBinding.FieldName = 'acFiscalNumber' Width = 134 end object grdMovedDBTableView1Column2: TcxGridDBColumn Caption = 'Klju'#269 DataBinding.FieldName = 'acKey' Width = 147 end object grdMovedDBTableView1Column3: TcxGridDBColumn Caption = 'ZOI' DataBinding.FieldName = 'acZIK' Width = 175 end object grdMovedDBTableView1Column4: TcxGridDBColumn Caption = 'EOR' DataBinding.FieldName = 'acJIR' Width = 174 end object grdMovedDBTableView1Column5: TcxGridDBColumn Caption = 'Datum fiskalizacije' DataBinding.FieldName = 'adFiscalDate' Width = 178 end end object grdMovedLevel1: TcxGridLevel GridView = grdMovedDBTableView1 end end end object pModevFilter: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 41 Align = alTop Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 DesignSize = ( 1411 41) object btnMovedZoiDetails: TdlcxButton Left = 1307 Top = 8 Width = 104 Height = 25 Anchors = [akTop, akRight] Caption = 'Podrobnosti ZOI' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end end end object tabDuplicated: TdlcxTabSheet Caption = 'Duplicirani' Color = 15131095 ImageIndex = 11 ParentColor = False object pDuplicated: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 462 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 DesignSize = ( 1411 462) object grdDuplicated: TcxGrid Left = 0 Top = 42 Width = 1411 Height = 420 Anchors = [akLeft, akTop, akRight, akBottom] TabOrder = 0 object grdDuplicatedDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsDuplicated DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.GroupByBox = False object grdDuplicatedDBTableView1Column3: TcxGridDBColumn Caption = 'Ozn.' DataBinding.FieldName = 'anSelected' PropertiesClassName = 'TcxCheckBoxProperties' end object grdDuplicatedDBTableView1Column1: TcxGridDBColumn Caption = 'Interna '#353'tevilka' DataBinding.FieldName = 'acKey' Width = 130 end object grdDuplicatedDBTableView1Column2: TcxGridDBColumn Caption = 'Fiskalna '#353'tevilka' DataBinding.FieldName = 'acFiscalNumber' Width = 147 end object grdDuplicatedDBTableView1Column4: TcxGridDBColumn Caption = 'Datum printa' DataBinding.FieldName = 'adDateTimePrint' Width = 144 end object grdDuplicatedDBTableView1Column5: TcxGridDBColumn Caption = 'Status' DataBinding.FieldName = 'acDescription' Width = 493 end end object grdDuplicatedLevel1: TcxGridLevel GridView = grdDuplicatedDBTableView1 end end object bDupFix: TdlcxButton Left = 84 Top = 11 Width = 75 Height = 25 Caption = 'Popravi' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 1 end object bDupRefresh: TdlcxButton Left = 5 Top = 11 Width = 75 Height = 25 Caption = 'Osve'#382'i' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 2 end object bDupRemove: TdlcxButton Left = 1113 Top = 13 Width = 182 Height = 25 Anchors = [akTop, akRight] Caption = 'Odstrani ra'#269'un iz seznama' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 3 end object btnDuplicatedShowZoi: TdlcxButton Left = 1307 Top = 13 Width = 104 Height = 25 Anchors = [akTop, akRight] Caption = 'Podrobnosti ZOI' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 4 end end end object tabMissmatch: TdlcxTabSheet Caption = 'Pregled vrednosti glav/pozicij' Color = 15131095 ImageIndex = 7 ParentColor = False object pMissMatch: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 462 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object pHeadsMM: TdlcxPanel Left = 0 Top = 41 Width = 1014 Height = 421 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object grdHeadsMM: TcxGrid Left = 0 Top = 0 Width = 1014 Height = 421 Align = alClient TabOrder = 0 object grdHeadsMMDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsHeadsMM DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Inserting = False OptionsView.GroupByBox = False object grdHeadsMMDBTableView1Column1: TcxGridDBColumn Caption = 'Ozn.' DataBinding.FieldName = 'acMarked' PropertiesClassName = 'TdlcxCustomCheckBoxProperties' Properties.NullStyle = nssUnchecked Properties.ValueChecked = 'T' Properties.ValueUnchecked = 'F' end object grdHeadsMMDBTableView1Column2: TcxGridDBColumn Caption = 'Vrsta' DataBinding.FieldName = 'acType' Options.Editing = False end object grdHeadsMMDBTableView1Column3: TcxGridDBColumn Caption = 'Status' DataBinding.FieldName = 'acStatusDescr' Options.Editing = False Width = 55 end object grdHeadsMMDBTableView1Column4: TcxGridDBColumn Caption = 'Datum printa' DataBinding.FieldName = 'adDateTimePrint' Options.Editing = False Width = 73 end object grdHeadsMMDBTableView1Column5: TcxGridDBColumn Caption = 'Klju'#269 DataBinding.FieldName = 'acKey' Options.Editing = False end object grdHeadsMMDBTableView1Column6: TcxGridDBColumn Caption = #268'as spremembe' DataBinding.FieldName = '_dl_LastCh' Options.Editing = False end object grdHeadsMMDBTableView1Column7: TcxGridDBColumn Caption = 'ZOI' DataBinding.FieldName = 'acZik' Options.Editing = False Width = 231 end object grdHeadsMMDBTableView1Column8: TcxGridDBColumn Caption = 'EOR' DataBinding.FieldName = 'acJIR' Options.Editing = False Width = 241 end object grdHeadsMMDBTableView1_anFiscalNumber: TcxGridDBColumn Caption = 'Fiskalna '#353't.' DataBinding.FieldName = 'anFiscalNumber' end object grdHeadsMMDBTableView1Column9: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anForPay' Options.Editing = False end object grdHeadsMMDBTableView1Column11: TcxGridDBColumn Caption = 'Valuta' DataBinding.FieldName = 'acCurrency' end object grdHeadsMMDBTableView1Column10: TcxGridDBColumn Caption = 'Datum fiskalizacije' DataBinding.FieldName = 'adFiscalDate' Options.Editing = False end object grdHeadsMMDBTableView1Column12: TcxGridDBColumn Caption = 'Knji'#382'enje ra'#269'una' DataBinding.FieldName = 'acATIKey' Options.Editing = False end object grdHeadsMMDBTableView1Column13: TcxGridDBColumn Caption = 'Knji'#382'enje POS ra'#269'una' DataBinding.FieldName = 'acLMATKey' Options.Editing = False end object grdHeadsMMDBTableView1Column14: TcxGridDBColumn Caption = 'Knji'#382'enje porabe materiala' DataBinding.FieldName = 'acLMATIKey' Options.Editing = False end object grdHeadsMMDBTableView1Column15: TcxGridDBColumn Caption = 'Blagajna' DataBinding.FieldName = 'acLMCRKey' Options.Editing = False end object grdHeadsMMDBTableView1Column16: TcxGridDBColumn Caption = 'DDV-O' DataBinding.FieldName = 'anForPayDDVO' Visible = False Options.Editing = False end object grdHeadsMMDBTableView1Column17: TcxGridDBColumn Caption = 'Znesek FURS' DataBinding.FieldName = 'anValue' Options.Editing = False Width = 79 end end object grdHeadsMMLevel1: TcxGridLevel GridView = grdHeadsMMDBTableView1 end end end object pItemsMM: TdlcxPanel Left = 1022 Top = 41 Width = 389 Height = 421 Align = alRight Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 object grdItemsMM: TcxGrid Left = 0 Top = 0 Width = 389 Height = 421 Align = alClient TabOrder = 0 object grdItemsMMDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsItemsMM DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.Footer = True OptionsView.GroupByBox = False object grdItemsMMDBTableView1Column1: TcxGridDBColumn Caption = #352't. spremembe' DataBinding.FieldName = 'ChgNum' Options.Editing = False end object grdItemsMMDBTableView1Column2: TcxGridDBColumn Caption = 'Poz.' DataBinding.FieldName = 'anNO' Options.Editing = False end object grdItemsMMDBTableView1Column3: TcxGridDBColumn Caption = 'Ident' DataBinding.FieldName = 'acIdent' Options.Editing = False end object grdItemsMMDBTableView1Column4: TcxGridDBColumn Caption = 'Naziv' DataBinding.FieldName = 'acName' Options.Editing = False end object grdItemsMMDBTableView1Column5: TcxGridDBColumn Caption = 'Cena' DataBinding.FieldName = 'anPrice' Options.Editing = False end object grdItemsMMDBTableView1Column6: TcxGridDBColumn Caption = 'Koli'#269'ina' DataBinding.FieldName = 'anQty' Options.Editing = False end object grdItemsMMDBTableView1Column7: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anPVOCForPay' Options.Editing = False end object grdItemsMMDBTableView1Column8: TcxGridDBColumn Caption = 'Popust' DataBinding.FieldName = 'anRebate' Options.Editing = False end end object grdItemsMMLevel1: TcxGridLevel GridView = grdItemsMMDBTableView1 end end end object cxSplitter5: TcxSplitter Left = 1014 Top = 41 Width = 8 Height = 421 AlignSplitter = salRight Control = pItemsMM end object pFilterMM: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 41 Align = alTop Caption = '' TabOrder = 3 HeaderCaptionDistance = 8 DesignSize = ( 1411 41) object btnStornoCreateMM: TdlcxButton Left = 299 Top = 12 Width = 75 Height = 25 Caption = 'Popravi' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end object btnRefreshMargin: TdlcxButton Left = 209 Top = 12 Width = 75 Height = 25 Caption = 'Osve'#382'i' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 1 end object neMargin: TdlcxLabeledNumberEdit Left = 84 Top = 13 EditValue = 0.500000000000000000 Properties.Alignment.Horz = taRightJustify Properties.AssignedValues.DisplayFormat = True Properties.DecimalPlaces = 3 Properties.MaxValue = 100.000000000000000000 Properties.ReadOnly = False TabOrder = 2 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Caption = '% odstopanja' EditLabel.Color = clWindowText EditLabel.FocusControl = neMargin EditLabel.ParentColor = False EditLabel.ParentFont = False ComponentSize = csSmall Caption = '% odstopanja' Templatable = False ReadOnly = False Width = 121 end object btnHeadValueShowZoi: TdlcxButton Left = 1307 Top = 13 Width = 104 Height = 25 Anchors = [akTop, akRight] Caption = 'Podrobnosti ZOI' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 3 end end end end object tabFxRate: TdlcxTabSheet Caption = 'Napake na valuti' Color = 15131095 ImageIndex = 10 ParentColor = False DesignSize = ( 1411 462) object bFxRateRefresh: TdlcxButton Left = 5 Top = 11 Width = 75 Height = 25 Caption = 'Osve'#382'i' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end object grdFxRate: TcxGrid Left = 5 Top = 47 Width = 1401 Height = 415 Anchors = [akLeft, akTop, akRight, akBottom] TabOrder = 1 object grdFxRateView: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsFxRate DataController.DetailKeyFieldNames = 'acKey' DataController.KeyFieldNames = 'acKey' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.GroupByBox = False object grdFxRateViewColumn9: TcxGridDBColumn Caption = 'Ozn.' DataBinding.FieldName = 'anSelected' PropertiesClassName = 'TcxCheckBoxProperties' Width = 37 end object grdFxRateViewColumn1: TcxGridDBColumn Caption = 'Kjlu'#269' dokumenta' DataBinding.FieldName = 'acKey' Options.Editing = False Width = 136 end object grdFxRateViewColumn2: TcxGridDBColumn Caption = 'Fiskalna '#353'tevilka' DataBinding.FieldName = 'acFiscalNo' Options.Editing = False Width = 152 end object grdFxRateViewColumn3: TcxGridDBColumn Caption = 'Datum fiskalizacije' DataBinding.FieldName = 'adFiscalDate' Options.Editing = False Width = 119 end object grdFxRateViewColumn4: TcxGridDBColumn Caption = 'Znesek PA' DataBinding.FieldName = 'anForPay' Options.Editing = False Width = 121 end object grdFxRateViewColumn5: TcxGridDBColumn Caption = 'Te'#269'aj' DataBinding.FieldName = 'anFXRate' Options.Editing = False Width = 40 end object grdFxRateViewColumn6: TcxGridDBColumn Caption = 'Znesek te'#269'aj PA' DataBinding.FieldName = 'anCurrValue' Options.Editing = False Width = 151 end object grdFxRateViewColumn7: TcxGridDBColumn Caption = 'Znesek FURS' DataBinding.FieldName = 'anFiscValue' Options.Editing = False Width = 175 end object grdFxRateViewColumn8: TcxGridDBColumn Caption = 'Status' DataBinding.FieldName = 'acDescription' Options.Editing = False Width = 335 end end object grdFxRateLevel1: TcxGridLevel GridView = grdFxRateView end end object bFxRateFix: TdlcxButton Left = 84 Top = 11 Width = 75 Height = 25 Caption = 'Popravi' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 2 end object btnFXRateShowZoi: TdlcxButton Left = 1307 Top = 13 Width = 104 Height = 25 Anchors = [akTop, akRight] Caption = 'Podrobnosti ZOI' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 3 end end object tabValueMissmatch: TdlcxTabSheet Caption = 'Neujemanje zneska ali fiskalne '#353'tevilke FURS/PA ' Color = 15131095 ImageIndex = 8 ParentColor = False ExplicitLeft = 0 ExplicitTop = 0 ExplicitWidth = 0 ExplicitHeight = 0 object dlcxPanel8: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 41 Align = alTop Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object bRefresh: TdlcxButton Left = 18 Top = 8 Width = 75 Height = 25 Caption = 'Osve'#382'i' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end end object dlcxPanel9: TdlcxPanel Left = 0 Top = 41 Width = 1411 Height = 421 Align = alClient Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 object grdValueMissmatch: TcxGrid Left = 0 Top = 0 Width = 1411 Height = 421 Align = alClient TabOrder = 0 object grdValueMissmatchDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsValueMissmatch DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Inserting = False OptionsSelection.CellSelect = False OptionsView.GroupByBox = False object grdValueMissmatchDBTableView1Column1: TcxGridDBColumn Caption = 'Znesek FURS' DataBinding.FieldName = 'anValue' Width = 98 end object grdValueMissmatchDBTableView1Column2: TcxGridDBColumn Caption = 'Znesek PA' DataBinding.FieldName = 'anForPay' Width = 102 end object grdValueMissmatchDBTableView1Column3: TcxGridDBColumn Caption = 'Fiskalna '#353't. FURS' DataBinding.FieldName = 'acFiscalNumberFURS' Width = 136 end object grdValueMissmatchDBTableView1Column5: TcxGridDBColumn Caption = 'Fiskalna '#353't. PA' DataBinding.FieldName = 'acFiscalNumberPA' Width = 106 end object grdValueMissmatchDBTableView1Column4: TcxGridDBColumn Caption = 'Interna '#353'tevilka' DataBinding.FieldName = 'acKey' Width = 131 end end object grdValueMissmatchLevel1: TcxGridLevel GridView = grdValueMissmatchDBTableView1 end end end end object tabCreated: TdlcxTabSheet Caption = 'Pregled kreiranih dokumentov' Color = 15131095 ImageIndex = 2 ParentColor = False ExplicitLeft = 0 ExplicitTop = 0 ExplicitWidth = 0 ExplicitHeight = 0 object pCreated: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 462 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object grdCreated: TcxGrid Left = 0 Top = 41 Width = 1411 Height = 421 Align = alClient TabOrder = 0 object grdCreatedDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsCreated DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsView.GroupByBox = False object grdCreatedDBTableView1Column1: TcxGridDBColumn Caption = 'Kreiran klju'#269 DataBinding.FieldName = 'acKey' PropertiesClassName = 'TdlcxLookupComboBoxProperties' Properties.ClearKey = 46 Properties.DropDownAutoSize = True Properties.IncrementalFiltering = False Properties.KeyFieldNames = 'acKey' Properties.ListColumns = < item Caption = 'Klju'#269 FieldName = 'acKey' end> Properties.ListOptions.SyncMode = True Properties.ListSource = dsKeyCreated Properties.PostPopupValueOnTab = True Properties.ShowFieldNameValue = True Properties.LookupType = ltEmpty Properties.VisibleButtons = [lbDropDown, lbEllipsisButton] Width = 194 end object grdCreatedDBTableView1_acKey: TcxGridDBColumn Caption = 'Originalen klju'#269 DataBinding.FieldName = 'acKeyOrig' Width = 194 end object grdCreatedDBTableView1Column3: TcxGridDBColumn Caption = 'Na'#269'in kreiranja' DataBinding.FieldName = 'acCreatedType' Options.Editing = False Width = 94 end object grdCreatedDBTableView1Column2: TcxGridDBColumn DataBinding.FieldName = 'acStatus' PropertiesClassName = 'TdlcxImageComboBoxProperties' Properties.Items = < item Description = 'Pozicije Brisanje/Dodajanje' ImageIndex = 0 Value = 'Pozicije Brisanje/Dodajanje' end item Description = 'Dokument brisanje' Value = 'Dokument brisanje' end item Description = 'Razlike Glave/Pozicije' Value = '0' end item Description = 'Pozicije Dodajanje' Value = 'Pozicije Dodajanje' end item Description = 'Tehni'#269'ni popravek' Value = 'Tehni'#269'ni popravek' end item Description = 'Popravljena valuta' Value = 'Popravljena valuta' end item Description = 'Odstranjen' Value = 'Odstranjen' end item Description = 'Duplikat tehni'#269'ni popravek' Value = 'Duplikat tehni'#269'ni popravek' end> Properties.ClearValue = Null Width = 235 end object grdCreatedDBTableView1_acNote: TcxGridDBColumn Caption = 'Ugotovitve' DataBinding.FieldName = 'acNote' Width = 218 end object grdCreatedDBTableView1_acStatusCreated: TcxGridDBColumn Caption = 'Status' DataBinding.FieldName = 'acStatusCreated' Width = 219 end object grdCreatedDBTableView1_anVATInCurPer: TcxGridDBColumn Caption = 'DDV v tek. obd.' DataBinding.FieldName = 'anVatInCurPer' PropertiesClassName = 'TcxCurrencyEditProperties' Width = 96 end end object grdCreatedLevel1: TcxGridLevel GridView = grdCreatedDBTableView1 end end object dlcxPanel7: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 41 Align = alTop Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 object bReport: TdlcxButton Left = 0 Top = 9 Width = 299 Height = 23 Caption = 'Poro'#269'ilo o kreiranih in spremenjenih dokumentih' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end end end end object tabError: TdlcxTabSheet Caption = 'Napake pri kreiranju' Color = 15131095 ImageIndex = 3 ParentColor = False ExplicitLeft = 0 ExplicitTop = 0 ExplicitWidth = 0 ExplicitHeight = 0 object pError: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 462 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object grdError: TcxGrid Left = 0 Top = 0 Width = 1411 Height = 462 Align = alClient TabOrder = 0 object grdErrorDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsError DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.GroupByBox = False object grdErrorDBTableView1Column1: TcxGridDBColumn Caption = 'Klju'#269 DataBinding.FieldName = 'acKey' end object grdErrorDBTableView1Column2: TcxGridDBColumn Caption = 'Napaka' DataBinding.FieldName = 'acError' Width = 816 end end object grdErrorLevel1: TcxGridLevel GridView = grdErrorDBTableView1 end end end end object tabLog: TdlcxTabSheet Caption = 'Log sprememb' Color = 15131095 ImageIndex = 5 ParentColor = False ExplicitLeft = 0 ExplicitTop = 0 ExplicitWidth = 0 ExplicitHeight = 0 object pLog: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 462 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object dlcxPanel1: TdlcxPanel Left = 0 Top = 0 Width = 213 Height = 462 Align = alLeft Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object dlcxPanel2: TdlcxPanel Left = 0 Top = 0 Width = 213 Height = 41 Align = alTop Alignment = taCenter Caption = 'Spremembe' TabOrder = 0 HeaderCaptionDistance = 8 end object grdChanges: TcxGrid Left = 0 Top = 41 Width = 213 Height = 421 Align = alClient TabOrder = 1 object grdChangesDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsChangesLog DataController.DetailKeyFieldNames = 'anChgNumSession' DataController.MasterKeyFieldNames = 'anChgNumSession' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.GroupByBox = False object grdChangesDBTableView1Column1: TcxGridDBColumn Caption = #268'as spremembe' DataBinding.FieldName = 'adTimeIns' Width = 94 end object grdChangesDBTableView1Column2: TcxGridDBColumn Caption = 'Uporabnik' DataBinding.FieldName = 'anUserId' Width = 86 end end object grdChangesLevel1: TcxGridLevel GridView = grdChangesDBTableView1 end end end object cxSplitter3: TcxSplitter Left = 213 Top = 0 Width = 4 Height = 462 Control = dlcxPanel1 end object dlcxPanel3: TdlcxPanel Left = 217 Top = 0 Width = 790 Height = 462 Align = alLeft Caption = '' TabOrder = 2 HeaderCaptionDistance = 8 object dlcxPanel4: TdlcxPanel Left = 0 Top = 0 Width = 790 Height = 41 Align = alTop Alignment = taCenter Caption = 'Podatki, ki so se spremenili' TabOrder = 0 HeaderCaptionDistance = 8 end object grdChangesAnalitycal: TcxGrid Left = 0 Top = 41 Width = 790 Height = 421 Align = alClient TabOrder = 1 object grdChangesAnalitycalDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsChangesLogAnalytical DataController.DetailKeyFieldNames = 'acKey;ChgNum;acType;anChgNumSession' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.GroupByBox = False object grdChangesAnalitycalDBTableView1Column1: TcxGridDBColumn Caption = 'Datum printa' DataBinding.FieldName = 'adDateTimePrint' Width = 112 end object grdChangesAnalitycalDBTableView1Column2: TcxGridDBColumn Caption = 'Klju'#269 DataBinding.FieldName = 'acKey' Width = 142 end object grdChangesAnalitycalDBTableView1Column3: TcxGridDBColumn Caption = 'ZOI' DataBinding.FieldName = 'acZIK' Width = 170 end object grdChangesAnalitycalDBTableView1Column4: TcxGridDBColumn Caption = 'EOR' DataBinding.FieldName = 'acJIR' Width = 127 end object grdChangesAnalitycalDBTableView1Column5: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anForPay' Width = 77 end object grdChangesAnalitycalDBTableView1Column6: TcxGridDBColumn Caption = 'Datum Fiskalizacije' DataBinding.FieldName = 'adDateTimePrintFiscalized' Width = 105 end object grdChangesAnalitycalDBTableView1Column7: TcxGridDBColumn Caption = 'Knji'#382'enje ra'#269'una' DataBinding.FieldName = 'acATIKey' Width = 83 end object grdChangesAnalitycalDBTableView1Column8: TcxGridDBColumn Caption = 'Knji'#382'enje POS ra'#269'una' DataBinding.FieldName = 'acLMATKey' end object grdChangesAnalitycalDBTableView1Column9: TcxGridDBColumn Caption = 'Knji'#382'enje porabe materiala' DataBinding.FieldName = 'acLMATIKey' end object grdChangesAnalitycalDBTableView1Column10: TcxGridDBColumn Caption = 'Blagajna' DataBinding.FieldName = 'acLMCRKey' end end object grdChangesAnalitycalLevel1: TcxGridLevel GridView = grdChangesAnalitycalDBTableView1 end end end object cxSplitter4: TcxSplitter Left = 1007 Top = 0 Width = 4 Height = 462 Control = dlcxPanel3 end object dlcxPanel5: TdlcxPanel Left = 1011 Top = 0 Width = 400 Height = 462 Align = alClient Caption = '' TabOrder = 4 HeaderCaptionDistance = 8 object dlcxPanel6: TdlcxPanel Left = 0 Top = 0 Width = 400 Height = 41 Align = alTop Alignment = taCenter Caption = 'Kreirani ra'#269'uni' TabOrder = 0 HeaderCaptionDistance = 8 end object grdChangesHeadsCreated: TcxGrid Left = 0 Top = 41 Width = 400 Height = 421 Align = alClient TabOrder = 1 object grdChangesHeadsCreatedDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsChangesHeadsCre DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsView.GroupByBox = False object grdChangesHeadsCreatedDBTableView1Column1: TcxGridDBColumn Caption = 'Kreiran ra'#269'un' DataBinding.FieldName = 'acKey' Width = 171 end object grdChangesHeadsCreatedDBTableView1Column2: TcxGridDBColumn Caption = 'Na'#269'in kreiranja' DataBinding.FieldName = 'acCreatedType' Width = 110 end end object grdChangesHeadsCreatedLevel1: TcxGridLevel GridView = grdChangesHeadsCreatedDBTableView1 end end end end end object tabUtility: TdlcxTabSheet Caption = 'Utility' Color = 15131095 ImageIndex = 9 ParentColor = False ExplicitLeft = 0 ExplicitTop = 0 ExplicitWidth = 0 ExplicitHeight = 0 object pUtility: TdlcxPanel Left = 0 Top = 0 Width = 1411 Height = 462 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 ExplicitLeft = 598 ExplicitTop = 207 ExplicitWidth = 185 ExplicitHeight = 41 object pFindDoc: TdlcxPanel Left = 273 Top = 0 Width = 1138 Height = 462 Align = alClient BorderProperties.Kind.Right = dbrGroup Caption = '' TabOrder = 0 HeaderVisible = True HeaderColor = 14142915 HeaderCaption = 'I'#353#269'i dokumente po znesku' HeaderColorTo = 14142915 HeaderHeight = 22 HeaderFont.Charset = DEFAULT_CHARSET HeaderFont.Color = clWindowText HeaderFont.Height = -12 HeaderFont.Name = 'Calibri' HeaderFont.Style = [fsBold] HeaderFont.Quality = fqClearType HeaderPanelType = ptSubWithHeader HeaderCaptionDistance = 8 ExplicitWidth = 987 object pGridResults: TdlcxPanel Left = 0 Top = 82 Width = 1138 Height = 380 Align = alClient Caption = '' TabOrder = 0 HeaderCaptionDistance = 8 object grdFilterResults: TcxGrid Left = 0 Top = 0 Width = 1138 Height = 380 Align = alClient TabOrder = 0 object grdFilterResultsDBTableView1: TcxGridDBTableView Navigator.Buttons.CustomButtons = <> DataController.DataSource = dsSearchResults DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsData.Deleting = False OptionsData.DeletingConfirmation = False OptionsData.Editing = False OptionsData.Inserting = False OptionsView.GroupByBox = False object grdFilterResultsDBTableView1_acKey: TcxGridDBColumn Caption = 'Klju'#269 DataBinding.FieldName = 'acKey' Width = 139 end object grdFilterResultsDBTableView1_adDate: TcxGridDBColumn Caption = 'Datum' DataBinding.FieldName = 'adDate' Width = 79 end object grdFilterResultsDBTableView1_acZIK: TcxGridDBColumn Caption = 'ZOI' DataBinding.FieldName = 'acZIK' Width = 227 end object grdFilterResultsDBTableView1_acJIR: TcxGridDBColumn Caption = 'EOR' DataBinding.FieldName = 'acJIR' Width = 236 end object grdFilterResultsDBTableView1_anFiscalNumber: TcxGridDBColumn Caption = 'Fisk.'#353't.' DataBinding.FieldName = 'anFiscalNumber' Width = 79 end object grdFilterResultsDBTableView1_adDateTimePrint: TcxGridDBColumn Caption = 'Datum tiskanja' DataBinding.FieldName = 'adDateTimePrint' Width = 140 end object grdFilterResultsDBTableView1_anValue: TcxGridDBColumn Caption = 'Vrednost' DataBinding.FieldName = 'anValue' Width = 73 end object grdFilterResultsDBTableView1_anVAT: TcxGridDBColumn Caption = 'DDV' DataBinding.FieldName = 'anVAT' Width = 81 end object grdFilterResultsDBTableView1_anForPay: TcxGridDBColumn Caption = 'Za pla'#269'ilo' DataBinding.FieldName = 'anForPay' Width = 150 end end object grdFilterResultsLevel1: TcxGridLevel GridView = grdFilterResultsDBTableView1 end end end object pFilterFind: TdlcxPanel Left = 0 Top = 20 Width = 1138 Height = 62 Align = alTop BorderProperties.Kind.Bottom = dbrGroup Caption = '' TabOrder = 1 HeaderCaptionDistance = 8 ExplicitWidth = 987 object neForPay: TdlcxLabeledNumberEdit Left = 76 Top = 35 EditValue = 0.000000000000000000 Properties.Alignment.Horz = taRightJustify Properties.AssignedValues.DisplayFormat = True Properties.ReadOnly = False TabOrder = 0 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Caption = 'Za pla'#269'ilo' EditLabel.Color = clWindowText EditLabel.FocusControl = neForPay EditLabel.ParentColor = False EditLabel.ParentFont = False ComponentSize = csSmall Caption = 'Za pla'#269'ilo' Templatable = False ReadOnly = False Width = 121 end object btnFind: TdlcxButton Left = 201 Top = 33 Width = 75 Height = 25 Caption = 'Poi'#353#269'i' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 1 end end end object pFiscNoUpd: TdlcxPanel Left = 0 Top = 0 Width = 273 Height = 462 Align = alLeft BorderProperties.Kind.Right = dbrGroup Caption = '' TabOrder = 1 HeaderVisible = True HeaderColor = 14142915 HeaderCaption = 'Poi'#353#269'i fiskalno '#353'tevilko' HeaderColorTo = 14142915 HeaderHeight = 22 HeaderFont.Charset = DEFAULT_CHARSET HeaderFont.Color = clWindowText HeaderFont.Height = -12 HeaderFont.Name = 'Calibri' HeaderFont.Style = [fsBold] HeaderFont.Quality = fqClearType HeaderPanelType = ptSubWithHeader HeaderCaptionDistance = 8 object btnUpdateFiscNo: TdlcxButton Left = 161 Top = 97 Width = 75 Height = 25 Caption = 'Posodobi' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 0 end object neFiscalNumber: TdlcxLabeledNumberEdit Left = 95 Top = 69 EditValue = 0.000000000000000000 Properties.Alignment.Horz = taRightJustify Properties.AssignedValues.DisplayFormat = True Properties.DecimalPlaces = 0 Properties.ReadOnly = False TabOrder = 1 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Caption = 'Fiskalna '#353't.' EditLabel.Color = clWindowText EditLabel.FocusControl = neFiscalNumber EditLabel.ParentColor = False EditLabel.ParentFont = False ComponentSize = csSmall Caption = 'Fiskalna '#353't.' Templatable = False ReadOnly = False Width = 145 end object fKey: TdlcxLabeledLookupComboBox Left = 95 Top = 40 Properties.DropDownListStyle = lsEditList Properties.IncrementalFiltering = False Properties.KeyFieldNames = 'acKey' Properties.ListColumns = < item Caption = 'Klju'#269 FieldName = 'acKey' end> Properties.ListOptions.SyncMode = True Properties.ListSource = dsKey Properties.ReadOnly = False TabOrder = 2 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Caption = 'Klju'#269' dokumenta' EditLabel.Color = clWindowText EditLabel.FocusControl = fKey EditLabel.ParentColor = False EditLabel.ParentFont = False ComponentSize = csSmall Templatable = False Caption = 'Klju'#269' dokumenta' ReadOnly = False LookupType = ltEmpty VisibleButtons = [lbDropDown, lbEllipsisButton] LookupTypeIndividualSettings = False Width = 145 end end end end end object _evsaver: TEventCom events = 'tbHeadsDel.AfterOpen=tbHeadsDelAfterOpen'#13#10'tbHeadsUpd.AfterOpen=t' + 'bHeadsUpdAfterOpen'#13#10'tbHeadsMM.AfterOpen=tbHeadsMMAfterOpen'#13#10 end object tbHeadsUpd: TdlDataset SQL.Strings = ( 'select A.*, FFD.anValue as anFiscValue, ' 'case when FFD.acZIK is null then A.acZIK else FFD.acZIK end as ' + 'acZIKFisc,' 'case when FFD.acJIR is null then A.acJIR else FFD.acJIR end as ' + 'acJIRFisc ,' 'case when FFD.anFiscalNumber is null then A.anFiscalNumber else ' + 'FFD.anFiscalNumber end as anFiscalNOFisc,' 'rtrim(IsNull(rtrim(SSC.acUserId), Isnull(A.anUserIns, '#39#39'))) as a' + 'cUserIns, rtrim(IsNull(rtrim(SSC2.acUserId), IsNull(A._dl_UserCh' + ', '#39#39'))) as acUserUpd' 'from #lHE_ChangedInvoicesAnalytical A' 'left join _linksFisc L on A.ackey = L.acKeyOrig and L.acCreated ' + '= '#39'A'#39 'left join #lHE_FURSFiscData FFD on FFD.adDateTimePrint = dateadd' + '(millisecond, -datepart(millisecond, A.addateTimePrint), A.addat' + 'eTimePrint) ' 'left join tHE_SetSubjContact SSC on SSC.anUserId = A.anUserIns' 'left join tHE_SetSubjContact SSC2 on SSC2.anUserId = A._dl_UserC' + 'h' 'where A.acChgType = '#39'U'#39 'and L.acKeyOrig is null' 'order by A.acKey, A.acType desc, A.ChgNum' '') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = 'acKey;acType;ChgNum' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 120 end object dsHeadsUpd: TDataSource DataSet = tbHeadsUpd Left = 1215 Top = 120 end object tbItemsUpd: TdlDataset SQL.Strings = ( 'Select CAI.* from #lHE_ChangedInvoicesAnalyticalItems CAI' 'INNER JOIN #lHE_ChangedInvoicesAnalytical CA on CA.acKey = CAI.a' + 'cKey and CA.ChgNum = CAI.ChgNum and CA.acType = CAI.acType' 'where CAI.acKey = :acKey' 'and CAI.ChgNum = :ChgNum ' 'and CAI.acType = :acType' 'and CA.acChgType = '#39'U'#39 'order by anNo' '' '' '') FieldNamesToUpperCase = False MasterSource = dsHeadsUpd MasterFields = 'acKey;acType;ChgNum' UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 150 ParamData = < item DataType = ftUnknown Name = 'acKey' Value = nil end item DataType = ftUnknown Name = 'ChgNum' Value = nil end item DataType = ftUnknown Name = 'acType' Value = nil end> end object dsItemsUpd: TDataSource DataSet = tbItemsUpd Left = 1215 Top = 150 end object dsHeadsDel: TDataSource DataSet = tbHeadsDel Left = 1215 Top = 60 end object tbHeadsDel: TdlDataset SQL.Strings = ( 'select A.*, FFD.anValue as anFiscValue, ' 'case when FFD.acZIK is null then A.acZIK else FFD.acZIK end as ' + 'acZIKFisc,' 'case when FFD.acJIR is null then A.acJIR else FFD.acJIR end as ' + 'acJIRFisc ,' 'case when FFD.anFiscalNumber is null then A.anFiscalNumber else ' + 'FFD.anFiscalNumber end as anFiscalNOFisc ' 'from #lHE_ChangedInvoicesAnalytical A' 'left join _linksFisc L on A.ackey = L.acKeyOrig' 'left join #lHE_FURSFiscData FFD on FFD.adDateTimePrint = dateadd' + '(millisecond, -datepart(millisecond, A.addateTimePrint), A.addat' + 'eTimePrint) ' 'where A.acChgType = '#39'D'#39' and L.acKey is null' 'order by A.acKey, A.ChgNum') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = 'acKey;acType;ChgNum' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 60 end object tbItemsDel: TdlDataset SQL.Strings = ( 'Select CAI.* from #lHE_ChangedInvoicesAnalyticalItems CAI' 'INNER JOIN #lHE_ChangedInvoicesAnalytical CA on CA.acKey = CAI.a' + 'cKey and CA.ChgNum = CAI.ChgNum and CA.acType = CAI.acType' 'where CAI.acKey = :acKey' 'and CAI.ChgNum = :ChgNum ' 'and CAI.acType = :acType' 'and CA.acChgType = '#39'D'#39 'order by anNo') FieldNamesToUpperCase = False MasterSource = dsHeadsDel MasterFields = 'acKey;acType;ChgNum' UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 90 ParamData = < item DataType = ftUnknown Name = 'acKey' Value = nil end item DataType = ftUnknown Name = 'ChgNum' Value = nil end item DataType = ftUnknown Name = 'acType' Value = nil end> end object dsItemsDel: TDataSource DataSet = tbItemsDel Left = 1215 Top = 90 end object tbError: TdlDataset SQL.Strings = ( 'select * from #lHE_CreationErrors') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 330 end object dsError: TDataSource DataSet = tbError Left = 1215 Top = 330 end object tbCreated: TdlDataset SQL.Strings = ( 'select *' ' from _LinksFisc' '') FieldNamesToUpperCase = False Active = True UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = 'acKey' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 360 end object dsCreated: TDataSource DataSet = tbCreated Left = 1215 Top = 360 end object tbMoved: TdlDataset SQL.Strings = ( 'select F.*, rtrim(F.acWorkPlace)+'#39'-'#39'+rtrim(F.acFiscalDevice)+'#39'-'#39 + '+rtrim(cast( anFiscalNumber as char(10))) as acFiscalNumber, G.a' + 'dDateTimePrint, G.anForPay from tHE_MoveFiscalisation F' 'LEFT JOIN the_move G on F.ackey = G.ackey' 'LEFT JOIN _linksFisc L on L.acKeyOrig= G.ackey' 'WHERE G.acKey is null' '') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 180 end object dsMoved: TDataSource DataSet = tbMoved Left = 1215 Top = 180 end object tbChangesLog: TdlDataset SQL.Strings = ( 'Select distinct CIL.anUserId, CIL.adTimeIns, CIL.anChgNumSession' 'from _ChangedInvoicesLog CIL' 'inner join _LinksFisc LF on LF.anChgNumSession = CIL.anChgNumSes' + 'sion ') FieldNamesToUpperCase = False Active = True UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = 'anChgNumSession' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 390 end object dsChangesLog: TDataSource DataSet = tbChangesLog Left = 1215 Top = 390 end object tbChangesLogAnalytical: TdlDataset SQL.Strings = ( 'select A.* from _ChangedInvoicesLogAnalytical A' 'inner join _linksFisc L on L.anChgNumSession = A.anChgNumSession' + ' and L.acKey = A.acKey' 'where A.anChgNumSession = :anChgNumSession' 'order by A.acKey, A.acType desc, A.ChgNum' '') FieldNamesToUpperCase = False MasterSource = dsChangesLog MasterFields = 'anChgNumSession' UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = 'acKey;acType;ChgNum;anChgNumSession' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 420 ParamData = < item DataType = ftInteger Name = 'anChgNumSession' ParamType = ptInput Value = 4 end> end object dsChangesLogAnalytical: TDataSource DataSet = tbChangesLogAnalytical Left = 1215 Top = 420 end object tbChangesHeadsCreated: TdlDataset SQL.Strings = ( 'Select A.* from _LinksFisc A' 'inner join _ChangedInvoicesLog CIL on A.anChgNumSession = CIL.an' + 'ChgNumSession' 'where A.anChgNumSession = :anChgNumSession' '' '' '' '') FieldNamesToUpperCase = False MasterSource = dsChangesLog MasterFields = 'anChgNumSession' UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 240 ParamData = < item DataType = ftUnknown Name = 'anChgNumSession' Value = nil end> end object dsChangesHeadsCre: TDataSource DataSet = tbChangesHeadsCreated Left = 1215 Top = 240 end object dsFursXml: TDataSource DataSet = tbFursXml Left = 1215 Top = 30 end object tbFursXml: TdlDataset SQL.Strings = ( 'select FXD.adDateTimePrint, FXD.anValue, FXD.acZIK, FXD.acJIR, ' ' RTRIM(FXD.acWorkPlace) + P.acFiscalMark1 + CAST(FXD.acFiscalDev' + 'ice as varchar(50) ) + P.acFiscalMark2 + CAST(FXD.anFiscalNumber' + ' as varchar(10)) as acFiscalKey' 'from #lHE_FURSFiscData FXD, vPA_SysParam P ' 'order by FXD.adDateTimePrint') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 32 end object dsHeadsMM: TDataSource DataSet = tbHeadsMM Left = 1215 Top = 270 end object tbHeadsMM: TdlDataset SQL.Strings = ( 'select A.*, FFD.anValue from #lHE_ChangedInvoicesAnalytical A' 'left join _linksFisc L on A.ackey = L.acKeyOrig' 'left join #lHE_FURSFiscData FFD on FFD.adDateTimePrint = dateadd' + '(millisecond, -datepart(millisecond, A.addateTimePrint), A.addat' + 'eTimePrint) ' 'LEFT JOIN (select distinct acKey from tHE_MoveFiscalisationFix w' + 'here adFiscalDate IS NOT NULL and acType = '#39'0'#39') as tf ON tf.acKe' + 'y = L.acKeyOrig' 'where A.acChgType = '#39'Q'#39 'and (L.acKeyOrig is null OR tf.acKey is null)' 'order by A.acKey, A.acType desc, A.ChgNum') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1181 Top = 271 end object tbItemsMM: TdlDataset SQL.Strings = ( 'Select CAI.* from #lHE_ChangedInvoicesAnalyticalItems CAI' 'where CAI.acKey = :acKey' 'and CAI.ChgNum = :ChgNum ' 'and CAI.acType = :acType' 'order by anNo') FieldNamesToUpperCase = False MasterSource = dsHeadsMM MasterFields = 'acKey;acType;ChgNum' UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 300 ParamData = < item DataType = ftFixedChar Name = 'acKey' ParamType = ptInput Size = 13 Value = nil end item DataType = ftLargeint Name = 'ChgNum' ParamType = ptInput Value = nil end item DataType = ftString Name = 'acType' ParamType = ptInput Size = 1 Value = nil end> end object dsItemsMM: TDataSource DataSet = tbItemsMM Left = 1215 Top = 300 end object tbValueMissmatch: TdlDataset SQL.Strings = ( 'select * from ' '(' 'Select FFD.anValue, A.anForPay, RTRIM(FFD.acWorkPlace) + '#39'-'#39' + C' + 'AST(FFD.acFiscalDevice as varchar(50) ) + '#39'-'#39' + CAST(FFD.anFisca' + 'lNumber as varchar(10)) as acFiscalNumberFURS, ' 'A.acFiscalNumberMI as acFiscalNumberPA, A.acKey from' '#lHE_FURSFiscData FFD ' 'JOIN (select A.ackey, RTRIM(MF.acWorkPlace) + '#39'-'#39' + CAST(MF.acFi' + 'scalDevice as varchar(50) ) + '#39'-'#39' + CAST(MF.anFiscalNumber as va' + 'rchar(10)) as acFiscalNumberMI, ' 'case when B.acVatCalcReceiver = '#39'T'#39' then sum(anPVOCVatBase) els' + 'e sum(anPVOCFOrPay) end as anForPay from the_moveitem A' 'join the_settax B on A.acVatCode = B.acVATCode' 'join the_movefiscalisation MF on A.ackey = MF.ackey' 'join #lHE_ValidDocTypes VD on VD.acDocType = substring(MF.ackey,' + ' 3, 4)' ' group by A.ackey, RTRIM(MF.acWorkPlace) + '#39'-'#39' + CAST(MF.acFisca' + 'lDevice as varchar(50) ) + '#39'-'#39' + CAST(MF.anFiscalNumber as varch' + 'ar(10)), acVATCalcReceiver) A ' ' ON A.acFiscalNumberMI = RTRIM(FFD.acWorkPlace) + '#39'-'#39' + CAST(FFD' + '.acFiscalDevice as varchar(50) ) + '#39'-'#39' + CAST(FFD.anFiscalNumber' + ' as varchar(10))' 'where (dbo.fpa_roundfin(FFD.anValue,0.01) <> dbo.fpa_roundfin(A.' + 'anForPay ,0.01)) or ' 'A.acFiscalNumberMI <> (RTRIM(FFD.acWorkPlace) + '#39'-'#39' + CAST(FFD.a' + 'cFiscalDevice as varchar(50) ) + '#39'-'#39' + CAST(FFD.anFiscalNumber a' + 's varchar(10)))' 'UNION ALL' 'Select FFD.anValue, X.anForPay, RTRIM(FFD.acWorkPlace) + '#39'-'#39' + C' + 'AST(FFD.acFiscalDevice as varchar(50) ) + '#39'-'#39' + CAST(FFD.anFisca' + 'lNumber as varchar(10)) as acFiscalNumberFURS, ' 'RTRIM(X.acWorkPlace) + '#39'-'#39' + CAST(X.acFiscalDevice as varchar(50' + ') ) + '#39'-'#39' + CAST(X.anFiscalNumber as varchar(10)) as acFiscalNum' + 'berPA,' 'X.acKey from' '#lHE_FURSFiscData FFD ' 'OUTER APPLY ' '(' ' Select CIA.acKey, CIA.anForPay, MF.acWorkPlace, MF.anFiscalNumb' + 'er, MF.acFiscalDevice from #lHE_ChangedInvoicesAnalytical CIA le' + 'ft join tHE_MoveFiscalisation MF on MF.acKey = CIA.acKey where d' + 'ateadd(millisecond, -datepart(millisecond, CIA.addateTimePrint),' + ' CIA.adDateTimePrint) = FFD.adDateTimePrint and IsNull(MF.acWork' + 'Place, FFD.acWorkPlace) = FFD.acWorkPlace and IsNull(MF.acFiscal' + 'Device, FFD.acFiscalDevice) = FFD.acFiscalDevice' ' UNION ' ' Select acKey, anForPay, acWorkPlace, anFiscalNumber, acFiscalDe' + 'vice from #lHE_PAFiscData PD where PD.adDateTimePrint = FFD.adDa' + 'teTimePrint and IsNull(PD.acWorkPlace, FFD.acWorkPlace) = FFD.ac' + 'WorkPlace and IsNull(PD.acFiscalDevice, FFD.acFiscalDevice) = FF' + 'D.acFiscalDevice' ') X' 'JOIN (select count(FFD.anFiscalNumber) as acCount, RTRIM(FFD.a' + 'cWorkPlace) + '#39'-'#39' + CAST(FFD.acFiscalDevice as varchar(50) ) + '#39 + '-'#39' + CAST(FFD.anFiscalNumber as varchar(10)) as acFiscalNumberFU' + 'RS' 'from #lhe_FURSFIscData FFD' 'OUTER APPLY ' '(' ' Select CIA.acKey, CIA.anForPay, MF.acWorkPlace, MF.anFiscalNumb' + 'er, MF.acFiscalDevice from #lHE_ChangedInvoicesAnalytical CIA le' + 'ft join tHE_MoveFiscalisation MF on MF.acKey = CIA.acKey where d' + 'ateadd(millisecond, -datepart(millisecond, CIA.addateTimePrint),' + ' CIA.adDateTimePrint) = FFD.adDateTimePrint and IsNull(MF.acWork' + 'Place, FFD.acWorkPlace) = FFD.acWorkPlace and IsNull(MF.acFiscal' + 'Device, FFD.acFiscalDevice) = FFD.acFiscalDevice' ' UNION ' ' Select acKey, anForPay, acWorkPlace, anFiscalNumber, acFiscalDe' + 'vice from #lHE_PAFiscData PD where PD.adDateTimePrint = FFD.adDa' + 'teTimePrint and IsNull(PD.acWorkPlace, FFD.acWorkPlace) = FFD.ac' + 'WorkPlace and IsNull(PD.acFiscalDevice, FFD.acFiscalDevice) = FF' + 'D.acFiscalDevice' ') X' 'join #lHE_ValidDocTypes VD on VD.acDocType = substring(X.ackey, ' + '3, 4)' 'group by RTRIM(FFD.acWorkPlace) + '#39'-'#39' + CAST(FFD.acFiscalDevice ' + 'as varchar(50) ) + '#39'-'#39' + CAST(FFD.anFiscalNumber as varchar(10))' 'having count(FFD.anFiscalNumber) > 1 ' ') A ON RTRIM(FFD.acWorkPlace) + '#39'-'#39' + CAST(FFD.acFiscalDevice as' + ' varchar(50) ) + '#39'-'#39' + CAST(FFD.anFiscalNumber as varchar(10)) =' + ' A.acFiscalNumberFURS' ')B' 'group by anValue, anForPay, acFiscalNumberFURS, acFiscalNumberPA' + ', ackey' 'having (dbo.fpa_roundFin(anValue, 0.01) <> dbo.fpa_roundFin(anFo' + 'rPay, 0.01)) or (acFiscalNumberFURS <> acFiscalNumberPA)' 'ORDER by acFiscalNumberFURS') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 0 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 210 end object dsValueMissmatch: TDataSource DataSet = tbValueMissmatch Left = 1215 Top = 210 end object tbKey: TdlDataset SQL.Strings = ( 'select distinct G.acKey, ' 'case when F.anFiscalNumber is null then 0 else F.anFiscalNumber ' + 'end as anFiscalNUmber' 'from the_move G' 'join tPA_SetDocType D on G.acDocType = D.acDocType' 'left join tHE_MoveFiscalisation F on G.ackey = F.ackey' 'where D.acSetOf = '#39'F'#39' and D.acType in ('#39'I'#39', '#39'M'#39') ' 'and G.adDate > '#39'2016-01-01'#39 'order by ackey') FieldNamesToUpperCase = False Active = True UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 0 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 15 Top = 130 end object dsKey: TDataSource DataSet = tbKey Left = 45 Top = 130 end object tbSearchResults: TdlDataset SQL.Strings = ( 'select * from #lHE_SearchResults' 'order by ackey') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 0 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1180 Top = 450 end object dsSearchResults: TDataSource DataSet = tbSearchResults Left = 1215 Top = 450 end object tbKeyCreated: TdlDataset SQL.Strings = ( 'select distinct G.acKey from the_move G' 'join tPA_SetDocType D on G.acDocType = D.acDocType' 'where D.acSetOf = '#39'F'#39' and D.acType in ('#39'I'#39', '#39'M'#39') ' 'and G.adDate > '#39'2016-01-01'#39 'order by ackey') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 0 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 15 Top = 160 end object dsKeyCreated: TDataSource DataSet = tbKeyCreated Left = 45 Top = 160 end object tbFxRate: TdlDataset SQL.Strings = ( 'SELECT' #9'm.acKey, ' #9'isnull(FFD.anFiscalNumber, mf.anFiscalNumber) as anFiscalNo,' #9'isnull(FFD.adDateTimePrint, mf.adFiscalDate) as adFiscalDate,' #9'm.anForPay,' #9'm.anFXRate,' #9'm.anCurrValue,' #9'FFD.anValue as anFiscValue,' #9'fx.acDescription,' #9'case when FFD.anFiscalNumber is not null then' #9#9'LTRIM(RTRIM(mf.acWorkPlace)) + '#39'-'#39' + LTRIM(RTRIM(mf.acFiscalDe' + 'vice)) + '#39'-'#39' + cast(FFD.anFiscalNumber as varchar(100))' #9'else' #9#9'LTRIM(RTRIM(mf.acWorkPlace)) + '#39'-'#39' + LTRIM(RTRIM(mf.acFiscalDe' + 'vice)) + '#39'-'#39' + cast(mf.anFiscalNumber as varchar(100))' ' end as acFiscalNo,' ' fx.anSelected,' ' m.adDateTimePrint' 'FROM' ' #lHE_FxRateMissmatch as fx' ' INNER JOIN tHE_Move as m ON m.acKey = fx.acKey' ' LEFT JOIN tHE_MoveFiscalisation as mf ON mf.acKey = m.acKey ' + 'AND mf.adFiscalDate IS NOT NULL' ' LEFT JOIN #lHE_FURSFiscData FFD on FFD.adDateTimePrint = dat' + 'eadd(millisecond, -datepart(millisecond, m.addateTimePrint), m.a' + 'ddateTimePrint) ' ' LEFT JOIN (' ' select distinct acKey from tHE_MoveFiscalisationFix wher' + 'e adFiscalDate IS NOT NULL and acType = '#39'0'#39 ' ) as tf ON tf.acKey = m.acKey' 'WHERE' ' (FFD.anFiscalNumber IS NOT NULL OR mf.anFiscalNumber IS NOT ' + 'NULL OR m.adDateTimePrint IS NOT NULL)' ' AND (isnull(FFD.adDateTimePrint, mf.adFiscalDate) < fx.anVer' + 'sion OR fx.anVersion IS NULL)' ' AND tf.acKey is null' 'ORDER BY' ' m.acKey' '') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 10 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1100 Top = 35 end object dsFxRate: TDataSource DataSet = tbFxRate Left = 1132 Top = 35 end object dsDuplicated: TDataSource DataSet = tbDuplicated Left = 1134 Top = 68 end object tbDuplicated: TdlDataset SQL.Strings = ( 'Select * from #lHE_DuplicatedInvoices') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 0 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 1099 Top = 67 end object tbDocTypeU: TdlDataset SQL.Strings = ( 'select acDocType, acName ' 'from vPA_SetDocType' 'where actype in ('#39'I'#39', '#39'M'#39') and acsetOf = '#39'F'#39' and acisDoc = '#39'T'#39' ' 'order by acDocType') FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 0 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 13 Top = 192 end object dsDocTypeU: TDataSource DataSet = tbDocTypeU Left = 45 Top = 192 end end unit FForm1; interface uses Forms, Controls, StdCtrls, SysUtils, Classes, Graphics, dlComponents, Dialogs, cxGrid, dlDatabase, db, Variants, dlGLCommon; type TForm1 = class(TarForm) PageControl: TdlcxPageControl; tabDeleted: TdlcxTabSheet; tabUpdated: TdlcxTabSheet; tbHeadsUpd: TdlDataset; dsHeadsUpd: TDataSource; tbItemsUpd: TdlDataset; dsItemsUpd: TDataSource; pChanged: TdlcxPanel; dsHeadsDel: TDataSource; tbHeadsDel: TdlDataset; tbItemsDel: TdlDataset; dsItemsDel: TDataSource; pDeleted: TdlcxPanel; grdHeadsDel: TcxGrid; grdHeadsDelDBTableView1: TcxGridDBTableView; grdHeadsDelLevel1: TcxGridLevel; grdHeadsDelDBTableView1_adDateTimePrint: TcxGridDBColumn; grdHeadsDelDBTableView1_acKey: TcxGridDBColumn; grdHeadsDelDBTableView1_acZIK: TcxGridDBColumn; grdHeadsDelDBTableView1_acJIR: TcxGridDBColumn; grdHeadsDelDBTableView1_adDateFiscalised: TcxGridDBColumn; grdItemsDel: TcxGrid; grdItemsDelDBTableView1: TcxGridDBTableView; grdItemsDelLevel1: TcxGridLevel; grdItemsDelDBTableView1_ChgNum: TcxGridDBColumn; grdItemsDelDBTableView1_anNo: TcxGridDBColumn; grdItemsDelDBTableView1_acIdent: TcxGridDBColumn; grdItemsDelDBTableView1_acName: TcxGridDBColumn; grdItemsDelDBTableView1_anPrice: TcxGridDBColumn; grdItemsDelDBTableView1_anPVOCForPay: TcxGridDBColumn; grdHeadsDelDBTableView1_anForPay: TcxGridDBColumn; grdHeadsUpd: TcxGrid; grdHeadsUpdDBTableView1: TcxGridDBTableView; grdHeadsUpdLevel1: TcxGridLevel; cxGridDBColumn1: TcxGridDBColumn; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; grdItemsUpd: TcxGrid; grdItemsUpdDBTableView1: TcxGridDBTableView; grdItemsUpdLevel1: TcxGridLevel; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridDBColumn10: TcxGridDBColumn; cxGridDBColumn11: TcxGridDBColumn; cxGridDBColumn12: TcxGridDBColumn; cxGridDBColumn13: TcxGridDBColumn; grdHeadsDelDBTableView1_acATIKey: TcxGridDBColumn; grdHeadsDelDBTableView1_acLMATKey: TcxGridDBColumn; grdHeadsDelDBTableView1_acLMATIKey: TcxGridDBColumn; grdHeadsDelDBTableView1_acLMCRKey: TcxGridDBColumn; cxGridDBColumn0: TcxGridDBColumn; grdItemsDelDBTableView1_anQty: TcxGridDBColumn; cxGridDBColumn14: TcxGridDBColumn; grdHeadsUpdDBTableView1Column1: TcxGridDBColumn; grdHeadsUpdDBTableView1Column2: TcxGridDBColumn; grdHeadsUpdDBTableView1Column3: TcxGridDBColumn; grdHeadsUpdDBTableView1Column4: TcxGridDBColumn; grdHeadsUpdDBTableView1Column5: TcxGridDBColumn; pFilterU: TdlcxPanel; btnCreateU: TdlcxButton; pFilterD: TdlcxPanel; btnCreateD: TdlcxButton; grdHeadsDelDBTableView1Column1: TcxGridDBColumn; grdHeadsUpdDBTableView1Column6: TcxGridDBColumn; tabCreated: TdlcxTabSheet; tabError: TdlcxTabSheet; tbError: TdlDataset; dsError: TDataSource; pError: TdlcxPanel; grdError: TcxGrid; grdErrorDBTableView1: TcxGridDBTableView; grdErrorLevel1: TcxGridLevel; grdErrorDBTableView1Column1: TcxGridDBColumn; grdErrorDBTableView1Column2: TcxGridDBColumn; pCreated: TdlcxPanel; grdCreated: TcxGrid; grdCreatedDBTableView1: TcxGridDBTableView; grdCreatedLevel1: TcxGridLevel; grdCreatedDBTableView1Column1: TcxGridDBColumn; grdCreatedDBTableView1_acKey: TcxGridDBColumn; tbCreated: TdlDataset; dsCreated: TDataSource; tabMoved: TdlcxTabSheet; pMoved: TdlcxPanel; grdMoved: TcxGrid; grdMovedDBTableView1: TcxGridDBTableView; grdMovedLevel1: TcxGridLevel; tbMoved: TdlDataset; dsMoved: TDataSource; grdMovedDBTableView1Column1: TcxGridDBColumn; grdMovedDBTableView1Column2: TcxGridDBColumn; grdMovedDBTableView1Column3: TcxGridDBColumn; grdMovedDBTableView1Column4: TcxGridDBColumn; grdMovedDBTableView1Column5: TcxGridDBColumn; grdHeadsUpdDBTableView1Column7: TcxGridDBColumn; grdCreatedDBTableView1Column3: TcxGridDBColumn; pHeadsU: TdlcxPanel; pItemsU: TdlcxPanel; cxSplitter1: TcxSplitter; pHeadsD: TdlcxPanel; pItemsD: TdlcxPanel; cxSplitter2: TcxSplitter; btnFillZoi: TdlcxButton; btnDeletedZoiDetails: TdlcxButton; btnChangedZoiDetails: TdlcxButton; pModevFilter: TdlcxPanel; btnMovedZoiDetails: TdlcxButton; tabLog: TdlcxTabSheet; pLog: TdlcxPanel; dlcxPanel1: TdlcxPanel; dlcxPanel2: TdlcxPanel; cxSplitter3: TcxSplitter; dlcxPanel3: TdlcxPanel; dlcxPanel4: TdlcxPanel; cxSplitter4: TcxSplitter; dlcxPanel5: TdlcxPanel; dlcxPanel6: TdlcxPanel; grdChanges: TcxGrid; grdChangesDBTableView1: TcxGridDBTableView; grdChangesLevel1: TcxGridLevel; grdChangesAnalitycal: TcxGrid; grdChangesAnalitycalDBTableView1: TcxGridDBTableView; grdChangesAnalitycalLevel1: TcxGridLevel; grdChangesHeadsCreated: TcxGrid; grdChangesHeadsCreatedDBTableView1: TcxGridDBTableView; grdChangesHeadsCreatedLevel1: TcxGridLevel; grdChangesDBTableView1Column1: TcxGridDBColumn; grdChangesDBTableView1Column2: TcxGridDBColumn; tbChangesLog: TdlDataset; dsChangesLog: TDataSource; tbChangesLogAnalytical: TdlDataset; dsChangesLogAnalytical: TDataSource; grdChangesAnalitycalDBTableView1Column1: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column2: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column3: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column4: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column5: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column6: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column7: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column8: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column9: TcxGridDBColumn; grdChangesAnalitycalDBTableView1Column10: TcxGridDBColumn; tbChangesHeadsCreated: TdlDataset; dsChangesHeadsCre: TDataSource; grdChangesHeadsCreatedDBTableView1Column1: TcxGridDBColumn; grdChangesHeadsCreatedDBTableView1Column2: TcxGridDBColumn; tabFursXml: TdlcxTabSheet; dsFursXml: TDataSource; tbFursXml: TdlDataset; pFursXmlFilters: TdlcxPanel; cxGrid1: TcxGrid; cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1DBTableView1Column1: TcxGridDBColumn; cxGrid1DBTableView1Column2: TcxGridDBColumn; cxGrid1DBTableView1Column3: TcxGridDBColumn; cxGrid1DBTableView1Column4: TcxGridDBColumn; cxGrid1DBTableView1Column5: TcxGridDBColumn; btnFursXml: TdlcxButton; grdCreatedDBTableView1Column2: TcxGridDBColumn; lSessionID: TdlcxLabeledTextEdit; btnRefresh: TdlcxButton; grdHeadsUpdDBTableView1Column8: TcxGridDBColumn; grdHeadsDelDBTableView1Column2: TcxGridDBColumn; grdItemsUpdDBTableView1Column1: TcxGridDBColumn; grdItemsDelDBTableView1Column1: TcxGridDBColumn; btnCreateOthers: TdlcxButton; tabMissmatch: TdlcxTabSheet; pMissMatch: TdlcxPanel; grdHeadsMM: TcxGrid; grdHeadsMMDBTableView1: TcxGridDBTableView; grdHeadsMMLevel1: TcxGridLevel; grdItemsMM: TcxGrid; grdItemsMMDBTableView1: TcxGridDBTableView; grdItemsMMLevel1: TcxGridLevel; pHeadsMM: TdlcxPanel; pItemsMM: TdlcxPanel; cxSplitter5: TcxSplitter; dsHeadsMM: TDataSource; tbHeadsMM: TdlDataset; tbItemsMM: TdlDataset; dsItemsMM: TDataSource; grdHeadsMMDBTableView1Column1: TcxGridDBColumn; grdHeadsMMDBTableView1Column2: TcxGridDBColumn; grdHeadsMMDBTableView1Column3: TcxGridDBColumn; grdHeadsMMDBTableView1Column4: TcxGridDBColumn; grdHeadsMMDBTableView1Column5: TcxGridDBColumn; grdHeadsMMDBTableView1Column6: TcxGridDBColumn; grdHeadsMMDBTableView1Column7: TcxGridDBColumn; grdHeadsMMDBTableView1Column8: TcxGridDBColumn; grdHeadsMMDBTableView1Column9: TcxGridDBColumn; grdHeadsMMDBTableView1Column10: TcxGridDBColumn; grdHeadsMMDBTableView1Column12: TcxGridDBColumn; grdHeadsMMDBTableView1Column13: TcxGridDBColumn; grdHeadsMMDBTableView1Column14: TcxGridDBColumn; grdHeadsMMDBTableView1Column15: TcxGridDBColumn; grdHeadsMMDBTableView1Column16: TcxGridDBColumn; grdItemsMMDBTableView1Column1: TcxGridDBColumn; grdItemsMMDBTableView1Column2: TcxGridDBColumn; grdItemsMMDBTableView1Column3: TcxGridDBColumn; grdItemsMMDBTableView1Column4: TcxGridDBColumn; grdItemsMMDBTableView1Column5: TcxGridDBColumn; grdItemsMMDBTableView1Column6: TcxGridDBColumn; grdItemsMMDBTableView1Column7: TcxGridDBColumn; grdItemsMMDBTableView1Column8: TcxGridDBColumn; cbVATExclude: TdlcxCheckBox; cbFiscExclude: TdlcxCheckBox; pFilterMM: TdlcxPanel; btnStornoCreateMM: TdlcxButton; btnRefreshMargin: TdlcxButton; neMargin: TdlcxLabeledNumberEdit; grdHeadsDelDBTableView1Column3: TcxGridDBColumn; grdHeadsUpdDBTableView1Column9: TcxGridDBColumn; grdHeadsMMDBTableView1Column17: TcxGridDBColumn; tabValueMissmatch: TdlcxTabSheet; tbValueMissmatch: TdlDataset; dsValueMissmatch: TDataSource; grdCreatedDBTableView1_acNote: TcxGridDBColumn; grdCreatedDBTableView1_acStatusCreated: TcxGridDBColumn; grdHeadsDelDBTableView1_anFiscalNumber: TcxGridDBColumn; grdHeadsUpdDBTableView1_anFiscalNumber: TcxGridDBColumn; grdHeadsMMDBTableView1_anFiscalNumber: TcxGridDBColumn; grdCreatedDBTableView1_anVATInCurPer: TcxGridDBColumn; tabUtility: TdlcxTabSheet; pUtility: TdlcxPanel; fKey: TdlcxLabeledLookupComboBox; neFiscalNumber: TdlcxLabeledNumberEdit; btnUpdateFiscNo: TdlcxButton; tbKey: TdlDataset; dsKey: TDataSource; pFindDoc: TdlcxPanel; pFilterFind: TdlcxPanel; grdFilterResults: TcxGrid; grdFilterResultsDBTableView1: TcxGridDBTableView; grdFilterResultsLevel1: TcxGridLevel; grdFilterResultsDBTableView1_acKey: TcxGridDBColumn; grdFilterResultsDBTableView1_anValue: TcxGridDBColumn; grdFilterResultsDBTableView1_anVAT: TcxGridDBColumn; grdFilterResultsDBTableView1_anForPay: TcxGridDBColumn; grdFilterResultsDBTableView1_adDate: TcxGridDBColumn; neForPay: TdlcxLabeledNumberEdit; btnFind: TdlcxButton; tbSearchResults: TdlDataset; dsSearchResults: TDataSource; tbKeyCreated: TdlDataset; dsKeyCreated: TDataSource; pFiscNoUpd: TdlcxPanel; pGridResults: TdlcxPanel; grdFilterResultsDBTableView1_acZIK: TcxGridDBColumn; grdFilterResultsDBTableView1_acJIR: TcxGridDBColumn; grdFilterResultsDBTableView1_anFiscalNumber: TcxGridDBColumn; grdFilterResultsDBTableView1_adDateTimePrint: TcxGridDBColumn; lSurrogateIdent: TdlcxLabeledLookupComboBox; cbUse: TdlcxCheckBox; tabFxRate: TdlcxTabSheet; bFxRateRefresh: TdlcxButton; grdFxRate: TcxGrid; grdFxRateView: TcxGridDBTableView; grdFxRateLevel1: TcxGridLevel; tbFxRate: TdlDataset; dsFxRate: TDataSource; grdFxRateViewColumn1: TcxGridDBColumn; grdFxRateViewColumn2: TcxGridDBColumn; grdFxRateViewColumn3: TcxGridDBColumn; grdFxRateViewColumn4: TcxGridDBColumn; grdFxRateViewColumn5: TcxGridDBColumn; grdFxRateViewColumn6: TcxGridDBColumn; grdFxRateViewColumn7: TcxGridDBColumn; grdFxRateViewColumn8: TcxGridDBColumn; grdItemsUpdDBTableView1Column2: TcxGridDBColumn; grdItemsDelDBTableView1Column2: TcxGridDBColumn; grdItemsUpdDBTableView1Column3: TcxGridDBColumn; grdHeadsUpdDBTableView1Column10: TcxGridDBColumn; grdHeadsUpdDBTableView1Column11: TcxGridDBColumn; dlcxPanel7: TdlcxPanel; bReport: TdlcxButton; tabDuplicated: TdlcxTabSheet; pDuplicated: TdlcxPanel; grdDuplicated: TcxGrid; grdDuplicatedDBTableView1: TcxGridDBTableView; grdDuplicatedLevel1: TcxGridLevel; grdDuplicatedDBTableView1Column1: TcxGridDBColumn; grdDuplicatedDBTableView1Column2: TcxGridDBColumn; dsDuplicated: TDataSource; tbDuplicated: TdlDataset; bFxRateFix: TdlcxButton; grdFxRateViewColumn9: TcxGridDBColumn; dlcxPanel8: TdlcxPanel; dlcxPanel9: TdlcxPanel; grdValueMissmatch: TcxGrid; grdValueMissmatchDBTableView1: TcxGridDBTableView; grdValueMissmatchLevel1: TcxGridLevel; grdValueMissmatchDBTableView1Column1: TcxGridDBColumn; grdValueMissmatchDBTableView1Column2: TcxGridDBColumn; grdValueMissmatchDBTableView1Column3: TcxGridDBColumn; grdValueMissmatchDBTableView1Column5: TcxGridDBColumn; grdValueMissmatchDBTableView1Column4: TcxGridDBColumn; bRefresh: TdlcxButton; bRemove: TdlcxButton; lKeyUpd: TdlcxLabel; grdDuplicatedDBTableView1Column3: TcxGridDBColumn; grdDuplicatedDBTableView1Column4: TcxGridDBColumn; grdDuplicatedDBTableView1Column5: TcxGridDBColumn; bDupFix: TdlcxButton; bDupRefresh: TdlcxButton; fDocTypeU: TdlcxLabeledLookupComboBox; tbDocTypeU: TdlDataset; dsDocTypeU: TDataSource; bDupRemove: TdlcxButton; btnDuplicatedShowZoi: TdlcxButton; btnHeadValueShowZoi: TdlcxButton; btnFXRateShowZoi: TdlcxButton; rgDDV: TdlcxRadioGroup; grdHeadsDelDBTableView1_acCurrency: TcxGridDBColumn; grdHeadsUpdDBTableView1Column12: TcxGridDBColumn; grdHeadsMMDBTableView1Column11: TcxGridDBColumn; procedure tbHeadsMMAfterOpen(DataSet: TDataSet); procedure tbHeadsUpdAfterOpen(DataSet: TDataSet); procedure btnFXRateShowZoiClick(Sender: TObject); procedure btnHeadValueShowZoiClick(Sender: TObject); procedure btnDuplicatedShowZoiClick(Sender: TObject); procedure bDupRemoveClick(Sender: TObject); procedure bDupRefreshClick(Sender: TObject); procedure bDupFixClick(Sender: TObject); procedure tbHeadsDelAfterOpen(DataSet: TDataSet); procedure tbHeadsUpdAfterScroll(DataSet: TDataSet); procedure bRemoveClick(Sender: TObject); procedure bRefreshClick(Sender: TObject); procedure cxSplitter5Moved(Sender: TObject); procedure cxSplitter1Moved(Sender: TObject); procedure cxSplitter2Moved(Sender: TObject); procedure grdHeadsMMDBTableView1DblClick(Sender: TObject); procedure bFxRateFixClick(Sender: TObject); procedure bReportClick(Sender: TObject); procedure grdFxRateViewDblClick(Sender: TObject); procedure bFxRateRefreshClick(Sender: TObject); procedure grdFilterResultsDBTableView1DblClick(Sender: TObject); procedure grdCreatedDBTableView1Column1PropertiesDblClick(Sender: TObject); procedure dlcxButton1Click(Sender: TObject); procedure neFiscalNumberPropertiesEditValueChanged(Sender: TObject); procedure fKeyPropertiesEditValueChanged(Sender: TObject); procedure btnUpdateFiscNoClick(Sender: TObject); procedure grdItemsUpdDBTableView1DblClick(Sender: TObject); procedure grdItemsDelDBTableView1DblClick(Sender: TObject); procedure grdItemsMMDBTableView1DblClick(Sender: TObject); procedure btnRefreshMarginClick(Sender: TObject); procedure btnStornoCreateMMClick(Sender: TObject); procedure PageControlChange(Sender: TObject); procedure grdHeadsUpdDBTableView1Column5PropertiesEditValueChanged(Sender: TObject); procedure grdHeadsDelDBTableView1Column1PropertiesEditValueChanged(Sender: TObject); procedure grdHeadsDelDBTableView1_anFiscalNumberValueChanged(Sender: TObject); procedure btnCreateOthersClick(Sender: TObject); procedure grdHeadsUpdDBTableView1DblClick(Sender: TObject); procedure grdHeadsDelDBTableView1DblClick(Sender: TObject); procedure grdValueMissmatchDBTableView1DblClick(Sender: TObject); procedure grdDuplicatedDBTableView1DblClick(Sender: TObject); procedure btnRefreshClick(Sender: TObject); procedure tbCreatedBeforePost(DataSet: TDataSet); procedure btnFursXmlClick(Sender: TObject); procedure btnMovedZoiDetailsClick(Sender: TObject); procedure btnChangedZoiDetailsClick(Sender: TObject); procedure btnDeletedZoiDetailsClick(Sender: TObject); procedure btnFillZoiClick(Sender: TObject); procedure btnCreateUClick(Sender: TObject); procedure btnCreateDClick(Sender: TObject); procedure tbHeadsDelSetText(Sender: TField;const Text: String); procedure tbHeadsDelJIRFiscSetText(Sender: TField;const Text: String); private nSessionID : Integer; public constructor Create(AOwner: TComponent); override; end; var Form1: TForm1; implementation uses LibFiscRecovery, FForm2; constructor TForm1.Create(AOwner: TComponent); begin inherited Create(AOwner); Ares.AssignObjectsToForm('FForm1', Self); tbDuplicated.Active := True; tbItemsDel.Active := True; tbChangesLogAnalytical.Active := True; tbChangesHeadsCreated.Active := True; tbFursXml.Active := True; tbFxRate.Active := True; btnCreateD.OnClick := btnCreateDClick; tbMoved.Active := True; btnCreateU.OnClick := btnCreateUClick; btnFillZoi.OnClick := btnFillZoiClick; btnDeletedZoiDetails.OnClick := btnDeletedZoiDetailsClick; btnChangedZoiDetails.OnClick := btnChangedZoiDetailsClick; btnMovedZoiDetails.OnClick := btnMovedZoiDetailsClick; btnFursXml.OnClick := btnFursXmlClick; nSessionID := defDatabase.GetIntValue('Select IsNUll(max(anChgNumSession),0) from _ChangedInvoicesLog'); lSessionId.Text := IntToStr(nSessionId); tbCreated.BeforePost := tbCreatedBeforePost; btnRefresh.OnClick := btnRefreshClick; PageControl.ActivePageIndex := 0; grdHeadsUpdDBTableView1.OnDblClick := grdHeadsUpdDBTableView1DblClick; grdHeadsDelDBTableView1.OnDblClick := grdHeadsDelDBTableView1DblClick; cbVATExclude.Checked := False; cbFiscExclude.Checked := True; btnCreateOthers.OnClick := btnCreateOthersClick; TcxCheckBoxProperties(grdHeadsDelDBTableView1Column1.Properties).OnEditValueChanged := grdHeadsDelDBTableView1Column1PropertiesEditValueChanged; TdlcxCustomCheckBoxProperties(grdHeadsUpdDBTableView1Column5.Properties).OnEditValueChanged := grdHeadsUpdDBTableView1Column5PropertiesEditValueChanged; PageControl.OnChange := PageControlChange; btnStornoCreateMM.OnClick := btnStornoCreateMMClick; btnRefreshMargin.OnClick := btnRefreshMarginClick; grdItemsMMDBTableView1.OnDblClick := grdItemsMMDBTableView1DblClick; grdItemsDelDBTableView1.OnDblClick := grdItemsDelDBTableView1DblClick; grdItemsUpdDBTableView1.OnDblClick := grdItemsUpdDBTableView1DblClick; grdValueMissmatchDBTableView1.OnDblClick := grdValueMissmatchDBTableView1DblClick; grdDuplicatedDBTableView1.OnDblClick := grdDuplicatedDBTableView1DblClick; btnUpdateFiscNo.OnClick := btnUpdateFiscNoClick; TdlcxLabeledLookupComboBoxProperties(fKey.Properties).OnEditValueChanged := fKeyPropertiesEditValueChanged; neFiscalNumber.Properties.OnEditValueChanged := neFiscalNumberPropertiesEditValueChanged; btnFind.OnClick := dlcxButton1Click; TdlcxLookupComboBoxProperties(grdCreatedDBTableView1Column1.Properties).OnDblClick := grdCreatedDBTableView1Column1PropertiesDblClick; grdFilterResultsDBTableView1.OnDblClick := grdFilterResultsDBTableView1DblClick; bFxRateRefresh.OnClick := bFxRateRefreshClick; grdFxRateView.OnDblClick := grdFxRateViewDblClick; bReport.OnClick := bReportClick; bFxRateFix.OnClick := bFxRateFixClick; grdHeadsMMDBTableView1.OnDblClick := grdHeadsMMDBTableView1DblClick; cxSplitter2.OnMoved := cxSplitter2Moved; cxSplitter1.OnMoved := cxSplitter1Moved; cxSplitter5.OnMoved := cxSplitter5Moved; bRefresh.OnClick := bRefreshClick; bRemove.OnClick := bRemoveClick; tbHeadsUpd.AfterScroll := tbHeadsUpdAfterScroll; tbHeadsDel.AfterOpen := tbHeadsDelAfterOpen; tbHeadsDel.Active := True; tbHeadsDel.Close; tbHeadsDel.Open; grdHeadsUpdDBTableView1Column10.Width := 64; grdHeadsUpdDBTableView1Column11.Width := 64; bDupFix.OnClick := bDupFixClick; bDupRefresh.OnClick := bDupRefreshClick; bDupRemove.OnClick := bDupRemoveClick; grdItemsDelDBTableView1_anPVOCForPay.Summary.FooterKind := skSum; grdItemsDelDBTableView1_anPVOCForPay.Summary.GroupFooterKind := skSum; btnDuplicatedShowZoi.OnClick := btnDuplicatedShowZoiClick; btnHeadValueShowZoi.OnClick := btnHeadValueShowZoiClick; btnFXRateShowZoi.OnClick := btnFXRateShowZoiClick; tbHeadsUpd.AfterOpen := tbHeadsUpdAfterOpen; tbHeadsMM.AfterOpen := tbHeadsMMAfterOpen; end; procedure TForm1.btnCreateDClick(Sender: TObject); begin ares.executeStep(3); tbChangesLog.Close; tbChangesLog.Open; tbChangesLogAnalytical.Close; tbChangesLogAnalytical.Open; if isRecordExists('#lHE_CreationErrors', '') then begin tbError.Close; tbError.Open; PageControl.ActivePage := tabError; end else begin tbCreated.Close; tbCreated.Open; PageControl.ActivePage := tabCreated; tbHeadsDel.Refresh; end; end; procedure TForm1.btnCreateUClick(Sender: TObject); begin // if fDocTypeU.Text <> '' then begin ares.executeStep(4); tbChangesLog.Close; tbChangesLog.Open; tbChangesLogAnalytical.Close; tbChangesLogAnalytical.Open; if isRecordExists('#lHE_CreationErrors', '') then begin tbError.Close; tbError.Open; PageControl.ActivePage := tabError; end else begin tbCreated.Close; tbCreated.Open; PageControl.ActivePage := tabCreated; tbHeadsUpd.Refresh; end; (* end else begin dlMessageDlg('Poslovni dogodek je obvezen podatek.', mtInformation, [mbOK], 0); end; *) end; procedure TForm1.btnFillZoiClick(Sender: TObject); var Index: Integer; Zoi: String; FiscNum: Integer; begin Index := tbHeadsDel.RecNo; tbHeadsDel.DisableControls; try tbHeadsDel.First; while not tbHeadsDel.Eof do begin if tbHeadsDel.FieldByname('acMarked').AsString <> 'T' then begin tbHeadsDel.Next; continue; end; GetFiscData(tbHeadsDel.FieldByName('acKey').AsString, tbHeadsDel.FieldByName('adDateTimePrint').AsDateTime, tbHeadsDel.FieldByName('anForPay').AsFloat, Zoi, FiscNum); if (not tbHeadsDel.FieldByname('anFiscalNOFisc').IsNull) and (tbHeadsDel.FieldByname('anFiscalNOFisc').AsInteger <> 0) then FiscNum := tbHeadsDel.FieldByname('anFiscalNOFisc').AsInteger; DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set acZIK = ''' + Zoi + ''', anFiscalNumber = ' + IntToStr(FiscNum) + ' where acKey = ''' + tbHeadsDel.FieldByName('acKey').AsString + ''' '); tbHeadsDel.Next; end finally tbHeadsDel.Refresh; tbHeadsDel.RecNo := Index; tbHeadsDel.EnableControls; end; end; procedure TForm1.btnDeletedZoiDetailsClick(Sender: TObject); var sKey: String; dDate: TDateTime; fAmount: Double; frm: TfrmFiscalData; begin if (not tbHeadsDel.Active) or (tbHeadsDel.RecordCount = 0) then exit; sKey := tbHeadsDel.FieldByName('acKey').AsString; dDate := tbHeadsDel.FieldByName('adDateTimePrint').AsDateTime; fAmount := tbHeadsDel.FieldByName('anForPay').AsFloat; frm := TfrmFiscalData.Create(self, sKey, dDate, fAmount); frm.ShowModal(); end; procedure TForm1.btnChangedZoiDetailsClick(Sender: TObject); var sKey: String; dDate: TDateTime; fAmount: Double; frm: TfrmFiscalData; selIndex: Integer; begin if (not tbHeadsUpd.Active) or (tbHeadsUpd.RecordCount = 0) then exit; sKey := tbHeadsUpd.FieldByName('acKey').AsString; dDate := tbHeadsUpd.FieldByName('adDateTimePrint').AsDateTime; fAmount := tbHeadsUpd.FieldByName('anForPay').AsFloat; frm := TfrmFiscalData.Create(self, sKey, dDate, fAmount, True); if frm.ShowModal() = mrOk then begin selIndex := tbHeadsUpd.RecNo; DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set acZIK = ''' + frm.ZOI + ''' where acKey = ''' + tbHeadsUpd.FieldByName('acKey').AsString + ''' AND acChgType = ''U'' AND ChgNum = ' + IntToStr(tbHeadsUpd.FieldByName('ChgNum').AsInteger)); DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set acJIR = ''' + frm.EOR + ''' where acKey = ''' + tbHeadsUpd.FieldByName('acKey').AsString + ''' AND acChgType = ''U'' AND ChgNum = ' + IntToStr(tbHeadsUpd.FieldByName('ChgNum').AsInteger)); tbHeadsUpd.Refresh; tbHeadsUpd.RecNo := selIndex; end; end; procedure TForm1.btnMovedZoiDetailsClick(Sender: TObject); var sKey: String; dDate: TDateTime; fAmount: Double; frm: TfrmFiscalData; begin if (not tbMoved.Active) or (tbMoved.RecordCount = 0) then exit; sKey := tbMoved.FieldByName('acKey').AsString; dDate := tbMoved.FieldByName('adDateTimePrint').AsDateTime; fAmount := tbMoved.FieldByName('anForPay').AsFloat; frm := TfrmFiscalData.Create(self, sKey, dDate, fAmount); frm.ShowModal(); end; procedure TForm1.btnFursXmlClick(Sender: TObject); var SL, SLLine: TStringList; DS: TdlDataset; i: integer; OD: TOpenDialog; begin OD := TSaveDialog.Create(nil); try OD.Title := 'Load from CSV file...'; OD.Filter := 'CSV files (*.csv)|*.csv'; OD.DefaultExt := '.csv'; if OD.Execute then begin ares.executestep(7); DS := TdlDataset.Create(nil); try DS.SQL.Text := 'Select * from #lHE_FURSFiscData'; DS.Open; SL := TStringLIst.Create; try SLLine := TStringList.Create; try SL.LoadFromFile(OD.FileName); SLLine.StrictDelimiter := True; SLLine.Delimiter := ';'; for i := 1 to SL.Count - 1 do begin SLLine.DelimitedText := SL[i]; DS.Append; DS.FieldByName('acJIR').AsString := SLLine[1]; DS.FieldByName('acZIK').AsString := SLLine[31]; DS.FieldByName('adDateTimePrint').AsDateTime := strtodatetime(SLLine[5]); //if IsNumberStr(SLLine[16]) then DS.FieldByName('anValue').AsFloat := StrToFloat(StringReplace(SLLine[14], '.', ',', [rfReplaceAll])); DS.FieldByName('acWorkPlace').AsString := SLLine[7]; DS.FieldByName('acFiscalDevice').AsString := SLLine[8]; if not ((SLLine[6]) ='V') then DS.FieldByName('anFiscalNumber').AsInteger := StrToInt(SLLine[9]); //DS.Post; end; finally SLLine.Free; end; finally SL.Free; end; finally DS.Free; end; end; finally OD.Free; if tbFursXml.State in [dsInactive] then tbFursXml.Open else begin tbFursXml.Close; tbFursXml.Open; end end; end; procedure TForm1.tbCreatedBeforePost(DataSet: TDataSet); begin if tbCreated.FieldByName('acStatus').asString = 'Dokument brisanje' then tbCreated.FieldByName('acType').asString := 'MU' else tbCreated.FieldByName('acType').asString := 'M'; tbCreated.FieldByName('anChgNumSession').asInteger := nSessionID; tbCreated.FieldByName('anUserIns').asInteger := GetUserID; tbCreated.FieldByName('anUserChg').asInteger := GetUserID; tbCreated.FieldByName('adTimeIns').asDateTime := now; tbCreated.FieldByName('adTimeChg').asDateTime := now; tbCreated.FieldByName('anForPay').asFloat := defDatabase.GetDoubleValue('Select IsNUll(anForPay,0) from tHE_Move where ackey = ' + QuotedStr(tbCreated.FieldByName('acKey').asString)); end; procedure TForm1.btnRefreshClick(Sender: TObject); begin ares.executeStep(2); if tbHeadsUpd.Active then tbHeadsUpd.Refresh; if tbCreated.Active then tbCreated.Refresh; if tbHeadsDel.Active then tbHeadsDel.Refresh; if tbItemsDel.Active then tbItemsDel.Refresh; if tbItemsUpd.Active then tbItemsUpd.Refresh; if tbChangesLog.Active then tbChangesLog.Refresh; if tbChangesLogAnalytical.Active then tbChangesLogAnalytical.Refresh; if tbChangesLogAnalytical.Active then tbChangesLogAnalytical.Refresh; tbFxRate.Refresh; end; procedure TForm1.grdHeadsUpdDBTableView1DblClick(Sender: TObject); begin if AnsiSameStr(TcxGridDBColumn(grdHeadsUpdDBTableView1.Controller.FocusedColumn).DataBinding.FieldName, 'acKey') then dlFindDocument(tbHeadsUpd.FieldByName('acKey').AsString, '', '', True) else if AnsiSameStr(TcxGridDBColumn(grdHeadsUpdDBTableView1.Controller.FocusedColumn).DataBinding.FieldName, 'acLMCRKey') then dlFindDocument(tbHeadsUpd.FieldByName('acLMCRKey').AsString, '', '', True); end; procedure TForm1.grdHeadsDelDBTableView1DblClick(Sender: TObject); begin if AnsiSameStr(TcxGridDBColumn(grdHeadsDelDBTableView1.Controller.FocusedColumn).DataBinding.FieldName, 'acLMCRKey') then dlFindDocument(tbHeadsDel.FieldByName('acLMCRKey').AsString, '', '', True); end; procedure TForm1.grdValueMissmatchDBTableView1DblClick(Sender: TObject); begin //if AnsiSameStr(TcxGridDBColumn(grdValueMissmatchDBTableView1.Controller.FocusedColumn).DataBinding.FieldName, 'acKey') then dlFindDocument(tbValueMissmatch.FieldByName('acKey').AsString, '', '', True); end; procedure TForm1.grdDuplicatedDBTableView1DblClick(Sender: TObject); begin dlFindDocument(tbDuplicated.FieldByName('acKey').AsString, '', '', True); end; procedure TForm1.btnCreateOthersClick(Sender: TObject); begin //if fDocTypeU.Text <> '' then begin ares.executeStep(9); tbChangesLog.Close; tbChangesLog.Open; tbChangesLogAnalytical.Close; tbChangesLogAnalytical.Open; if isRecordExists('#lHE_CreationErrors', '') then begin tbError.Close; tbError.Open; PageControl.ActivePage := tabError; end else begin tbCreated.Close; tbCreated.Open; PageControl.ActivePage := tabCreated; tbHeadsUpd.Refresh; end; // end // else begin // dlMessageDlg('Poslovni dogodek je obvezen podatek.', mtInformation, [mbOK], 0); // end; end; procedure TForm1.grdHeadsDelDBTableView1Column1PropertiesEditValueChanged(Sender: TObject); var cMarked : String; begin cMarked := tbHeadsDel.FieldByName('acMarked').AsString; DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set acMarked = ''' + cMarked + ''' where acKey = ''' + tbHeadsDel.FieldByName('acKey').AsString + ''' '); end; procedure TForm1.grdHeadsUpdDBTableView1Column5PropertiesEditValueChanged(Sender: TObject); var cMarked: string; begin cMarked := tbHeadsUpd.FieldByName('acMarked').AsString; if cMarked = 'F' then cMarked := 'T' else cMarked := 'F'; DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set acMarked = ''' + cMarked + ''' where acKey = ''' + tbHeadsUpd.FieldByName('acKey').AsString + ''' '); tbHeadsUpd.Refresh; end; procedure TForm1.grdHeadsDelDBTableView1_anFiscalNumberValueChanged(Sender: TObject); var cFiscalNOFisc: string; begin showmessage(tbHeadsDel.FieldByName('anFiscalNumber').AsString); cFiscalNOFisc := tbHeadsDel.FieldByName('anFiscalNumber').AsString; DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set anFiscalNumber = ''' + cFiscalNOFisc + ''' where acKey = ''' + tbHeadsDel.FieldByName('acKey').AsString + ''' '); tbHeadsDel.Refresh; end; procedure TForm1.PageControlChange(Sender: TObject); begin if PageControl.ActivePage = tabCreated then begin tbCreated.Close; tbCreated.Open; end else if PageControl.ActivePage = tabLog then begin tbChangesLogAnalytical.Refresh; tbChangesHeadsCreated.Refresh; end else if PageControl.ActivePage = tabUpdated then begin tbHeadsUpd.Active := True; tbItemsUpd.Active := True; tbHeadsUpd.Refresh; if grdHeadsUpdDBTableView1Column10.Width > 150 then begin grdHeadsUpdDBTableView1Column10.Width := 100; grdHeadsUpdDBTableView1Column11.Width := 100; end; cxGridDBColumn13.Summary.FooterKind := skSum; cxGridDBColumn13.Summary.GroupFooterKind := skSum; end else if PageControl.ActivePage = tabDeleted then begin tbHeadsDel.Active := True; tbItemsDel.Active := True; tbHeadsDel.Refresh; end else if PageControl.ActivePage = tabDuplicated then begin tbDuplicated.Active := True; tbDuplicated.Refresh end else if PageControl.ActivePage = tabValueMissmatch then begin tbValueMissmatch.Active := True; tbValueMissmatch.Refresh; end else if PageControl.ActivePage = tabMissmatch then begin tbHeadsMM.Active := True; tbItemsMM.Active := True; grdItemsMMDBTableView1Column7.Summary.FooterKind := skSum; grdItemsMMDBTableView1Column7.Summary.GroupFooterKind := skSum; end else if PageControl.ActivePage = tabUtility then begin tbKey.Active := True; tbKey.Refresh; end else if PageControl.ActivePage = tabFxRate then begin tbFxRate.Active := True; tbFXRate.Close; tbFxRate.Open; end; end; procedure TForm1.btnStornoCreateMMClick(Sender: TObject); begin ares.executeStep(14); tbChangesLog.Close; tbChangesLog.Open; tbChangesLogAnalytical.Close; tbChangesLogAnalytical.Open; if isRecordExists('#lHE_CreationErrors', '') then begin tbError.Close; tbError.Open; PageControl.ActivePage := tabError; end else begin tbCreated.Close; tbCreated.Open; PageControl.ActivePage := tabCreated; tbHeadsMM.Refresh; end; end; procedure TForm1.btnRefreshMarginClick(Sender: TObject); begin ares.executeStep(11); ares.executeStep(18); tbHeadsMM.Refresh; tbItemsMM.Refresh; end; procedure TForm1.grdItemsMMDBTableView1DblClick(Sender: TObject); begin if AnsiSameStr(TcxGridDBColumn(grdItemsMMDBTableView1.Controller.FocusedColumn).DataBinding.FieldName, 'acIdent') then begin dlOpenSet(tbItemsMM.FieldByName('acIdent').AsString, 'tHE_SetItem', 'acItem'); end; end; procedure TForm1.grdItemsDelDBTableView1DblClick(Sender: TObject); begin if AnsiSameStr(TcxGridDBColumn(grdItemsDelDBTableView1.Controller.FocusedColumn).DataBinding.FieldName, 'acIdent') then begin dlOpenSet(tbItemsDel.FieldByName('acIdent').AsString, 'tHE_SetItem', 'acItem'); end; end; procedure TForm1.grdItemsUpdDBTableView1DblClick(Sender: TObject); begin if AnsiSameStr(TcxGridDBColumn(grdItemsUpdDBTableView1.Controller.FocusedColumn).DataBinding.FieldName, 'acIdent') then begin dlOpenSet(tbItemsUpd.FieldByName('acIdent').AsString, 'tHE_SetItem', 'acItem'); end; end; procedure TForm1.btnUpdateFiscNoClick(Sender: TObject); begin if ((fKey.Text <> '') and (neFiscalNumber.Value > 0)) then begin ares.ExecuteStep(12); dlMessageDlg('Fiskalna tevilka posodobljena.', mtInformation, [mbOK], 0); end else dlMessageDlg('Izberite klju in vnesite fiskalno tevilko!', mtError, [mbOK], 0); end; procedure TForm1.fKeyPropertiesEditValueChanged(Sender: TObject); begin neFiscalNumber.Value := tbKey.FieldByName('anFiscalNumber').asFloat; end; procedure TForm1.neFiscalNumberPropertiesEditValueChanged(Sender: TObject); begin tbKey.Refresh; end; procedure TForm1.dlcxButton1Click(Sender: TObject); begin ares.ExecuteStep(13); tbSearchResults.Close; tbSearchResults.Open; end; procedure TForm1.grdCreatedDBTableView1Column1PropertiesDblClick(Sender: TObject); begin dlFindDocument(tbCreated.FieldByName('acKey').AsString, '', '', True); end; procedure TForm1.grdFilterResultsDBTableView1DblClick(Sender: TObject); begin dlFindDocument(tbSearchResults.FieldByName('acKey').AsString, '', '', True); end; procedure TForm1.bFxRateRefreshClick(Sender: TObject); begin Ares.ExecuteStep(17); tbFxRate.Refresh; end; procedure TForm1.grdFxRateViewDblClick(Sender: TObject); var SearchOptions: TLocateOptions; begin dlFindDocument(tbFxRate.FieldByName('acKey').AsString, '', '', True); end; procedure TForm1.bReportClick(Sender: TObject); begin Ares.ExecuteStep(15); end; procedure TForm1.bFxRateFixClick(Sender: TObject); begin tbFxRate.DisableControls; try tbFxRate.First; while not tbFxRate.Eof do begin if (tbFxRate.FieldByName('anSelected').AsBoolean) and (tbFxRate.FieldByName('acDescription').AsString = '') then DefDatabase.ExecSQL('update #lHE_FxRateMissmatch set anSelected = 1 where acKey = ''' + tbFxRate.FieldByName('acKey').AsString + ''' '); tbFxRate.Next; end; try ares.ExecuteStep(16); if isRecordExists('#lHE_CreationErrors', '') then begin tbError.Close; tbError.Open; PageControl.ActivePage := tabError; end else begin tbCreated.Close; tbCreated.Open; PageControl.ActivePage := tabCreated; tbFxRate.Refresh; end; except on e: Exception do dlMessageDlg(e.Message, mtInformation, [mbOK], 0); end; finally tbFxRate.EnableControls; tbFxRate.Refresh; end; end; procedure TForm1.grdHeadsMMDBTableView1DblClick(Sender: TObject); begin dlFindDocument(tbHeadsMM.FieldByName('acKey').AsString, '', '', True); end; procedure TForm1.cxSplitter2Moved(Sender: TObject); begin grdItemsDelDBTableView1_acName.Width := 70; end; procedure TForm1.cxSplitter1Moved(Sender: TObject); begin cxGridDBColumn11.Width := 70; end; procedure TForm1.cxSplitter5Moved(Sender: TObject); begin grdItemsMMDBTableView1Column4.Width := 70; end; procedure TForm1.bRefreshClick(Sender: TObject); begin ares.executeStep(19); ares.executeStep(2); tbValueMissmatch.Refresh; end; procedure TForm1.bRemoveClick(Sender: TObject); begin ares.executeStep(20); tbHeadsUpd.Refresh; end; procedure TForm1.tbHeadsUpdAfterScroll(DataSet: TDataSet); begin lKeyUpd.Caption := tbHeadsUpd.FieldByName('acKey').AsString; end; procedure TForm1.tbHeadsDelAfterOpen(DataSet: TDataSet); begin FormatDecCena(DataSet, ['anForPay']); tbHeadsDel.FieldByName('anFiscalNOFisc').OnSetText := tbHeadsDelSetText; tbHeadsDel.FieldByName('acJIRFisc').OnSetText := tbHeadsDelJIRFiscSetText; end; procedure TForm1.tbHeadsDelJIRFiscSetText( Sender: TField; const Text: String); begin tbHeadsDel.FieldByName('acJIRFisc').AsString := Text; DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set acJIR = ''' + Text + ''' where acKey = ''' + tbHeadsDel.FieldByName('acKey').AsString + ''' '); DefDatabase.ExecSQL('Delete FFD from #lHE_FURSFiscData FFD inner join #lHE_ChangedInvoicesAnalytical A on FFD.adDateTimePrint = dateadd(millisecond, -datepart(millisecond, A.addateTimePrint), A.addateTimePrint) where acKey = ''' + tbHeadsDel.FieldByName('acKey').AsString + ''' '); end; procedure TForm1.tbHeadsDelSetText( Sender: TField; const Text: String); begin tbHeadsDel.FieldByName('anFiscalNOFisc').AsString := Text; DefDatabase.ExecSQL('update #lHE_ChangedInvoicesAnalytical set anFiscalNumber = ''' + Text + ''' where acKey = ''' + tbHeadsDel.FieldByName('acKey').AsString + ''' '); end; procedure TForm1.bDupFixClick(Sender: TObject); begin tbDuplicated.DisableControls; try tbDuplicated.First; while not tbDuplicated.Eof do begin if (tbDuplicated.FieldByName('anSelected').AsBoolean) and (tbDuplicated.FieldByName('acDescription').AsString = '') then DefDatabase.ExecSQL('update #lHE_DuplicatedInvoices set anSelected = 1 where acKey = ''' + tbDuplicated.FieldByName('acKey').AsString + ''' '); tbDuplicated.Next; end; try ares.ExecuteStep(21); if isRecordExists('#lHE_CreationErrors', '') then begin tbError.Close; tbError.Open; PageControl.ActivePage := tabError; end else begin tbCreated.Close; tbCreated.Open; PageControl.ActivePage := tabCreated; tbDuplicated.Refresh; end; except on e: Exception do dlMessageDlg(e.Message, mtInformation, [mbOK], 0); end; finally tbDuplicated.EnableControls; tbDuplicated.Refresh; end; end; procedure TForm1.bDupRefreshClick(Sender: TObject); begin Ares.ExecuteStep(22); tbDuplicated.Refresh; end; procedure TForm1.bDupRemoveClick(Sender: TObject); begin tbDuplicated.DisableControls; try tbDuplicated.First; try while not tbDuplicated.Eof do begin if (tbDuplicated.FieldByName('anSelected').AsBoolean) then DefDatabase.ExecSQL('delete from #lHE_DuplicatedInvoices where acKey = ''' + tbDuplicated.FieldByName('acKey').AsString + ''' '); tbDuplicated.Next; end; except on e: Exception do dlMessageDlg(e.Message, mtInformation, [mbOK], 0); end; finally tbDuplicated.EnableControls; tbDuplicated.Refresh; end; end; procedure TForm1.btnDuplicatedShowZoiClick(Sender: TObject); var sKey: String; dDate: TDateTime; fAmount: Double; frm: TfrmFiscalData; begin sKey := tbDuplicated.FieldByName('acKey').AsString; dDate := tbDuplicated.FieldByName('adDateTimePrint').AsDateTime; fAmount := tbDuplicated.FieldByName('anForPay').AsFloat; frm := TfrmFiscalData.Create(self, sKey, dDate, fAmount); frm.ShowModal(); end; procedure TForm1.btnHeadValueShowZoiClick(Sender: TObject); var sKey: String; dDate: TDateTime; fAmount: Double; frm: TfrmFiscalData; begin sKey := tbHeadsMM.FieldByName('acKey').AsString; dDate := tbHeadsMM.FieldByName('adDateTimePrint').AsDateTime; fAmount := tbHeadsMM.FieldByName('anForPay').AsFloat; frm := TfrmFiscalData.Create(self, sKey, dDate, fAmount); frm.ShowModal(); end; procedure TForm1.btnFXRateShowZoiClick(Sender: TObject); var sKey: String; dDate: TDateTime; fAmount: Double; frm: TfrmFiscalData; begin sKey := tbFxRate.FieldByName('acKey').AsString; dDate := tbFxRate.FieldByName('adDateTimePrint').AsDateTime; fAmount := tbFxRate.FieldByName('anForPay').AsFloat; frm := TfrmFiscalData.Create(self, sKey, dDate, fAmount); frm.ShowModal(); end; procedure TForm1.tbHeadsUpdAfterOpen(DataSet: TDataSet); begin FormatDecCena(DataSet, ['anForPay']); end; procedure TForm1.tbHeadsMMAfterOpen(DataSet: TDataSet); begin FormatDecCena(DataSet, ['anForPay']); end; end. 9999999GMFAENFCԱBYffB windows-1250Zbiranje podatkovF/DECLARE @dFiscStartDate DATETIME, @nUserId Integer, @nChgNumSession integer, @nMargin Float set @nUserId = ~U~ set @nMargin = 0.005--cast('#neMargin#' as float) SET @dFiscStartDate = (SELECT adFiscalDate FROM tpa_Sysparam) If not object_id('tempdb..#lHE_ValidDocTypes') is null drop table #lHE_ValidDocTypes If not object_id('tempdb..#lHE_ChangedInvoices') is null drop table #lHE_ChangedInvoices If not object_id('tempdb..#lHE_ChangedInvoicesAnalytical') is null drop table #lHE_ChangedInvoicesAnalytical If not object_id('tempdb..#lHE_ChangedInvoicesAnalyticalitems') is null drop table #lHE_ChangedInvoicesAnalyticalItems If not object_id('tempdb..#lHE_DuplicatedInvoices') is null drop table #lHE_DuplicatedInvoices If object_id('dbo._LinksFisc') is null create table dbo._LinksFisc( acKey varchar(13), acKeyOrig varchar(13), acType varchar(2), anUserIns integer, anUserChg integer, adTimeIns datetime, adTimeChg datetime, acCreatedType varchar(1) default ('M'), anForPay decimal(19,6), anChgNumSession integer, acStatus varchar(100), acCreated varchar(1) default ('A'), --Original (O), All (A) acNote varchar(max) default (''), acStatusCreated varchar(max) default (''), anVatInCurPer money default (0) ) If object_id('dbo._LinksFiscItems') is null create table dbo._LinksFiscItems( acKey varchar(13), acKeyOrig varchar(13), anUserIns integer, anUserChg integer, adTimeIns datetime, adTimeChg datetime, anNoOrig integer, anNo integer, anChgNumSession integer, acIdent varchar(16), anQty decimal(19,6), anForPay decimal(19,6), anRebate decimal(19,6), anPrice decimal(19,6) ) If object_id('dbo._ChangedInvoicesLog') is null create table dbo._ChangedInvoicesLog( anUserId int, adTimeIns datetime, anChgNumSession int ) --creation of doc type filter ----------------------------------------- SELECT dt.acDocType, dt.acType, dt.acSetOf, wp.adStartDate into #lHE_ValidDocTypes FROM tPA_SetDocType as dt LEFT JOIN ( SELECT d.IDDocumentType, COUNT(1) as DocCount FROM Document as d GROUP BY d.IDDocumentType ) as dNp on dNp.IDDocumentType = dt.acDocType JOIN tHE_FiscalWorkPlace wp on dt.acWorkPlace = wp.acWorkPlace WHERE dt.acType in ('M', 'I') AND ISNULL(dt.acFiscalDocs, 'F') = 'T' AND ISNULL(dt.acDocType, '') <> '' AND dt.acNewPOS <> 'T' AND ISNULL(dNp.DocCount, 0) = 0 --finding out ackey of invoicess, without record in tHE_Move SELECT distinct mu.acKey, 'D' as acType into #lHE_ChangedInvoices FROM the_move_undo as mu INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = mu.acDocType LEFT JOIN the_move as m ON mu.ackey = m.ackey LEFT JOIN tPA_SetDocType SDT on MU.acDocType = SDT.acDocType INNER JOIN tHE_SetPayMet SPM on SPM.acPayMethod = MU.acPayMethod LEFT JOIN the_MoveFiscalisation as mf ON mu.ackey = mf.ackey LEFT JOIN _LinksFisc LF on LF.acKeyOrig = mu.acKey and LF.acCreated = 'A' WHERE m.acKey IS NULL AND mf.acKey IS NULL AND mu.adDateInv >= @dFiscStartDate AND mu.adDateInv >= '20160101' and mu.adDateInv >= vd.adStartDate AND mu.adDateTimePrint IS NOT NULL AND mu._dl_TypeCh = 'D' AND LF.acKeyOrig is null AND (IsNull(SPM.acFiscalGroup, 'O') = 'G' OR IsNull(SDT.acFiscalAll, 'F') = 'T' OR SDT.acTypeOfDoc = 'A') INSERT INTO #lHE_ChangedInvoices (acKey, acType) SELECT distinct mu.acKey, 'M' as acType FROM the_move_undo as mu INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = mu.acDocType LEFT JOIN the_move as m ON mu.ackey = m.ackey LEFT JOIN tPA_SetDocType SDT on MU.acDocType = SDT.acDocType INNER JOIN tHE_SetPayMet SPM on SPM.acPayMethod = M.acPayMethod INNER JOIN the_MoveFiscalisation as mf ON mu.ackey = mf.ackey WHERE m.acKey IS NULL AND mu.adDateInv >= @dFiscStartDate AND mu.adDateInv >= '20160101' and mu.adDateInv >= vd.adStartDate AND (IsNull(SPM.acFiscalGroup, 'O') = 'G' OR IsNull(SDT.acFiscalAll, 'F') = 'T' OR IsNull(mf.acJIR, '') <> '') --finding out ackey of invoicess, that have been changed ----------------------------------------- INSERT INTO #lHE_ChangedInvoices (acKey, acType) SELECT distinct acKey, 'U' as acType FROM ( SELECT ROW_NUMBER() OVER(PARTITION BY m.acKey ORDER BY mu._dl_LastCh DESC, MU.adDateTimePrint ASC) AS _RowNum, m.anForPay as anForPay_Current, mu.anForPay as anForPay_Old, ISNULL(mf.adFiscalDate, ISNULL(mf.adTimeChg, m.adDateTimePrint)) as adFiscalDate, mu.ackey,mu._dl_LastCh as _dl_LastChHead, ISNULL(mf.adFiscalDate, ISNULL(mf.adTimeChg, m.adDateTimePrint)) as fiscaldate, M.adDateTimePrint, MU.adDateTimePrint AS addatetimeprintUndo, vd.acType as acVdType, vd.acSetOf as acVdSetOf FROM the_move as m INNER JOIN tHE_SetPayMet SPM on SPM.acPayMethod = M.acPayMethod INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = m.acDocType LEFT JOIN the_MoveFiscalisation as mf ON m.ackey = mf.ackey LEFT JOIN tPA_SetDocType SDT on M.acDocType = SDT.acDocType LEFT JOIN _LinksFisc LF on LF.acKeyOrig = m.acKey and LF.acCreated = 'A' CROSS APPLY (Select TOP 1 * from tHE_Move_Undo where acKey = m.acKey and adDateTimePrint is not null order by _dl_LastCh) mu OUTER APPLY ( Select acKey from ( Select acKey, Round(anForPay, 2) as anForPay from ( Select acKey, anForPay from tHE_Move_Undo where acKey = m.acKey and adDateTimePrint is not null and _dl_TypeCh = 'U' UNION ALL Select acKey, anForPay from tHE_Move where acKey = m.acKey ) A group by acKey, Round(anForPay, 2) ) B group by acKey having count(acKey) > 1 ) MU2 OUTER APPLY ( Select acKey, Round(anForPay, 2) as anForPay from tHE_Move_Undo where acKey = m.acKey and adDateTimePrint is not null and _dl_TypeCh = 'D' ) MU3 WHERE m.adDateTimePrint IS NOT NULL and M.adDateInv >= '20160101' and M.adDateInv >= vd.adStartDate AND LF.acKeyOrig is null AND ((IsNull(MU2.acKey, '') <> '') OR (IsNull(MU3.acKey, '') <> '')) AND (IsNull(SPM.acFiscalGroup, 'O') = 'G' OR IsNull(SDT.acFiscalAll, 'F') = 'T' OR IsNull(mf.acJIR, '') <> '') ) as t WHERE t._RowNum = 1 AND ((ISNULL(t.anForPay_Current, 0) <> ISNULL(t.anForPay_Old, 0) or (t.adDateTimePrint <> t.addatetimeprintUndo))) --AND t.anForPay_Old <> 0 --finding out ackey of invoicess, that gave duplicated fiscal number Select X.acKey, rtrim(B.acWorkPlace) + '-' + rtrim(B.acFiscalDevice) + '-' + cast(B.anFiscalNumber as varchar) as acFiscalNumber, M.adDateTimePrint, M.anForPay, CAST(0 as BIT) as anSelected, case when lf.acKey is not null then CAST('Popravljen duplikat. Naredi tehnini popravek in osvei seznam.' as NVARCHAR(100)) else CAST('' as NVARCHAR(100)) end as acDescription into #lHE_DuplicatedInvoices from (Select acWorkPlace, acFiscalDevice, anFiscalNumber, adYear, sum(rn) as Totalrn from (Select MF.acKey, MF.acWorkPlace, MF.acFiscalDevice, MF.anFiscalNumber, MF.acYearInv as adYear, row_number() OVER(PARTITION BY MF.acWorkPlace, MF.acFiscalDevice, MF.anFiscalNumber, MF.acYearInv ORDER BY MF.acKey) AS [rn] from tHE_MoveFiscalisation MF inner join tHE_Move M on MF.acKey = M.acKey INNER JOIN tHE_SetPayMet SPM on SPM.acPayMethod = M.acPayMethod inner join #lHE_ValidDocTypes as vd ON vd.acDocType = M.acDocType WHERE IsNull(SPM.acFiscalGroup, 'O') <> 'G') A group by acWorkPlace, acFiscalDevice, anFiscalNumber, adYear having adYear >= 2016) B CROSS APPLY (Select acKey from tHE_MoveFiscalisation where acWorkPlace = B.acWorkPlace and acFiscalDevice = B.acFiscalDevice and anFiscalNumber = B.anFiscalNumber and acYearInv = B.adYear) X INNER JOIN the_move M on M.acKey = X.acKey LEFT JOIN _LinksFisc as lf ON lf.acKey = M.acKey and lf.acStatus = 'Duplikat tehnini popravek' and lf.acStatusCreated = 'Potreben tehnini popravek' LEFT JOIN (select distinct ackey from tHE_MoveFiscalisationFix where acType = 1 and adFiscalDate is not null and isnull(acerror, '') = '') as mff on mff.acKey = M.acKey where B.Totalrn > 1 AND mff.acKey IS NULL order by acWorkPlace, acFiscalDevice, anFiscalNumber, acKey --creation of analytical the_Move and tHE_Move_Undo table table for documents, that have been changed ----------------------------------------- Select A.acKey, acType, ChgNum, anForPay, acCurrency, adDateTimePrintUndo as adDateTimePrint, _dl_LastCh, _dl_LastChPrev, adDateTimePrintFiscalized, adFiscalDate, 'U' as acChgType, CASE WHEN adDateTimePrintFiscalized = adDateTimePrintUndo and _RowNum = 1 THEN acZIK ELSE '' END as acZIK, CASE WHEN adDateTimePrintFiscalized = adDateTimePrintUndo and _RowNum = 1 THEN acJIR ELSE '' END as acJIR, IsNull(ATI.acATIKey, '') as acATIKey, IsNull(LMAT.acLMATKey, '') as acLMATKey, IsNull(LMATI.acLMATIKey, '') as acLMATIKey, IsNull(LMCR.acLMCRKey, '') as acLMCRKey, cast('' as char(1)) as acStatus, cast('' as varchar(100)) as acStatusDescr, acIssuer, acReceiver, acDept, adDate, 'F' as acMarked, CASE WHEN adDateTimePrintFiscalized = adDateTimePrintUndo and _RowNum = 1 THEN anFiscalNumber ELSE '' END as anFiscalNumber, '' as _dl_TypeCh, IsNull(DDV.anForPayDDVO,0) as anForPayDDVO, A._dl_UserCh, A.anUserIns, A.adTimeChg into #lHE_ChangedInvoicesAnalytical from ( SELECT m.acKey, MU2.acType, MU2._RowNum, MU2.ChgNum, mu2.anForPay, mu2.acCurrency, ISNULL(mf.adFiscalDate, ISNULL(mf.adTimeChg, m.adDateTimePrint)) as adFiscalDate, M.adDateTimePrint, MU2.adDateTimePrint AS adDateTimePrintUndo, mf.acZIK, mf.acJIR, MU2._dl_LastCh, (Select TOP 1 adDateTimePrint from tHE_Move_Undo where acKey = M.acKey and adDateTimePrint <= (case when exists (select top 1 ackey from the_eslogreport where ackey = M.ackey) then IsNull(dateadd(second, 1, MF.adFiscalDate), '20990101') else IsNull(MF.adFiscalDate, '20990101')end) order by adDateTimePrint desc) as adDateTimePrintFiscalized, (Select TOP 1 _dl_LastCh from tHE_Move_Undo where acKey = M.acKey and _dl_LastCh < MU2._dl_LastCh order by _dl_LastCh desc) as _dl_LastChPrev, m.acIssuer, m.acReceiver, m.acDept, m.adDate, MF.anFiscalNumber, MU2._dl_UserCh, MU2.anUserIns, MU2.adTimeChg FROM the_move as m INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = m.acDocType LEFT JOIN the_MoveFiscalisation as mf ON m.ackey = mf.ackey INNER JOIN #lHE_ChangedInvoices CI on CI.acKEy = M.acKey CROSS APPLY (Select Y.adDateTimePrint, Y.anForPay, Y.acCurrency, Y.acKey, Y._dl_LastCh, ROW_NUMBER() OVER(PARTITION BY Y.acKey, Y.adDateTimePrint ORDER BY Y._dl_LastCh) AS _RowNum, DENSE_RANK() OVER(PARTITION BY Y.acKey ORDER BY Y.adDateTimePrint) as ChgNum, Y.acType, Y._dl_UserCh, Y.anUserIns, Y.adTimeChg from (Select X.adDateTimePrint, Round(X.anForPay, 2) as anForPay, X.acCurrency, X.acKey, X.min_dlLastChg, X.acType, Min(X._dl_LastCh) as _dl_LastCh, X._dl_UserCh, min(X.anUserIns) as anUserIns, min(adTimeChg) as adTimeChg from (Select adDateTimePrint, anForPay, acCurrency, acKey, _dl_LastCh, min_dlLastChg, acType, _dl_UserCh, anUserIns, adTimeChg from (Select IsNull(adDateTimePrint, '19000101') as adDateTimePrint, anForPay, acCurrency, acKey, _dl_LastCh, (Select min(_dl_LastCh) from tHE_Move_Undo MUSub where MUSub.acKey = MU.acKey and IsNull(adDateTimePrint, '') <> '') as min_dlLastChg, ROW_NUMBER() OVER(PARTITION BY MU.acKey, MU.adDateTimePrint, Round(MU.anForPay, 2) ORDER BY MU._dl_LastCh) AS anChgNum, DENSE_RANK() OVER(PARTITION BY MU.acKey, Round(MU.anForPay, 2) ORDER BY MU.adDateTimePrint desc) as anSetChgNum, 'MU' as acType, cast(_dl_UserCh as varchar) as _dl_UserCh, cast(anUserChg as varchar) as anUserIns, adTimeChg from tHE_Move_Undo MU where IsNull(MU.adDateTimePrint, '19000101') <> '19000101' and MU.ackey = m.acKey ) A where A.anChgNum = 1 /*and A._dl_LastCh = (Select min(_dl_LastCh) from tHE_Move_Undo where acKEy = A.acKey and adDateTimePrint = A.adDateTimePrint)*/ and CASE WHEN exists(Select acKey from tHE_Move_Undo where acKEy = A.acKey and IsNull(adDateTimePrint, '') <> '' and _dl_TypeCh = 'D') THEN 1 ELSE A.anSetChgNum END = 1 UNION ALL Select IsNull(adDateTimePrint, '19000101') as adDateTimePrint, anForPay, acCurrency, acKey, '20990101' as _dl_LastCh, (Select min(_dl_LastCh) from tHE_Move_Undo MUSub where MUSub.acKey = MU.acKey and IsNull(adDateTimePrint, '') <> '') as min_dlLastChg, 'M' as acType, '' as _dl_UserCh, cast(anUserChg as varchar) as anUserIns, adTimeChg from tHE_Move MU where MU.ackey = m.acKey ) X group by X.adDateTimePrint, Round(X.anForPay, 2), X.acKey, X.acCurrency, X.min_dlLastChg, X.acType, X._dl_UserCh ) Y where Y._dl_LastCh >= Y.min_dlLastChg ) MU2 WHERE m.adDateTimePrint IS NOT NULL and ((MU2._RowNum = 1 and (Round(MU2.anForpay, 2) <> Round(M.anForPay, 2) or m.adDateTimePrint <> MU2.adDateTimePrint) /*and ChgNum = 1*/) or MU2.acType = 'M') ) A OUTER APPLY (Select TOP 1 acKey from tHE_Move_UNDO where acKey = A.acKey and adDateTimePrint = A.adDateTimePrintUndo and A._RowNum = 1) X OUTER APPLY (select TOP 1 acKey as acATIKey from tHE_AcctTransItem where acLnkKey = A.acKey) ATI OUTER APPLY (select TOP 1 acLnkKey as acLMATKey from tHE_LinkMoveAcctTransItem where acKey = A.acKey and acType = 'F') LMAT OUTER APPLY (select TOP 1 acLnkKey as acLMATIKey from tHE_LinkMoveAcctTransItem where acKey = A.acKey and acType = 'C') LMATI OUTER APPLY (select TOP 1 acLnkKey as acLMCRKey from tHE_LinkMoveCashReg where acKey = A.acKey) LMCR OUTER APPLY (select IsNull(sum(anField11+anField21+anField22+anField1111),0) as anForPayDDVO from the_vatcalclink where acKey = A.ackey)DDV Delete A from #lHE_ChangedInvoicesAnalytical A CROSS APPLY (Select acKey from the_Move_Undo where acKey = A.acKey and _dl_typeCh = 'D' and _dl_LastCh = A._dl_LastCh) A1 OUTER APPLY (Select TOP 1 acKey from the_MoveFiscalisation_UNDO where acKey = A.acKEy and IsNull(acZik, '') <> '') B OUTER APPLY (Select TOP 1 acKey from the_MoveFiscalisation_UNDO where acKey = A.acKey) C where B.acKey is null and C.acKey is not null delete A from #lHE_ChangedInvoicesAnalytical A OUTER APPLY (Select acKey from #lHE_ChangedInvoicesAnalytical where acKEy = A.acKEy and acType = 'MU') B where B.acKEy is null --creation of analytical the_MoveItem and tHE_Moveitem_Undo table table for documents, that have been changed ----------------------------------------- Select MIU.acType, MIU.acSubType, CIA.acKey, CIA.ChgNum, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, IsNull(MIU.anExciseInc,0) as anExciseInc, IsNUll(MIU.anExciseIncP,0) as anExciseIncP, IsNull(MIU.anExciseNotInc,0) as anExciseNotInc, IsNull(MIU.anExciseNotIncP,0) as anExciseNotIncP, MIU.acVatCode, MIU.anVAT, '' as acSerialNo, IsNull(SI.acSerialNoType, '') as acSerialNoType INTO #lHE_ChangedInvoicesAnalyticalItems from #lHE_ChangedInvoicesAnalytical CIA CROSS APPLY (Select acType, acSubType, acFilter, _dl_TypeCh, acKey, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, _RowNum, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVatCode, anVAT, anFilter from (Select acType, acSubType, acFilter, _dl_TypeCh, acKey, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, _RowNum, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVatCode, anVAT,ROW_NUMBER() OVER(PARTITION BY X.acKey, X.anNo ORDER BY X.acFilter) as anFilter from ( Select 'MU' as acType, 'MU' as acSubType, 'F' as acFilter, _dl_TypeCh, MIUSub.acKey, MIUSub.anNo, MIUSub.acIdent, MIUSub.acName, MIUSub.anQty, MIUSub.anPrice, MIUSub.anRebate, MIUSub.anPVOCForPay, ROW_NUMBER() OVER(PARTITION BY MIUSub.acKey, MIUSub.anNo ORDER BY MIUSub._dl_LastCh) as _RowNum, MIUSub.anExciseInc, MIUSub.anExciseIncP, MIUSub.anExciseNotInc, MIUSub.anExciseNotIncP, MIUSub.acVatCode, MIUSub.anVAT from ( Select 'MU' as acType, 'MU' as acSubType, 'F' as acFilter, _dl_TypeCh, MIU.acKey, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, MIU.anExciseInc, MIU.anExciseIncP, MIU.anExciseNotInc, MIU.anExciseNotIncP, MIU.acVatCode, MIU.anVAT, MIU._dl_LastCh, CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MIU.adTimeIns ELSE IsNull(P._dl_LastChPrev, MIU.adTimeChg) END as adTimeChg, IsNull(P._dl_TypeChPrev, '') as _dl_TypeChPrev from tHE_MoveItem_Undo MIU OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIU.acKey and anNo = MIU.anNo and _dl_LastCh < MIU._dl_LastCh order by _dl_LastCh desc) P ) MIUSub where MIUSub.acKey = CIA.acKey and CIA.acType = 'MU' and MIUSub._dl_LastCh >= CIA._dl_LastCh and _dl_TypeCh in ('D') and MIUSub.adTimeChg <= CIA._dl_LastCh UNION ALL Select 'MU' as acType, 'MU' as acSubType, 'F' as acFilter, _dl_TypeCh, MIUSub.acKey, MIUSub.anNo, MIUSub.acIdent, MIUSub.acName, MIUSub.anQty, MIUSub.anPrice, MIUSub.anRebate, MIUSub.anPVOCForPay, ROW_NUMBER() OVER(PARTITION BY MIUSub.acKey, MIUSub.anNo ORDER BY MIUSub._dl_LastCh) as _RowNum, MIUSub.anExciseInc, MIUSub.anExciseIncP, MIUSub.anExciseNotInc, MIUSub.anExciseNotIncP, MIUSub.acVatCode, MIUSub.anVAT from ( Select 'MU' as acType, 'MU' as acSubType, 'F' as acFilter, _dl_TypeCh, MIU.acKey, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, MIU.anExciseInc, MIU.anExciseIncP, MIU.anExciseNotInc, MIU.anExciseNotIncP, MIU.acVatCode, MIU.anVAT, MIU._dl_LastCh, CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MIU.adTimeIns ELSE IsNull(P._dl_LastChPrev, MIU.adTimeChg) END as adTimeChg, IsNull(P._dl_TypeChPrev, '') as _dl_TypeChPrev from tHE_MoveItem_Undo MIU OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIU.acKey and anNo = MIU.anNo and _dl_LastCh < MIU._dl_LastCh order by _dl_LastCh desc) P ) MIUSub where MIUSub.acKey = CIA.acKey and CIA.acType = 'MU' and MIUSub._dl_LastCh >= CIA._dl_LastCh and _dl_TypeCh in ('U') and MIUSub.adTimeChg <= CIA.adTimeChg UNION ALL Select 'MU' as acType, 'MU' as acSubType, 'T' as acFilter, _dl_TypeCh, MIUSub.acKey, MIUSub.anNo, MIUSub.acIdent, MIUSub.acName, MIUSub.anQty, MIUSub.anPrice, MIUSub.anRebate, MIUSub.anPVOCForPay, ROW_NUMBER() OVER(PARTITION BY MIUSub.acKey, MIUSub.anNo ORDER BY MIUSub._dl_LastCh desc) as _RowNum, MIUSub.anExciseInc, MIUSub.anExciseIncP, MIUSub.anExciseNotInc, MIUSub.anExciseNotIncP, MIUSub.acVatCode, MIUSub.anVAT from ( Select 'MU' as acType, 'MU' as acSubType, 'F' as acFilter, _dl_TypeCh, MIU.acKey, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, MIU.anExciseInc, MIU.anExciseIncP, MIU.anExciseNotInc, MIU.anExciseNotIncP, MIU.acVatCode, MIU.anVAT, MIU._dl_LastCh, CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MIU.adTimeIns ELSE IsNull(P._dl_LastChPrev, MIU.adTimeChg) END as adTimeChg, IsNull(P._dl_TypeChPrev, '') as _dl_TypeChPrev from tHE_MoveItem_Undo MIU OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIU.acKey and anNo = MIU.anNo and _dl_LastCh < MIU._dl_LastCh order by _dl_LastCh desc) P ) MIUSub where MIUSub.acKey = CIA.acKey and CIA.acType = 'MU' and MIUSub._dl_LastCh < CIA._dl_LastCh and _dl_TypeCh in ('U', 'D') and MIUSub.adTimeChg <= CIA.adTimeChg and not exists ( Select anNo, acKey, CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MI.adTimeIns ELSE IsNull(P._dl_LastChPrev, MI.adTimeIns) END as adTimeChg, IsNull(P._dl_TypeChPrev, '') as _dl_TypeChPrev from tHE_MoveItem MI OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIUSub.acKey and anNo = MIUSub.anNo order by _dl_LastCh desc) P where CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MI.adTimeIns ELSE IsNull(P._dl_LastChPrev, MI.adTimeIns) END <= CIA.adTimeChg ) ) X ) Y where Y.anFilter = 1 UNION ALL Select 'MU' as acType, 'MU' as acSubType, 'F' as acFilter, _dl_TypeCh, MIUSub2.acKey, MIUSub2.anNo, MIUSub2.acIdent, MIUSub2.acName, MIUSub2.anQty, MIUSub2.anPrice, MIUSub2.anRebate, MIUSub2.anPVOCForPay, ROW_NUMBER() OVER(PARTITION BY MIUSub2.acKey, MIUSub2.anNo ORDER BY MIUSub2._dl_LastCh desc) as _RowNum, MIUSub2.anExciseInc, MIUSub2.anExciseIncP, MIUSub2.anExciseNotInc, MIUSub2.anExciseNotIncP, MIUSub2.acVatCode, MIUSub2.anVAT, 1 from ( Select 'MU' as acType, 'MU' as acSubType, 'F' as acFilter, _dl_TypeCh, MIU.acKey, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, MIU.anExciseInc, MIU.anExciseIncP, MIU.anExciseNotInc, MIU.anExciseNotIncP, MIU.acVatCode, MIU.anVAT, MIU._dl_LastCh, CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MIU.adTimeIns ELSE IsNull(P._dl_LastChPrev, MIU.adTimeChg) END as adTimeChg, IsNull(P._dl_TypeChPrev, '') as _dl_TypeChPrev from tHE_MoveItem_Undo MIU OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIU.acKey and anNo = MIU.anNo and _dl_LastCh < MIU._dl_LastCh order by _dl_LastCh desc) P ) MIUSub2 where MIUSub2.acKey = CIA.acKey and CIA.acType = 'MU' and MIUSub2._dl_LastCh < CIA._dl_LastCh and MIUSub2._dl_LastCh >= CIA._dl_LastChPrev and MIUSub2.adTimeChg <= CIA.adTimeChg and _dl_TypeCh = 'D' UNION ALL Select 'MU' as acType, 'M' as acSubType, 'F' as acFilter, 'U' as _dl_TypeCh, acKey, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, 1 as _RowNum, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVatCode, anVAT, 1 from tHE_MoveItem where acKey = CIA.acKey and CIA.acType = 'MU' ) MIU OUTER APPLY (Select anNo from tHE_MoveItem MISub where acKey = CIA.acKey and MISub.anNo = MIU.anNo and MIU.acSubType = 'M' and exists(Select anNo from tHE_MoveItem_Undo where acKey = CIA.acKey and CIA.acType = 'MU' and _dl_LastCh < CIA._dl_LastCh and adTimeChg > CIA._dl_LastChPrev and anNo = MISub.anNo)) MIDelete --CIA.adDateTimePrintFiscalized (NA BAZI SI_KNJIGCA_MIHAELZOREC pri raun '1630000000051' se pozcije niso ujemalo z glavo) OUTER APPLY ( Select anNo from ( Select anNo, acKey, CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MI.adTimeIns ELSE IsNull(P._dl_LastChPrev, MI.adTimeIns) END as adTimeChg, IsNull(P._dl_TypeChPrev, '') as _dl_TypeChPrev from tHE_MoveItem MI OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIU.acKey and anNo = MIU.anNo order by _dl_LastCh desc) P ) MISub2 where MISub2.acKey = CIA.acKey and MISub2.anNo = MIU.anNo and MIU.acSubType = 'M' and MISub2.adTimeChg > CIA.adTimeChg ) MIDelete2 OUTER APPLY (Select MIU3.anNo from tHE_MoveItem MISub3 inner join the_moveItem_undo MIU3 on MISub3.acKEy = MIU3.acKEy and MISub3.anNo = MIU3.anNo and MISub3.adTimeChg = MIU3.adTimeChg where MISub3.acKey = CIA.acKey and MISub3.anNo = MIU.anNo and MIU.acSubType = 'M') MIDelete3 OUTER APPLY (Select CASE WHEN acSerialNo = 'N' THEN '' ElSE acSerialNo END as acSerialNoType from tHE_SetItem where acIdent = MIU.acIdent) SI where (MIDelete.anNo is null and MIDelete2.anNo is null and MIDelete3.anNo is null) and MIU._RowNum = 1 and ((MIU.acFilter in ('F')) or (MIU.acFilter = 'T' and MIU._dl_TypeCh = 'U')) UNION ALL Select MI.acType, 'M' as acSubType, CIA.acKey, CIA.ChgNum, MI.anNo, MI.acIdent, MI.acName, MI.anQty, MI.anPrice, MI.anRebate, MI.anPVOCForPay, MI.anExciseInc, MI.anExciseIncP, MI.anExciseNotInc, MI.anExciseNotIncP, MI.acVatCode, MI.anVAT, MIS.acSerialNo, SI.acSerialNoType from #lHE_ChangedInvoicesAnalytical CIA CROSS APPLY (Select 'M' as acType, * from tHE_MoveItem where acKey = CIA.acKey and CIA.acType = 'M') MI CROSS APPLY (Select CASE WHEN acSerialNo = 'N' THEN '' ElSE acSerialNo END as acSerialNoType from tHE_SetItem where acIdent = MI.acIdent) SI OUTER APPLY (Select distinct STUFF((Select ',' + MISN.acSerialNo FROM [dbo].[tHE_MoveItemSerialNo] as MISN WHERE MISN.acKEy = MI.acKey and MISN.anNo = MI.anNo FOR xml path('')), 1, 1, '') as acSerialNo ) MIS --creation of analytical the_Move and tHE_Move_Undo table table for documents, without record in tHE_Move ----------------------------------------- insert into #lHE_ChangedInvoicesAnalytical (acKey, acType, ChgNum, anForPay, acCurrency, adDateTimePrint, _dl_LastCh, _dl_LastChPrev, adDateTimePrintFiscalized, adFiscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber,_dl_TypeCh, anForPayDDVO) Select acKey, 'MU' as acType, ROW_NUMBER() OVER(PARTITION BY acKey ORDER BY adDateTimePrint) as ChgNum, anForPay, acCurrency, adDateTimePrint, _dl_LastCh, '' as _dl_LastChPrev, adDateTimePrintFiscalized, adFiscalDate, 'D' as acChgType, '' as acZIK, '9999999' as acJIR , IsNull(ATI.acATIKey, '') as acATIKey, IsNull(LMAT.acLMATKey, '') as acLMATKey, IsNull(LMATI.acLMATIKey, '') as acLMATIKey, IsNull(LMCR.acLMCRKey, '') as acLMCRKey, '', '', acIssuer, acReceiver, acDept, adDate, 'F', 0, _dl_TypeCh, IsNUll(DDV.anForPayDDVO,0) from (Select mu.acKey, 'MU' as acType, 1 as ChgNum, mu.anForPay, mu.acCurrency, mu.adDateTimePrint, mu._dl_LastCh, '' as _dl_LastChPrev, mu.adDateTimePrint as adDateTimePrintFiscalized, mu.adDateTimePrint as adFiscalDate, mu.acIssuer, mu.acReceiver, mu.acDept, mu.adDate, ROW_NUMBER() OVER(PARTITION BY MU.acKey, MU.adDateTimePrint ORDER BY MU._dl_LastCh) AS anChgNum, mu._dl_TypeCh from the_move_undo as mu INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = mu.acDocType LEFT JOIN the_move as m ON mu.ackey = m.ackey LEFT JOIN the_MoveFiscalisation as mf ON mu.ackey = mf.ackey INNER JOIN #lHE_ChangedInvoices CI on CI.acKEy = mu.acKey and CI.acType = 'D' WHERE m.acKey IS NULL AND mu._dl_TypeCh in ('D', 'U') AND mf.acKey IS NULL AND mu.adDateInv >= @dFiscStartDate AND mu.adDateTimePrint IS NOT NULL ) MU OUTER APPLY (select TOP 1 acKey as acATIKey from tHE_AcctTransItem where acLnkKey = MU.acKey) ATI OUTER APPLY (select TOP 1 acLnkKey as acLMATKey from tHE_LinkMoveAcctTransItem where acKey = MU.acKey and acType = 'F') LMAT OUTER APPLY (select TOP 1 acLnkKey as acLMATIKey from tHE_LinkMoveAcctTransItem where acKey = MU.acKey and acType = 'C') LMATI OUTER APPLY (select TOP 1 acLnkKey as acLMCRKey from tHE_LinkMoveCashReg where acKey = MU.acKey) LMCR OUTER APPLY (select sum(anField11+anField21+anField22+anField1111) as anForPayDDVO from the_vatcalclink where acKey = MU.ackey)DDV WHERE MU.anChgNum = 1 ORDER BY mu.acKey, mu._dl_LastCh desc Delete A from #lHE_ChangedInvoicesAnalytical A where A.acChgType = 'D' and A.ChgNum <> (Select max(ChgNum) from #lHE_ChangedInvoicesAnalytical where acKey = A.acKey) --creation of analytical the_MoveItem and tHE_MoveItem_Undo table table for documents, without record in tHE_Move ----------------------------------------- Insert into #lHE_ChangedInvoicesAnalyticalItems (acType, acSubType, acKey, ChgNum, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT, acSerialNoType) Select MIU.acType, MIU.acSubType, CIA.acKey, CIA.ChgNum, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, IsNull(MIU.anExciseInc,0), IsNUll(MIU.anExciseIncP,0), IsNull(MIU.anExciseNotInc,0), IsNull(MIU.anExciseNotIncP,0), MIU.acVATCode, MIU.anVAT, SI.acSerialNoType from #lHE_ChangedInvoicesAnalytical CIA CROSS APPLY ( Select A.acType, A.acSubType, A.anNo, A.acIdent, A.acName, A.anQty, A.anPrice, A.anRebate, A.anPVOCForPay, A._RowNum, A.anExciseInc, A.anExciseIncP, A.anExciseNotInc, A.anExciseNotIncP, A.acVATCode, A.anVAT, ROW_NUMBER() OVER(PARTITION BY A.acKey, A.anNo ORDER BY A.acChgType, A._RowNum) as _RowNumChgType, A.acChgType from ( Select 'MU' as acType, 'MU' as acSubType, 'D' as acChgType, acKey, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh desc) as _RowNum, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT from tHE_MoveItem_Undo MIU OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIU.acKey and anNo = MIU.anNo and _dl_LastCh < MIU._dl_LastCh order by _dl_LastCh desc) P where acKey = CIA.acKey and CIA.acType = 'MU' and CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MIU.adTimeIns ELSE IsNull(P._dl_LastChPrev, MIU.adTimeChg) END < (Select TOP 1 adTimeChg from tHE_Move_Undo where acKey = CIA.acKey and IsNull(adDateTimePrint, '') <> '' and _dl_LastCh = CIA._dl_LastCh order by _dl_LastCh) and _dl_LastCh >= IsNull((Select TOP 1 adTimeChg from tHE_Move_Undo where acKey = CIA.acKey and IsNull(adDateTimePrint, '') <> '' and _dl_LastCh = CIA._dl_LastCh order by _dl_LastCh), '20990101') --and _dl_TypeCh = 'D' /*UNION ALL Select 'MU' as acType, 'MU' as acSubType, 'U' as acChgType, acKey, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh desc) as _RowNum, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT from tHE_MoveItem_Undo MIU OUTER APPLY (Select TOP 1 _dl_LastCh as _dl_LastChPrev, _dl_TypeCh as _dl_TypeChPrev from tHE_MoveItem_Undo where acKey = MIU.acKey and anNo = MIU.anNo and _dl_LastCh < MIU._dl_LastCh order by _dl_LastCh desc) P where acKey = CIA.acKey and CIA.acType = 'MU' and CASE WHEN IsNull(P._dl_TypeChPrev, 'D') = 'D' THEN MIU.adTimeIns ELSE IsNull(P._dl_LastChPrev, MIU.adTimeChg) END <= (Select TOP 1 adTimeChg from tHE_Move_Undo where acKey = CIA.acKey and IsNull(adDateTimePrint, '') <> '' and _dl_LastCh = CIA._dl_LastCh order by _dl_LastCh) and _dl_TypeCh = 'U' */ ) A /* LEFT JOIN ( Select 'MU' as acType, 'MU' as acSubType, 'D' as acChgType, acKey, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh) as _RowNum, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT from tHE_MoveItem_Undo where acKey = CIA.acKey and CIA.acType = 'MU' and _dl_LastCh > CIA._dl_LastCh and _dl_TypeCh = 'U' and adTimeIns < (Select TOP 1 adTimeChg from tHE_Move_Undo where acKey = CIA.acKey and IsNull(adDateTimePrint, '') <> '' and _dl_LastCh = CIA._dl_LastCh order by _dl_LastCh) ) B ON B.acKEy = A.acKey and B.anNo = A.anNo and B._RowNum = A._RowNum and B.acChgType = A.acChgType where B.acKey is null */ ) MIU CROSS APPLY (Select CASE WHEN acSerialNo = 'N' THEN '' ElSE acSerialNo END as acSerialNoType from tHE_SetItem where acIdent = MIU.acIdent) SI where MIU._RowNum = 1 --and MIU._RowNumChgType = 1 and CIA.acChgType = 'D' Update CIA set CIA._dl_LastCh = CASE WHEN IsNull(X._dl_TypeCh, 'D') = 'D' then M.adTimeChg else X._dl_LastCh END, CIA._dl_UserCh = CASE WHEN IsNull(X._dl_TypeCh, 'D') = 'D' then M.anUserChg else X._dl_UserCh END, CIA.anUserIns = CASE WHEN IsNull(X._dl_TypeCh, 'D') = 'D' then M.anUserChg else X.anUserChg END from #lHE_ChangedInvoicesAnalytical CIA inner join tHE_Move M on CIA.acKey = M.acKey OUTER APPLY (Select TOP 1 _dl_LastCh, _dl_TypeCh, _dl_UserCh, anUserChg from tHE_Move_Undo where acKey = CIA.acKey and anForPay <> M.anForPay order by _dl_LastCh desc) X where CIA.acChgType = 'U' and CIA.acType = 'M' --Filling document heads with missmatched heads (zero value or other) insert into #lHE_ChangedInvoicesAnalytical (acKey, acType, ChgNum, anForPay, acCurrency, adDateTimePrint, _dl_LastCh, _dl_LastChPrev, adDateTimePrintFiscalized, adFiscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber,_dl_TypeCh, anForPayDDVO) select ackey, actype, chgnum, anforpay, acCurrency, addatetimeprint, adtimechg, addatetimeprint, adFiscalDate, adFIscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber, _dl_typeCh, IsNull(anForPayDDVO,0) FROM (Select G.acKey, 'M' as acType, 1 as ChgNum, G.anForPay, G.acCurrency, G.adDateTimePrint, G.adTimeChg, F.adFiscalDate, 'Q' as acChgType, F.acZIK, F.acJIR , IsNull(ATI.acATIKey, '') as acATIKey, IsNull(LMAT.acLMATKey, '') as acLMATKey, IsNull(LMATI.acLMATIKey, '') as acLMATIKey, IsNull(LMCR.acLMCRKey, '') as acLMCRKey, '' as acStatus, '' as acStatusDescr, G.acIssuer, G.acReceiver, G.acDept, G.adDate, 'F' as acMarked, F.anFiscalNumber, 'Q' as _dl_typeCh, IsNUll(DDV.anForPayDDVO,0) as anForPayDDVO, sum(P.anPVOCForPay) as anPVOCForPay, sum(P.anPVForPay) as anPVForPay, (1-case when sum(anPVForPay) = 0 then 0 else anForPay/sum(anPVForPay) end) as anPercent, G.anCurrValue, G.anFXRate, G.anRoundValue FROM [dbo].[tHE_Move] as G LEFT JOIN [dbo].[tHE_MoveItem] as P ON P.acKey = G.acKey JOIN [dbo].[tHE_MoveFiscalisation] as F ON F.acKey = G.acKey INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = G.acDocType OUTER APPLY (select TOP 1 acKey as acATIKey from tHE_AcctTransItem where acLnkKey = G.acKey) ATI OUTER APPLY (select TOP 1 acLnkKey as acLMATKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'F') LMAT OUTER APPLY (select TOP 1 acLnkKey as acLMATIKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'C') LMATI OUTER APPLY (select TOP 1 acLnkKey as acLMCRKey from tHE_LinkMoveCashReg where acKey = G.acKey) LMCR OUTER APPLY (select sum(anField11+anField21+anField22+anField1111) as anForPayDDVO from the_vatcalclink where acKey = G.ackey)DDV WHERE G.adDateTimePrint IS NOT NULL AND G.adDate >= '20160101' AND F.acJIR <> '' group by G.acKey,G.anForPay, G.acCurrency, G.adDateTimePrint, G.adTimeChg, G.adDateTimePrint, F.adFiscalDate, F.acZIK, F.acJIR ,G.acIssuer, G.acReceiver, G.acDept, G.adDate, acATIKEy , acLMATKey, acLMATIKey, acLMCRKey, anFiscalNumber, anForpayDDVO, G.anCurrValue, G.anFXRate, G.anRoundValue) A WHERE ((anCurrValue <> anPVOCForPay) OR (anCurrValue <> anForPay and anFXRate = 1)) and abs(anPercent) > @nMargin and ABS(anForPay - anPVForPay) > CASE WHEN A.anRoundValue < 0.01 THEN 0.01 ELSE A.anRoundValue END UNION select ackey, actype, chgnum, anforpay, acCurrency, addatetimeprint, adtimechg, addatetimeprint, adFiscalDate, adFIscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber, _dl_typeCh, IsNull(anForPayDDVO,0) FROM (Select G.acKey, 'M' as acType, 1 as ChgNum, G.anForPay, G.acCurrency, G.adDateTimePrint, G.adTimeChg, F.adFiscalDate, 'Q' as acChgType, F.acZIK, F.acJIR , IsNull(ATI.acATIKey, '') as acATIKey, IsNull(LMAT.acLMATKey, '') as acLMATKey, IsNull(LMATI.acLMATIKey, '') as acLMATIKey, IsNull(LMCR.acLMCRKey, '') as acLMCRKey, '' as acStatus, '' as acStatusDescr, G.acIssuer, G.acReceiver, G.acDept, G.adDate, 'F' as acMarked, F.anFiscalNumber, 'Q' as _dl_typeCh, IsNUll(DDV.anForPayDDVO,0) as anForPayDDVO, sum(P.anPVOCForPay) as anPVOCForPay, G.anCurrValue FROM [dbo].[tHE_Move] as G LEFT JOIN [dbo].[tHE_MoveItem] as P ON P.acKey = G.acKey JOIN [dbo].[tHE_MoveFiscalisation] as F ON F.acKey = G.acKey INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = G.acDocType OUTER APPLY (select TOP 1 acKey as acATIKey from tHE_AcctTransItem where acLnkKey = G.acKey) ATI OUTER APPLY (select TOP 1 acLnkKey as acLMATKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'F') LMAT OUTER APPLY (select TOP 1 acLnkKey as acLMATIKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'C') LMATI OUTER APPLY (select TOP 1 acLnkKey as acLMCRKey from tHE_LinkMoveCashReg where acKey = G.acKey) LMCR OUTER APPLY (select sum(anField11+anField21+anField22+anField1111) as anForPayDDVO from the_vatcalclink where acKey = G.ackey)DDV WHERE G.adDateTimePrint IS NOT NULL AND G.adDate >= '20160101' AND F.acJIR <> '' group by G.acKey,G.anForPay, G.acCurrency, G.adDateTimePrint, G.adTimeChg, G.adDateTimePrint, F.adFiscalDate, F.acZIK, F.acJIR ,G.acIssuer, G.acReceiver, G.acDept, G.adDate, acATIKEy , acLMATKey, acLMATIKey, acLMCRKey, anFiscalNumber, anForpayDDVO, G.anCurrValue ) A WHERE anPVOCForPay is null and anForPay <> 0 Update CIA set CIA._dl_LastCh = CASE WHEN IsNull(X._dl_TypeCh, 'D') = 'D' then M.adTimeChg else X._dl_LastCh END, CIA._dl_UserCh = CASE WHEN IsNull(X._dl_TypeCh, 'D') = 'D' then M.anUserChg else X._dl_UserCh END, CIA.anUserIns = CASE WHEN IsNull(X._dl_TypeCh, 'D') = 'D' then M.anUserChg else X.anUserChg END from #lHE_ChangedInvoicesAnalytical CIA inner join tHE_Move M on CIA.acKey = M.acKey OUTER APPLY (Select TOP 1 _dl_LastCh, _dl_TypeCh, _dl_UserCh, anUserChg from tHE_Move_Undo where acKey = CIA.acKey and anForPay <> M.anForPay order by _dl_LastCh desc) X where CIA.acChgType = 'Q' and CIA.acType = 'M' --Filling document items with missmatched heads (zero value or other) Insert into #lHE_ChangedInvoicesAnalyticalItems (acType, acSubType, acKey, ChgNum, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT) Select 'M', 'M', CIA.acKey, CIA.ChgNum, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, IsNull(MIU.anExciseInc,0), IsNUll(MIU.anExciseIncP,0), IsNull(MIU.anExciseNotInc,0), IsNull(MIU.anExciseNotIncP,0), acVATCode, anVAT from #lHE_ChangedInvoicesAnalytical CIA JOIN tHE_MoveItem MIU ON CIA.acKEy = MIU.ackey WHERE CIA.acChgType = 'Q' --Filling statuses ------------------------------------------------------- Update #lHE_ChangedInvoicesAnalytical Set acStatus = CASE WHEN anForPay = 0 THEN '4' ELSE '5' END, acStatusDescr = CASE WHEN anForPay = 0 THEN 'Dokument brisanje prazni' ELSE 'Dokument brisanje' END where acChgType = 'D' Update CIA Set CIA.acStatus = '5', CIA.acStatusDescr = 'Dokument brisanje' from #lHE_ChangedInvoicesAnalytical CIA where CIA.acChgType = 'U' and exists(Select acKey from tHE_Move_Undo where acKey = CIA.acKey and _dl_TypeCh = 'D' and IsNull(adDateTimePrint, '') <> '' and _dl_LastCh >= (Select min(CIA2._dl_LastCh) from #lHE_ChangedInvoicesAnalytical CIA2 where CIA2.acKey = CIA.acKey)) Update CIA Set CIA.acStatus = '2', CIA.acStatusDescr = 'Pozicije Brisanje/Dodajanje' from #lHE_ChangedInvoicesAnalytical CIA OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh in ('U', 'D') and _dl_LastCh >= (Select min(CIA2._dl_LastCh) from #lHE_ChangedInvoicesAnalytical CIA2 where CIA2.acKey = CIA.acKey)) MU OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh = 'D' and _dl_LastCh < CIA._dl_LastCh and _dl_LastCh >= CIA._dl_LastChPrev) MU2 where acChgType = 'U' and (MU.acKEy is not null or MU2.acKey is not null) and IsNull(CIA.acStatus, '') = '' Update CIA Set acStatus = (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') = '' Update CIA Set CIA.acStatus = '3', CIA.acStatusDescr = 'Pozicije Dodajanje' from #lHE_ChangedInvoicesAnalytical CIA OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh in ('U', 'D') and _dl_LastCh >= (Select min(CIA2._dl_LastCh) from #lHE_ChangedInvoicesAnalytical CIA2 where CIA2.acKey = CIA.acKey)) MU OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh = 'D' and _dl_LastCh < CIA._dl_LastCh and _dl_LastCh >= CIA._dl_LastChPrev) MU2 where acChgType = 'U' and (MU.acKEy is null and MU2.acKey is null) and IsNull(CIA.acStatus, '') = '' Update CIA Set acStatus = (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') = '' Update #lHE_ChangedInvoicesAnalytical Set acStatusDescr = CASE WHEN (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) = '2' THEN 'Pozicije Brisanje/Dodajanje' WHEN (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) = '3' THEN 'Pozicije Dodajanje' WHEN (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) = '5' THEN 'Dokument brisanje' END from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') <> '' and IsNull(CIA.acStatusDescr, '') = '' Update #lHE_ChangedInvoicesAnalytical Set acStatus = '7', acStatusDescr = 'Razno' from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') = '' --Filling log ------------------------------------------------------- set @nChgNumSession = IsNull((Select max(anChgNumSession) from _ChangedInvoicesLog), 0) + 1 Insert into _ChangedInvoicesLog (anUserId, adTimeIns, anChgNumSession) values (@nUserId, getdate(), @nChgNumSession) If object_id('_ChangedInvoicesLogAnalytical') is null Select cast(@nChgNumSession as varchar) as anChgNumSession, * into _ChangedInvoicesLogAnalytical from #lHE_ChangedInvoicesAnalytical else insert into _ChangedInvoicesLogAnalytical(anChgNumSession, acKey, acType, ChgNum, anForPay, adDateTimePrint, _dl_LastCh, _dl_LastChPrev,_dl_TypeCh, adDateTimePrintFiscalized, adFiscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber, anForPayDDVO) Select cast(@nChgNumSession as varchar) as anChgNumSession, acKey, acType, ChgNum, anForPay, adDateTimePrint, _dl_LastCh, _dl_LastChPrev,_dl_TypeCh, adDateTimePrintFiscalized, adFiscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, IsNull(anFiscalNumber, 0), anForPayDDVO from #lHE_ChangedInvoicesAnalytical If object_id('_ChangedInvoicesLogAnalyticalItems') is null Select cast(@nChgNumSession as varchar) as anChgNumSession, * into _ChangedInvoicesLogAnalyticalItems from #lHE_ChangedInvoicesAnalyticalItems else insert into _ChangedInvoicesLogAnalyticalItems(anChgNumSession, acType, acSubType, acKey, ChgNum, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, acVATCode, anVAT, anExciseInc, anExciseNotInc, anExciseIncP, anExciseNotIncP ) Select cast(@nChgNumSession as varchar) as anChgNumSession, acType, acSubType, acKey, ChgNum, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, acVATCode, anVAT, anExciseInc, anExciseNotInc, anExciseIncP, anExciseNotIncP from #lHE_ChangedInvoicesAnalyticalItems -- POS anCurrValue <> anForPay If not object_id('tempdb..#lHE_FxRateMissmatch') is null drop table #lHE_FxRateMissmatch DECLARE @anFxRateVersion INT DECLARE @adFxRateUpgradeTime DATETIME SET @anFxRateVersion = 600300 SELECT @adFxRateUpgradeTime = MAX(ul.adStartDate) FROM tPA_SysUpgradeTimeLog as ul INNER JOIN ( SELECT MIN(anBuildNo) as anBuildNo FROM tPA_SysUpgradeTimeLog WHERE anBuildNo >= @anFxRateVersion ) as t ON t.anBuildNo = ul.anBuildNo SELECT @adFxRateUpgradeTime as anVersion, m.acKey, CAST(0 as BIT) as anSelected, case when lf.acKey is not null and lft.ackey is null then CAST('Valuta popravljena. Naredi tehnini popravek in osvei seznam.' as NVARCHAR(100)) else CAST('' as NVARCHAR(100)) end as acDescription INTO #lHE_FxRateMissmatch FROM [dbo].[tHE_Move] as M INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = m.acDocType INNER JOIN tPA_SetDocType SDT on SDT.acDoctype = VD.acDocType LEFT JOIN _LinksFisc as lf ON lf.acKey = M.acKey and lf.acStatus = 'Popravljena valuta' LEFT JOIN _LinksFisc as lft ON lf.acKey = M.acKey and lf.acStatus = 'Tehnini popravek' WHERE ((M.anForPay <> M.anCurrValue) OR (lf.acKey is not null and lft.ackey is null)) AND SDT.acSetOf = 'F' and SDT.acType = 'M' 9999999GMFAENF8MBUiB windows-1250Kreiraj brisaneF\If not object_id('tempdb..#lHE_CreationErrors') is null truncate table #lHE_CreationErrors else create table #lHE_CreationErrors( acKey varchar(13), anNo integer, acIdent varchar(16), acError varchar(max) ) If not object_id('tempdb..#lHE_RecalcItems') is null truncate table #lHE_RecalcItems else create table #lHE_RecalcItems( acWarehouse varchar(30), acIdent varchar(16), ) declare @cDocType Char(4), @cIssuer Char(30), @cReceiver Char(30), @dDate DateTime, @nUserId Integer, @cDept Char(30), @cKey Char(13), @cCheckAuthor Char(1) , @cStatus VarChar(2), @cError VarChar(1024), @cKeyOrig Char(13), @cType varchar(2), @cIdent varchar(16), @nQty decimal(19,6), @cNote varchar(max), @nNo integer, @nNoOrig integer, @nPrice decimal(19,6), @nRebate decimal(19,6), @cZOI varchar(100), @cEOR varchar(100), @nFiscalNumber integer, @cFiscalDevice varchar(50), @cWorkPlace varchar(20), @dDateTimePrint datetime, @cErrorMessage NVarChar(4000), @dCurrentDate datetime, @cStatusDescr varchar(20), @nChgNumSession integer, @nForPay decimal(19,6), @nPVOCForPay decimal(19,6), @cIssuerNew varchar(30), @cWarehouse varchar(30), @nExciseInc decimal(19,6), @nExciseIncP decimal(19,6), @nExciseNotInc decimal(19,6), @nExciseNotIncP decimal(19,6), @cVatCode varchar(2), @nVat decimal(19,6), @dLastCh datetime, @cTypeCh Char(1), @cStatusSN Char(1), @nQtySN Decimal(19,6), @nChgNum integer, @dDateVAT datetime, @cKeyFiscNoExists varchar(13) set @nUserId = ~U~ set @dCurrentDate = (SubString(Convert(Char,GetDate(),102),1,10)) set @nChgNumSession = Cast('#lSessionId#' as integer); begin try begin transaction declare crHeads cursor local fast_forward for select X.* from (select A.acKey, A.acIssuer, A.acReceiver, A.acDept, A.adDate, A.acType, case when FFD.acZIk is null then IsNull(A.acZIk, '') else FFD.acZIK end as acZIK, case when FFD.acJIR is null then IsNull(A.acJIR, '') else FFD.acJIR end as acJIR, case when FFD.anFiscalNumber is null then A.anFiscalNumber else FFD.anFiscalNumber end as anFiscalNumber, A.adDateTimePrint, A.acStatusDescr, A.anForPay, A._dl_LastCh, A._dl_TypeCh, A.ChgNum, IsNull(FFD.acWorkPlace, SDT.acWorkPlace) as acWorkPlace, IsNull(FFD.acFiscalDevice, SDT.acFiscalDevice) as acFiscalDevice from #lHE_ChangedInvoicesAnalytical A left join tPA_SetDocType SDT on Substring(A.acKey, 3, 4) = SDT.acDocType left join #lHE_FURSFiscData FFD ON FFD.adDateTimePrint = dateadd(millisecond, -datepart(millisecond, A.addateTimePrint), A.addateTimePrint) where acMarked = 'T' and acChgType = 'D')X where X.acZIK <> '' open crHeads fetch next from crHeads into @cKeyOrig, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @cEOR, @nFiscalNumber, @dDateTimePrint, @cStatusDescr, @nForPay, @dLastCh, @cTypeCh, @nChgNum, @cWorkPlace, @cFiscalDevice WHILE (@@FETCH_STATUS = 0) BEGIN set @cStatus = 'T' set @cError = '' set @cIssuerNew = @cIssuer if exists (select ackey from tHE_Move where ackey = @cKeyOrig) begin insert into #lHE_CreationErrors(ackey, acERror) values (@cKeyOrig, 'Klju e obstaja!') set @cStatus = 'F' end else if not exists (select top 1 acSubject from the_setSubj where acSubject = @cReceiver) begin insert into #lHE_CreationErrors(ackey, acERror) values (@cKeyOrig, 'Subjekt '+ltrim(rtrim(@cReceiver))+' ne obstaja v ifrantu subjektov!') set @cStatus = 'F' end else begin update the_setSubj set acStockManage = '0' where acSubject = @cIssuer and acStockManage = 'R' INSERT INTO [dbo].[tHE_Move] ([acKey] ,[acDocType] ,[adDate] ,[acReceiver] ,[acIssuer] ,[acReceiverStock] ,[acIssuerStock] ,[acPrsn3] ,[acContactPrsn] ,[acDoc1] ,[adDateDoc1] ,[acDoc2] ,[adDateDoc2] ,[acStatement] ,[acWayOfSale] ,[acPriceRate] ,[acPayMethod] ,[acDelivery] ,[acForm] ,[acInvoiceForm] ,[adDateInv] ,[anDaysForPayment] ,[adDateDue] ,[anValue] ,[anVAT] ,[anDiscount] ,[anForPay] ,[acLimitDuty] ,[anClerk] ,[acVerifiedPrices] ,[acCurrency] ,[anCurrValue] ,[anFXRate] ,[acCode1] ,[acCode2] ,[acCode3] ,[acPayPurpose1] ,[acPayPurpose2] ,[acPayPurpose3] ,[acRefNo1] ,[acRefNo2] ,[acDept] ,[acContactPrsn3] ,[anRebate] ,[anTransport] ,[anDuty] ,[anDirectCost] ,[anIncTax] ,[acPosted] ,[acTransPaperForm] ,[anVATIn] ,[adDateVAT] ,[acParity] ,[acParityPost] ,[acDutyTran] ,[anVATBase] ,[anBnkAcctNo] ,[acCreatFromWO] ,[adDateBeforeVAT] ,[acISOCountry] ,[acTriangTrans] ,[acAcctClaimLiab] ,[acVATAttType] ,[adVATAttDate] ,[acCreatePayOrd] ,[acDeptOut] ,[acCostDrvOut] ,[anNoteClerk] ,[adDateDDVPay] ,[acContractNo] ,[acIDBCState] ,[anRoundItem] ,[anRoundValue] ,[acRoundVATOnDoc] ,[acRefNo3] ,[acRefNo4] ,[acPackNum] ,[acDocTypePayOrd] ,[acDocTypePayOrdFgn] ,[anOurBankAcctNo] ,[anFgnBankNo] ,[acVerifyStatus] ,[anSigner1] ,[adSigned1] ,[anSigner2] ,[adSigned2] ,[anSigner3] ,[adSigned3] ,[acFiskPrintNo] ,[acFiskPrintNoS] ,[acTransportCalcType] ,[acNote] ,[acInternalNote] ,[acFieldSA] ,[acFieldSB] ,[acFieldSC] ,[acFieldSD] ,[acFieldSE] ,[acFieldSF] ,[acFieldSG] ,[acFieldSH] ,[acFieldSI] ,[acFieldSJ] ,[anFieldNA] ,[anFieldNB] ,[anFieldNC] ,[anFieldND] ,[anFieldNE] ,[anFieldNF] ,[anFieldNG] ,[anFieldNH] ,[anFieldNI] ,[anFieldNJ] ,[adFieldDA] ,[adFieldDB] ,[adFieldDC] ,[adFieldDD] ,[acUPNReference] ,[acUPNCode] ,[acUPNControlNum] ,[acProc] ,[acLoyaltyCard] ,[acParityType] ,[anPaid2] ,[acUPNPrint] ,[acNote2] ,[acNote3] ,[acInsFromImport] ,[anLicensesBase] ,[anLicensesVAT] ,[adTimeFiscal] ,[anSeqWhNoIn] ,[anSeqWhNoOut] ,[anRoundItemFC] ,[acDeliveryUnderART163A] ,[anRoundValueOC] ,[anRoundPrice] ,[acUJPDocId] ,[acFiscSalesBookSetNo] ,[acFiscSalesBookSerNo] ,[acFiscSalesBookDocNo] ,[adDateTimePrint]) SELECT TOP 1 [acKey] ,[acDocType] ,@dCurrentDate ,[acReceiver] ,[acIssuer] ,[acReceiverStock] ,[acIssuerStock] ,[acPrsn3] ,[acContactPrsn] ,[acDoc1] ,[adDateDoc1] ,[acDoc2] ,[adDateDoc2] ,[acStatement] ,[acWayOfSale] ,[acPriceRate] ,[acPayMethod] ,[acDelivery] ,[acForm] ,[acInvoiceForm] ,[adDateInv] ,[anDaysForPayment] ,[adDateDue] ,[anValue] ,[anVAT] ,[anDiscount] ,[anForPay] ,[acLimitDuty] ,[anClerk] ,[acVerifiedPrices] ,[acCurrency] ,[anCurrValue] ,[anFXRate] ,[acCode1] ,[acCode2] ,[acCode3] ,[acPayPurpose1] ,[acPayPurpose2] ,[acPayPurpose3] ,[acRefNo1] ,[acRefNo2] ,[acDept] ,[acContactPrsn3] ,[anRebate] ,[anTransport] ,[anDuty] ,[anDirectCost] ,[anIncTax] ,[acPosted] ,[acTransPaperForm] ,[anVATIn] ,case when IsNull('#rgDDV#', '0') = '1' then adDateInv else @dCurrentDate end --popravljano 2.11. in 3.11., najprej elja po radio buttonu, da se lahko da tudi datum rauna, 3.11. umaknjeno ,[acParity] ,[acParityPost] ,[acDutyTran] ,[anVATBase] ,[anBnkAcctNo] ,[acCreatFromWO] ,[adDateBeforeVAT] ,[acISOCountry] ,[acTriangTrans] ,[acAcctClaimLiab] ,[acVATAttType] ,[adVATAttDate] ,[acCreatePayOrd] ,[acDeptOut] ,[acCostDrvOut] ,[anNoteClerk] ,[adDateDDVPay] ,[acContractNo] ,[acIDBCState] ,[anRoundItem] ,[anRoundValue] ,[acRoundVATOnDoc] ,[acRefNo3] ,[acRefNo4] ,[acPackNum] ,[acDocTypePayOrd] ,[acDocTypePayOrdFgn] ,[anOurBankAcctNo] ,[anFgnBankNo] ,[acVerifyStatus] ,[anSigner1] ,[adSigned1] ,[anSigner2] ,[adSigned2] ,[anSigner3] ,[adSigned3] ,[acFiskPrintNo] ,[acFiskPrintNoS] ,[acTransportCalcType] ,[acNote] ,[acInternalNote] ,[acFieldSA] ,[acFieldSB] ,[acFieldSC] ,[acFieldSD] ,[acFieldSE] ,[acFieldSF] ,[acFieldSG] ,[acFieldSH] ,[acFieldSI] ,[acFieldSJ] ,[anFieldNA] ,[anFieldNB] ,[anFieldNC] ,[anFieldND] ,[anFieldNE] ,[anFieldNF] ,[anFieldNG] ,[anFieldNH] ,[anFieldNI] ,[anFieldNJ] ,[adFieldDA] ,[adFieldDB] ,[adFieldDC] ,[adFieldDD] ,[acUPNReference] ,[acUPNCode] ,[acUPNControlNum] ,[acProc] ,[acLoyaltyCard] ,[acParityType] ,[anPaid2] ,[acUPNPrint] ,[acNote2] ,[acNote3] ,[acInsFromImport] ,[anLicensesBase] ,[anLicensesVAT] ,[adTimeFiscal] ,[anSeqWhNoIn] ,[anSeqWhNoOut] ,[anRoundItemFC] ,[acDeliveryUnderART163A] ,[anRoundValueOC] ,[anRoundPrice] ,[acUJPDocId] ,[acFiscSalesBookSetNo] ,[acFiscSalesBookSerNo] ,[acFiscSalesBookDocNo] ,[adDateTimePrint] FROM [dbo].[tHE_Move_UNDO] where acKey = @cKeyOrig and adDateTimePrint is not null and _dl_LastCh = @dLastCh Set @cDocType = (Select acDoctype from tHE_Move where acKey = @cKeyOrig) if exists(select top 1 ackey from [dbo].[tHE_Move_UNDO] where acKey = @cKeyOrig and adDateTimePrint is not null and _dl_LastCh = @dLastCh) set @cStatus = 'T' else begin set @cStatus = 'F' set @cError = 'Glava ni bila kreirana (manjka datum printa)!' end if @cStatus <> 'T' begin insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, @cError) end else begin --KREIRANJE PLAIL if @cTypeCh = 'U' begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh) Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh ) A where A.ChgNum = 1 end if @cTypeCh = 'D' begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D') Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh desc) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D' ) A where A.ChgNum = 1 end --KREIRANJE POZICIJ declare crItems cursor local fast_forward for select acIdent, anQty, anNo, anPrice, anRebate, anPVOCForPay, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT from #lHE_ChangedInvoicesAnalyticalItems where acKey = @cKeyOrig and ChgNum = @nChgNum open crItems fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVATCode, @nVAT WHILE (@@FETCH_STATUS = 0) BEGIN set @cStatus = 'T' exec dbo.pHE_MoveItemsCreAll @cKeyOrig, @cIdent, @nQty, @cNote, @nUserId, @nNo output, @cError output, @cStatus output if @cStatus <> 'T' begin insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKeyOrig, @nNoOrig, @cIdent, @cError); end else begin --UPDATE CENE, RABATA update MI Set anPrice = @nPrice, anRTPrice = (@nPVOCForPay / (1 - (@nRebate/100)))/CASE WHEN @nQty = 0 THEN 1 ELSE @nQty END, anRebate1 = @nRebate, anRebate2= 0, anRebate3= 0, anRebate = @nRebate, anExciseInc = @nExciseInc, anExciseIncP = @nExciseIncP, anExciseNotInc = @nExciseNotInc, anExciseNotIncP = @nExciseNotIncP, anQty = @nQty, acVATCode = @cVatCode, anVAT = @nVAT from tHE_MoveItem MI inner join tPA_SetDocType SDT on Substring(MI.acKey, 3, 4) = SDT.acDocType where ackey = @cKeyOrig and anNo = @nNo exec dbo.pHE_MoveItemOutPvItem @cKeyOrig, @nNo insert into _LinksFiscItems(acKey, acKeyOrig, anUserIns, anUSerChg, adTimeIns, adTimeChg, anNoOrig, anNo, anChgNumSession, acIdent, anQty, anForPay, anRebate, anPrice) values (@cKeyOrig, @cKeyOrig, @nUserId, @nUserId, getdate(), getdate(), @nNoOrig, @nNo, @nChgNumSession, @cIdent, @nQty, @nPVOCForPay, @nRebate, @nPrice) --PRIDOBIVANJE VREDNOSTI ZA RECALC ZALOGE insert into #lHE_RecalcItems(acWarehouse, acIdent) values (@cIssuer, @cIdent) if exists (select acIdent from tHE_SetItem where acIdent = @cIdent and acSerialNo <> 'N') begin execute pHE_SerialNoAutoEdition '', @cIssuerNew, @cDocType, @cKeyOrig, @nNo, 'K', @cIdent, @nUserId, 'T', 0, @nQty, @nQtySN output, @cStatusSN output, '', '', '', 'T' if @nQty <> @nQtySN insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKeyOrig, @nNo, @cIdent, 'Izdana koliina identa in prosta koliina serijskih tevilk se ne ujemajo') end end fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVATCode, @nVAT END close crItems deallocate crItems end exec dbo.pHE_MoveSetSum @cKeyOrig update the_setSubj set acStockManage = 'R' where acSubject = @cIssuer and acStockManage = '0' --PREPIEMO FISKALNE PODATKE if @cZOI <> '' begin -- DEPERCATED: We create the document and resolve the duplicated fiscal number on "Duplicated" tab --set @cKeyFiscNoExists = (select top 1 ackey from the_movefiscalisation where anFiscalNumber = @nFiscalNumber and acFiscalDevice = @cFiscalDevice) --if IsNull(@cKeyFiscNoExists, '') <> '' begin -- insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, 'Fiskalna tevilka e obstaja na raunu t.: ' + @cKeyFiscNoExists) -- set @cStatus = 'F' --end --else begin -- Insert into the_MoveFiscalisation(acKey, acWorkPlace, acFiscalDevice, anFiscalNumber, acZIK, acJIR, adFiscalDate) -- values (@cKeyOrig, IsNull(@cWorkPlace, ''), IsNull(@cFiscalDevice, ''), @nFiscalNumber, IsNull(@cZOI, ''), IsNull(@cEOR, ''), IsNull(@dDateTimePrint, GetDate())) -- update tHE_Move set adDateTimePrint = @dDateTimePrint where ackey = @cKeyOrig --end DECLARE @IsFiscDup BIT set @IsFiscDup = 0 set @cKeyFiscNoExists = (select top 1 ackey from the_movefiscalisation where anFiscalNumber = @nFiscalNumber and acFiscalDevice = @cFiscalDevice) if IsNull(@cKeyFiscNoExists, '') <> '' set @IsFiscDup = 1 -- Get fiscal year from document issue date DECLARE @v_adDate DATE DECLARE @v_acYear CHAR(4) SET @v_adDate = IsNull(@dDateTimePrint, (SELECT TOP 1 adDate FROM [dbo].[tHE_Move] WHERE acKey = @cKeyOrig)) SET @v_acYear = CAST(YEAR(@v_adDate) as CHAR(4)) -- Check if company has a business year set and if current document date of issue fits in a business year IF (SELECT TOP 1 acDocKeyType FROM [dbo].[tpa_sysparam]) <> 'F' BEGIN DECLARE @v_Prefix CHAR(2) SET @v_Prefix = (SELECT TOP 1 acPrefix FROM [dbo].[tPA_SysParamKeyYear] WHERE @v_adDate >= adDateFrom AND @v_adDate <= adDateTo) -- Get fiscal year from business year if @v_Prefix is not null SET @v_acYear = LEFT(CAST(YEAR(GETDATE()) as CHAR(49)), 2) + @v_Prefix END -- Backward compatibility: -- By law if one document type was numbered incorrectly, all document types need to continue with wrong numbering -- This is pending only for year 2016 issued documents (documents were fiscalised using adDate) IF (@v_acYear = '2015' OR @v_acYear = '2016') BEGIN IF (SELECT COUNT(acDocType) FROM ( SELECT CASE WHEN ISNULL(@cFiscalDevice, '') = '' THEN acDocType ELSE acFiscalDevice END as acDocType, acYearInv, MIN(anFiscalNumber) as anFiscalNumber FROM [dbo].[tHE_MoveFiscalisation] WHERE acYearInv = '2016' GROUP BY CASE WHEN ISNULL(@cFiscalDevice, '') = '' THEN acDocType ELSE acFiscalDevice END, acYearInv HAVING MIN(anFiscalNumber) > 1 ) as t) > 0 BEGIN SET @v_acYear = CAST(YEAR(@dDate) as CHAR(4)) END END Insert into the_MoveFiscalisation(acKey, acWorkPlace, acFiscalDevice, anFiscalNumber, acZIK, acJIR, adFiscalDate, acYearInv, acDocType) values (@cKeyOrig, IsNull(@cWorkPlace, ''), IsNull(@cFiscalDevice, ''), @nFiscalNumber, IsNull(@cZOI, ''), IsNull(@cEOR, ''), IsNull(@dDateTimePrint, GetDate()), @v_acYear, @cDocType) update tHE_Move set adDateTimePrint = @dDateTimePrint where ackey = @cKeyOrig -- Add to duplicated list if @IsFiscDup = 1 begin insert into #lHE_DuplicatedInvoices select @cKeyOrig, rtrim(IsNull(@cWorkPlace, '')) + '-' + rtrim(IsNull(@cFiscalDevice, '')) + '-' + cast(@nFiscalNumber as varchar) as acFiscalNumber, @dDateTimePrint as adDateTimePrint, @nForPay, CAST(0 as BIT) as anSelected, CAST('' as NVARCHAR(100)) as acDescription if @cKey is null set @cKey = (select top 1 ackey from the_movefiscalisation where anFiscalNumber = @nFiscalNumber and acFiscalDevice = @cFiscalDevice and acKey <> @cKeyOrig) if @cKey is not null begin insert into #lHE_DuplicatedInvoices select @cKey, rtrim(IsNull(@cWorkPlace, '')) + '-' + rtrim(IsNull(@cFiscalDevice, '')) + '-' + cast(@nFiscalNumber as varchar) as acFiscalNumber, @dDateTimePrint as adDateTimePrint, @nForPay, CAST(0 as BIT) as anSelected, CAST('' as NVARCHAR(100)) as acDescription end end end if IsNull(@cStatus, 'T') = 'T' begin Select @nVat = anVAT from tHE_Move where acKey = @cKeyOrig insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated, anVatInCurPer) values (@cKeyOrig, @cKeyOrig, @cType, @nUserId, @nUserId, getdate(), getdate(), 'A', @nForPay, @nChgNumSession, @cStatusDescr, 'A', @nVat) end else delete from tHE_Move where acKey = @cKeyOrig END fetch next from crHeads into @cKeyOrig, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @cEOR, @nFiscalNumber, @dDateTimePrint, @cStatusDescr, @nForPay, @dLastCh, @cTypeCh, @nChgNum, @cWorkPlace, @cFiscalDevice END close crHeads deallocate crHeads commit transaction; end try begin catch IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION; end catch --PRERAUN ZALOGE NA SKLADIE in IDENT declare crRecalc cursor local for select distinct acIdent, acWarehouse from #lHE_RecalcItems open crRecalc fetch next from crRecalc into @cIdent, @cWarehouse while (@@FETCH_STATUS = 0) begin execute pPA_SerialNoStatusRecalc @cIdent, @cWarehouse, '' execute pPA_StockRecalc @cIdent, @cWarehouse fetch next from crRecalc into @cIdent, @cWarehouse end close crRecalc deallocate crRecalc insert into #lHE_CreationErrors(acKey, acError) select X.acKey, 'ZOI je prazen, kreiranje ni mogoe! Uvozite FURS datoteko!' from (select A.acKey, case when FFD.acZIk is null then IsNull(A.acZIk, '') else FFD.acZIK end as acZIK from #lHE_ChangedInvoicesAnalytical A left join #lHE_FURSFiscData FFD ON FFD.adDateTimePrint = dateadd(millisecond, -datepart(millisecond, A.addateTimePrint), A.addateTimePrint) where acMarked = 'T' and acChgType = 'D')X where X.acZIK = '' update #lHE_ChangedInvoicesAnalytical set acMarked = 'F' 9999999GMFAENF8MBP>kB windows-1250Posodobi originalF3 If not object_id('tempdb..#lHE_CreationErrors') is null truncate table #lHE_CreationErrors else create table #lHE_CreationErrors( acKey varchar(13), anNo integer, acIdent varchar(16), acError varchar(max) ) If not object_id('tempdb..#lHE_RecalcItems') is null truncate table #lHE_RecalcItems else create table #lHE_RecalcItems( acWarehouse varchar(30), acIdent varchar(16), ) declare @cDocType Char(4), @cIssuer Char(30), @cReceiver Char(30), @dDate DateTime, @dDateVAT DateTime, @nUserId Integer, @cDept Char(30), @cKey Char(13), @cCheckAuthor Char(1) , @cStatus VarChar(2), @cError VarChar(1024), @cKeyOrig Char(13), @cType varchar(2), @cIdent varchar(16), @nQty decimal(19,6), @cNote varchar(max), @nNo integer, @nNoOrig integer, @nPrice decimal(19,6), @nRebate decimal(19,6), @cZOI varchar(100), @cErrorMessage NVarChar(4000), @nChgNum integer, @nChgNumSession integer, @vbContextInfoOld varbinary(128), @nForPay decimal(19, 6), @nForPayCreated decimal(19, 6), @nForPayPrev decimal(19, 6), @cSkip char(1), @dDateTimePrint DateTime, @dDateTimePrintPrev DateTime, @cStatusDescr varchar(100), @nPVOCForPay decimal(19,6), @cWarehouse varchar(30), @dCurrentDate datetime, @nExciseInc decimal(19,6), @nExciseIncP decimal(19,6), @nExciseNotInc decimal(19,6), @nExciseNotIncP decimal(19,6), @cVatCode varchar(2), @nVat decimal(19,6), @dLastCh datetime, @cStatusSN Char(1), @nQtySN Decimal(19,6), @cVATPeriod Char(7) , @cTypeOfDoc char(1) set @nUserId = ~U~ set @cSkip = 'F' set @dCurrentDate = (SubString(Convert(Char,GetDate(),102),1,10)) begin try exec [dbo].[pPA_ContextInfo_Set] 3,1 exec [dbo].[pPA_ContextInfo_Set] 4,1 set @nChgNumSession = Cast('#lSessionId#' as integer); begin transaction declare crHeads cursor local fast_forward for select CIA.acKey, CIA.adDate, CIA.acIssuer, CIA.acReceiver, CIA.acDept, CIA.adDate, CIA.acType, IsNull(CIA.acZik, ''), CIA.ChgNum, CIA.anForPay, CIA.adDateTimePrint, CIA.acStatusDescr, CIA._dl_LastCh, IsNull(M.adDateVAT, '19000101'), D.acTypeOfDoc from #lHE_ChangedInvoicesAnalytical CIA left join tHE_Move M on M.acKey = CIA.acKey JOIN tPA_SetDocType D on Substring(CIA.ackey,3,4) = D.acDocType where CIA.acKey in (Select distinct acKey from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey and acMarked = 'T' and acChgType = 'U') and CIA.acType = 'MU' and CIA.ChgNum = 1 order by CIA.acKey, CIA.ChgNum, CIA.adDateTimePrint, CIA.acStatusDescr desc open crHeads fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh, @dDateVAT, @cTypeOfDoc WHILE (@@FETCH_STATUS = 0) BEGIN set @cStatus = 'T' set @cError = '' if exists (select acClosed from tHE_VATCalc where dateadd(dd, - 1, dateadd(mm, 1, replace(acPeriod, '-', '') + '01')) >= @dDateVAT and replace(acPeriodStart, '-', '') + '01' <= @dDateVAT and acClosed = 'T') begin set @cVATPeriod = dbo.fPA_StrZeroInt(Year(@dDateVAT), 4) + '-' + dbo.fPA_StrZeroInt(Month(@dDateVAT), 2) exec pHE_MoveItemGetError 17, @nUserId, @cStatus output, @cError output, @cVATPeriod, '', '' end if @cStatus = 'T' begin if exists (select acSubject from tHE_SetSubj where acSubject = @cIssuer and acStockManage = 'R') if exists (select adMoveOpenDate from tPA_SysParam where adMoveOpenDate > @dDate) exec pHE_MoveItemGetError 18, @nUserId, @cStatus output, @cError output, 'M', '', '' end if @cStatus = 'T' begin if exists (select acSubject from tHE_SetSubj where acSubject = @cIssuer and acStockManage <> 'R') if exists (select adMoveNonMatOpenDate from tPA_SysParam where adMoveNonMatOpenDate > @dDate) exec pHE_MoveItemGetError 18, @nUserId, @cStatus output, @cError output, 'N', '', '' end if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, @cError) else begin set @nForPayPrev = @nForPay set @dDateTimePrintPrev = @dDateTimePrint update the_setSubj set acStockManage = '0' where acSubject = @cIssuer and acStockManage = 'R' delete from tHE_MoveItem where acKey = @cKeyOrig update tHE_Move set acIssuer = @cIssuer, acReceiver = @cReceiver, addateTimePrint= @dDateTimePrint where acKey = @cKeyOrig Set @cKey = @cKeyOrig set @cStatus = 'T' if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, @cError) else begin --KREIRANJE POZICIJ declare crItems cursor local fast_forward for select acIdent, anQty, anNo, anPrice, anRebate, anPVOCForPay, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVatCode, anVAT from #lHE_ChangedInvoicesAnalyticalItems where acKey = @cKeyOrig and ChgNum = @nChgNum and acType = @cType open crItems fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVatCode, @nVAT WHILE (@@FETCH_STATUS = 0) BEGIN exec dbo.pHE_MoveItemsCreAll @cKeyOrig, @cIdent, @nQty, @cNote, @nUserId, @nNo output, @cError output, @cStatus output if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKeyOrig, @nNoOrig, @cIdent, @cError) else begin --UPDATE CENE, RABATA update MI Set anPrice = @nPrice, anRTPrice = (@nPVOCForPay / (1 - (@nRebate/100)))/CASE WHEN @nQty = 0 THEN 1 ELSE @nQty END, anRebate1 = @nRebate, anRebate2= 0, anRebate3 = 0, anRebate = @nRebate, anExciseInc = @nExciseInc, anExciseIncP = @nExciseIncP, anExciseNotInc = @nExciseNotInc, anExciseNotIncP = @nExciseNotIncP, acVATCode = @cVatCode, anVAT = @nVAT, anQty = @nQty from tHE_MoveItem MI inner join tPA_SetDocType SDT on Substring(MI.acKey, 3, 4) = SDT.acDocType where ackey = @cKeyOrig and anNo = @nNo exec dbo.pHE_MoveItemOutPvItem @cKeyOrig, @nNo if @cTypeOfDoc = 'A' update MI Set anSalePrice = anPVOCForPay, anInSalePrice = anPVOCForPay from tHE_MoveItem MI where ackey = @cKeyOrig and anNo = @nNo insert into _LinksFiscItems(acKey, acKeyOrig, anUserIns, anUSerChg, adTimeIns, adTimeChg, anNoOrig, anNo, anChgNumSession, acIdent, anQty, anForPay, anRebate, anPrice) values (@cKeyOrig, @cKeyOrig, @nUserId, @nUserId, getdate(), getdate(), @nNoOrig, @nNo, @nChgNumSession, @cIdent, @nQty, @nPVOCForPay, @nRebate, @nPrice) --PRIDOBIVANJE VREDNOSTI ZA RECALC ZALOGE insert into #lHE_RecalcItems(acWarehouse, acIdent) values (@cIssuer, @cIdent) if exists (select acIdent from tHE_SetItem where acIdent = @cIdent and acSerialNo <> 'N') begin execute pHE_SerialNoAutoEdition '', @cIssuer, @cDocType, @cKeyOrig, @nNo, 'K', @cIdent, @nUserId, 'T', 0, @nQty, @nQtySN output, @cStatusSN output, '', '', '', 'T' if @nQty <> @nQtySN insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKeyOrig, @nNo, @cIdent, 'Izdana koliina identa in prosta koliina serijskih tevilk se ne ujemajo') end end fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVatCode, @nVAT END close crItems deallocate crItems exec dbo.pHE_MoveSetSum @cKey Select @nForPayCreated = anForPay from the_move where acKey = @cKey update the_setSubj set acStockManage = 'R' where acSubject = @cIssuer and acStockManage = '0' if not exists(select top 1 ackey from _LinksFisc where ackey = @cKeyOrig and acKeyOrig = @cKeyOrig and acCreated = 'O') insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated) values (@cKeyOrig, @cKeyOrig, @cType, @nUserId, @nUserId, getdate(), getdate(), 'A', @nForPayCreated, @nChgNumSession, @cStatusDescr, 'O') end --KREIRANJE PLAIL Delete from tHE_MoveCash where acKey = @cKeyOrig and (adTimeIns > @dLastCh or adTimeChg >= @dLastCh) if exists(Select top 1 acKey from tHE_Move_Undo where acKey = @cKeyOrig and _dl_LastCh = @dLastCh and _dl_TypeCh = 'U') begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh and adTimeIns <= @dLastCh) Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh and adTimeIns <= @dLastCh ) A where A.ChgNum = 1 end if exists(Select top 1 acKey from tHE_Move_Undo where acKey = @cKeyOrig and _dl_LastCh = @dLastCh and _dl_TypeCh = 'D') begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D' order by _dl_LastCh desc) Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh desc) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D' ) A where A.ChgNum = 1 end set @cSkip = 'F' end fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh, @dDateVAT, @cTypeOfDoc END close crHeads deallocate crHeads commit transaction; exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 end try begin catch set @cErrorMessage = ERROR_MESSAGE() raiserror (@cErrorMessage, 16, 1); exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 rollback; end catch --PRERAUN ZALOGE NA SKLADIE in IDENT declare crRecalc cursor local for select distinct acIdent, acWarehouse from #lHE_RecalcItems open crRecalc fetch next from crRecalc into @cIdent, @cWarehouse while (@@FETCH_STATUS = 0) begin execute pPA_SerialNoStatusRecalc @cIdent, @cWarehouse, '' execute pPA_StockRecalc @cIdent, @cWarehouse fetch next from crRecalc into @cIdent, @cWarehouse end close crRecalc deallocate crRecalc update #lHE_ChangedInvoicesAnalytical set acMarked = 'F' 9999999GFFAENF8MB2pB windows-1250FForm2F8object Form2: TForm Tag = 99 Left = 0 Top = 0 Caption = 'Form2' ClientHeight = 407 ClientWidth = 610 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqClearType OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 84 Top = 304 Width = 87 Height = 13 Caption = 'Izra'#269'unani podatki' end object edtKey: TdlcxLabeledTextEdit Left = 174 Top = 9 Properties.ReadOnly = False TabOrder = 0 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 77 EditLabel.Top = 10 EditLabel.Caption = 'Klju'#269' dokumenta:' EditLabel.FocusControl = edtKey EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 19 ComponentSize = csSmall Templatable = False Caption = 'Klju'#269' dokumenta:' ReadOnly = False Width = 423 end object edtDate: TdlcxLabeledDateEdit Left = 174 Top = 33 Properties.AssignedValues.DisplayFormat = True Properties.AssignedValues.EditFormat = True Properties.Kind = ckDateTime Properties.ReadOnly = False Properties.WeekNumbers = True TabOrder = 2 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 60 EditLabel.Top = 34 EditLabel.Caption = 'Datum in '#269'as izdaje:' EditLabel.FocusControl = edtDate EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 43 ComponentSize = csSmall Caption = 'Datum in '#269'as izdaje:' Templatable = False ReadOnly = False DropDownButtonWidth = 0 Width = 207 end object edtForPay: TdlcxLabeledTextEdit Left = 174 Top = 57 Properties.ReadOnly = False TabOrder = 4 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 18 EditLabel.Top = 58 EditLabel.Caption = 'Znesek dokumenta (z DDV)::' EditLabel.FocusControl = edtForPay EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 67 ComponentSize = csSmall Templatable = False Caption = 'Znesek dokumenta (z DDV)::' ReadOnly = False Width = 121 end object btnCalc: TdlcxButton Left = 175 Top = 199 Width = 120 Height = 25 Caption = 'Poka'#382'i podatke' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 6 end object edtWorkplace: TdlcxLabeledTextEdit Left = 175 Top = 150 Properties.ReadOnly = False TabOrder = 7 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 49 EditLabel.Top = 151 EditLabel.Caption = 'Oznaka posl. prostora:' EditLabel.FocusControl = edtWorkplace EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 160 ComponentSize = csSmall Templatable = False Caption = 'Oznaka posl. prostora:' ReadOnly = False Width = 120 end object edtDevice: TdlcxLabeledTextEdit Left = 175 Top = 175 Properties.ReadOnly = False TabOrder = 9 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 13 EditLabel.Top = 176 EditLabel.Caption = 'Oznaka elektronske naprave:' EditLabel.FocusControl = edtDevice EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 185 ComponentSize = csSmall Templatable = False Caption = 'Oznaka elektronske naprave:' ReadOnly = False Width = 121 end object edtZoi: TdlcxLabeledTextEdit Left = 174 Top = 327 Properties.ReadOnly = False TabOrder = 11 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 149 EditLabel.Top = 328 EditLabel.Caption = 'ZOI:' EditLabel.FocusControl = edtZoi EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 337 ComponentSize = csSmall Templatable = False Caption = 'ZOI:' ReadOnly = False Width = 424 end object edtQRCode: TdlcxLabeledTextEdit Left = 174 Top = 351 Properties.ReadOnly = False TabOrder = 13 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 92 EditLabel.Top = 352 EditLabel.Caption = 'QR '#269'rtna koda:' EditLabel.FocusControl = edtQRCode EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 361 ComponentSize = csSmall Templatable = False Caption = 'QR '#269'rtna koda:' ReadOnly = False Width = 423 end object edtTaxNumber: TdlcxLabeledTextEdit Left = 174 Top = 82 Properties.ReadOnly = False TabOrder = 15 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 64 EditLabel.Top = 83 EditLabel.Caption = 'Dav'#269'na '#353't. podjetja:' EditLabel.FocusControl = edtTaxNumber EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 92 ComponentSize = csSmall Templatable = False Caption = 'Dav'#269'na '#353't. podjetja:' ReadOnly = False Width = 121 end object edtCurrZoi: TdlcxLabeledTextEdit Left = 175 Top = 227 Properties.ReadOnly = False TabOrder = 17 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 107 EditLabel.Top = 228 EditLabel.Caption = 'ZOI na dok.:' EditLabel.FocusControl = edtZoi EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 237 ComponentSize = csSmall Templatable = False Caption = 'ZOI na dok.:' ReadOnly = False Width = 424 end object edtCurrEor: TdlcxLabeledTextEdit Left = 175 Top = 253 Properties.ReadOnly = False TabOrder = 19 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 104 EditLabel.Top = 254 EditLabel.Caption = 'EOR na dok.:' EditLabel.FocusControl = edtZoi EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 263 ComponentSize = csSmall Templatable = False Caption = 'EOR na dok.:' ReadOnly = False Width = 424 end object Panel1: TPanel Left = 17 Top = 321 Width = 590 Height = 1 BevelEdges = [] BevelOuter = bvNone Caption = 'Panel1' Color = clGray ParentBackground = False TabOrder = 21 end object bCopy: TdlcxButton Left = 175 Top = 378 Width = 120 Height = 25 Caption = 'Prenesi' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Calibri' Font.Style = [] Font.Quality = fqAntialiased TabOrder = 23 end object pnlZoi1: TPanel Left = 7 Top = 336 Width = 140 Height = 2 BevelEdges = [] BevelOuter = bvNone Color = clSilver ParentBackground = False TabOrder = 25 end object pnlZoi2: TPanel Left = 7 Top = 236 Width = 96 Height = 2 BevelEdges = [] BevelOuter = bvNone Color = clLime ParentBackground = False TabOrder = 22 end object pnlZoi3: TPanel Left = 7 Top = 237 Width = 2 Height = 100 BevelEdges = [] BevelOuter = bvNone Color = clSilver ParentBackground = False TabOrder = 24 end object cbAutoTax: TdlcxCheckBox Left = 174 Top = 103 Caption = 'Samodejna kompatibilnost za dokumente pred 1000003' State = cbsChecked TabOrder = 26 Transparent = True Width = 420 end object edtFiscNumIn: TdlcxLabeledTextEdit Left = 174 Top = 124 Properties.ReadOnly = False TabOrder = 29 LabelPosition = lpoLeft LabelSpacing = 3 LabelVisible = True EditLabel.Left = 82 EditLabel.Top = 125 EditLabel.Caption = 'Zap. fiskalna '#353't.:' EditLabel.ParentColor = False EditLabel.ParentFont = False EditLabel.Style.Font.Charset = DEFAULT_CHARSET EditLabel.Style.Font.Color = clWindowText EditLabel.Style.Font.Height = -12 EditLabel.Style.Font.Name = 'Calibri' EditLabel.Style.Font.Style = [] EditLabel.Style.Font.Quality = fqClearType EditLabel.Style.IsFontAssigned = True EditLabel.Properties.Alignment.Horz = taLeftJustify EditLabel.Alignment = taLeftJustify EditLabel.Color = clWindowText EditLabel.WordWrap = False EditLabel.AnchorY = 134 ComponentSize = csSmall Templatable = False Caption = 'Zap. fiskalna '#353't.:' ReadOnly = False Width = 121 end object _evsaver: TEventCom end object dsDoc: TDataSource DataSet = tbDoc Left = 459 Top = 203 end object tbDoc: TdlDataset FieldNamesToUpperCase = False UpdatingTable = '' AutoCalcFields = False Cached = False LocateInsert = False Editable = True RequestLive = False KeyFields = '' QueryRecCount = False DetailDelay = 0 LocalMasterDetail = False StrictUpdate = False TrimFixedChar = True TrimVarChar = True ORACompatibility = False Left = 425 Top = 203 end end unit FForm2; interface uses Forms, Controls, StdCtrls, SysUtils, Classes, Graphics, dlComponents, Dialogs, LibFiscRecovery, dlDatabase, db, ExtCtrls; type TfrmFiscalData = class(TarForm) edtKey: TdlcxLabeledTextEdit; edtDate: TdlcxLabeledTextEdit; edtForPay: TdlcxLabeledTextEdit; btnCalc: TdlcxButton; edtWorkplace: TdlcxLabeledTextEdit; edtDevice: TdlcxLabeledTextEdit; edtZoi: TdlcxLabeledTextEdit; edtQRCode: TdlcxLabeledTextEdit; edtTaxNumber: TdlcxLabeledTextEdit; edtCurrZoi: TdlcxLabeledTextEdit; edtCurrEor: TdlcxLabeledTextEdit; dsDoc: TDataSource; tbDoc: TdlDataset; Label1: TLabel; Panel1: TPanel; bCopy: TdlcxButton; pnlZoi1: TPanel; pnlZoi2: TPanel; pnlZoi3: TPanel; cbAutoTax: TdlcxCheckBox; edtFiscNumIn: TdlcxLabeledTextEdit; procedure bCopyClick(Sender: TObject); procedure btnCalcClick(Sender: TObject); private FCanCopy: Boolean; public ZOI: String; EOR: String; constructor Create(AOwner: TComponent; AKey: String; ADate: TDateTime; AForPay: Double; ACanCopy: Boolean = false); override; end; var frmFiscalData: TfrmFiscalData; implementation constructor TfrmFiscalData.Create(AOwner: TComponent; AKey: String; ADate: TDateTime; AForPay: Double; ACanCopy: Boolean = false); var sFiscNumStatus: PChar; sWorkplace: String; sDevice: String; sTaxnumber: String; iFiscNum: Integer; begin inherited Create(AOwner); Ares.AssignObjectsToForm('FForm2', Self); btnCalc.OnClick := btnCalcClick; bCopy.OnClick := bCopyClick; ZOI := ''; EOR := ''; FCanCopy := ACanCopy; if not FCanCopy then begin bCopy.Visible := false; end; pnlZoi1.Color := clSilver; pnlZoi2.Color := clSilver; pnlZoi3.Color := clSilver; edtKey.Text := AKey; edtDate.Text := formatdatetime('dd.mm.yyyy hh:nn:ss', ADate); edtForPay.Text := FloatToStr(AForPay); sTaxnumber := GetTaxnumber(PChar(AKey)); sWorkplace := GetWorkplace(PChar(AKey)); sDevice := GetDevice(PChar(AKey)); iFiscNum := CalcFiscalNum(PChar(AKey), sFiscNumStatus); edtTaxNumber.Text := sTaxnumber; edtWorkPlace.Text := sWorkplace; edtDevice.Text := sDevice; edtFiscNumIn.Text := IntToStr(iFiscNum); tbDoc.SQL.Text := 'select acZIK, acJIR from tHE_MoveFiscalisation where ackey = ''' + AKey + ''''; tbDoc.Open; if not tbDoc.Eof then begin edtCurrZoi.Text := tbDoc.FieldByName('acZIK').AsString; edtCurrEor.Text := tbDoc.FieldByName('acJIR').AsString; end; tbDoc.Close; btnCalcClick(btnCalc); end; procedure TfrmFiscalData.btnCalcClick(Sender: TObject); var sKey: String; iFiscNum: Integer; sZOI: String; dFiscDate: TDateTime; sTaxnumber: String; sWorkplace: String; sDevice: String; fAmount: Double; sQRCode: String; bTaxNumVersion: Boolean; s: String; sFiscNumStatus: PChar; begin sKey := edtKey.Text; dFiscDate := strtodatetime(edtDate.Text); fAmount := StrToFloat(edtForPay.Text); sTaxnumber := edtTaxNumber.Text; sWorkplace := edtWorkPlace.Text; sDevice := edtDevice.Text; //if sTaxnumber = '' then // sTaxnumber := GetTaxnumber(PChar(sKey)); //if sWorkplace = '' then // sWorkplace := GetWorkplace(PChar(sKey)); //if sDevice = '' then // sDevice := G      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJQRSTUVWXYZ[\]`abcdefghijklmnopqrstuvwxyz{|}~etDevice(PChar(sKey)); // Check document version (before version 600003 ZOI did not contain tax number) bTaxNumVersion := True; if cbAutoTax.Checked then bTaxNumVersion := IsDocVersion(dFiscDate, '600003'); // Try to calculate the fiscal number if edtFiscNumIn.Text = '' then iFiscNum := CalcFiscalNum(PChar(sKey), sFiscNumStatus) else iFiscNum := StrToInt(edtFiscNumIn.Text); // Check how fiscal number was calculated if (sFiscNumStatus = 'Predicted number') then begin // The number was only predicted, not 100% accurate // Let user enter fiscal number s := inputbox('Fisc number', 'Enter document fiscal number (integer), corret number could not be 100% calculated', IntToStr(iFiscNum)); if (s <> '') then iFiscNum := StrToInt(s); end; if (sFiscNumStatus = 'Filled deleted number') then begin // There was a perfect gap between the previous and next document, the number was filled in between end; if (sFiscNumStatus = 'Original number') then begin // Entry in tHE_MoveFiscalisation already exist, the existing anFiscalNumber was returened end; // Calculate ZOI from all parameters sZOI := CalcZoi(PChar(sTaxNumber), dFiscDate, PChar(IntToStr(iFiscNum)), PChar(sWorkplace), PChar(sDevice), fAmount, bTaxNumVersion); // Calculate QR barcode sQRCode := CalcQRBarcode(PChar(sTaxnumber), dFiscDate, PChar(sZOI)); // Show fisc results edtTaxNumber.Text := sTaxnumber; edtWorkPlace.Text := sWorkplace; edtDevice.Text := sDevice; edtFiscNumIn.Text := IntToStr(iFiscNum); edtZoi.Text := sZOI; edtQRCode.Text := sQRCode; pnlZoi1.Color := clSilver; pnlZoi2.Color := clSilver; pnlZoi3.Color := clSilver; if edtCurrZoi.Text = edtZoi.Text then begin pnlZoi1.Color := clLime; pnlZoi2.Color := clLime; pnlZoi3.Color := clLime; end; end; procedure TfrmFiscalData.bCopyClick(Sender: TObject); begin if edtZoi.Text = edtCurrZOI.Text then begin ZOI := edtCurrZOI.Text; EOR := edtCurrEor.Text; end else begin ZOI := edtZoi.Text; end; ModalResult := mrOk; end; end. 9999999GUFAENF8MBpB windows-1250LibFiscRecoveryFg)unit LibFiscRecovery; interface uses SysUtils, Classes, Windows, Dialogs, DB; procedure Init(AConnectionString: String); function GetTaxnumber(AKey: PChar): PChar; function GetWorkplace(AKey: PChar): PChar; function GetDevice(AKey: PChar): PChar; function CalcFiscalNum(AKey: PChar; var AStatus: PChar): Integer; function CalcZoi(ATaxNumber: PChar; AIssueDate: TDateTime; AInvoiceNum: PChar; AWorkPlaceId: PChar; ADeviceId: PChar; AAmount: Double; ATaxNumVersion: Boolean): PChar; function CalcZoiFromKey(AKey: PChar; AIssueDate: TDateTime; AAmount: Double): PChar; function CalcQRBarcode(ATaxNumber: PChar; AFiscalDate: TDateTime; AZOI: PChar): PChar; procedure DLLHandleClose; Procedure DLLHandleCreate; procedure CalcZoiDataset(ADataset: TDataset; ACheckedName: String = 'acMarked'; AKeyName: String = 'acKey'; ADateName: String = 'adDateTimePrint'; AForPayName: String = 'anForPay'; AZoiName: String = 'acZIK'; AFiscNumName: String = 'anFiscalNOFisc'); procedure GetFiscData(AKey: String; ADate: TDateTime; AAmount: Double; var AZoi: String; var AFiscNum: Integer); function IsDocVersion(AFiscalDate: TDateTime; AVersion: PChar): Boolean; function IsNumberStr(cStr: string): boolean; implementation uses Forms; type TProcInit = procedure(AServerName: PChar; ADatabaseName: PChar; AUsername: PChar; APassword: PChar); stdcall; TProcUninit = procedure(); stdcall; TFuncGetTaxnumber = function(AKey: PChar): PChar; stdcall; TFuncGetWorkplace = function(AKey: PChar): PChar; stdcall; TFuncGetDevice = function(AKey: PChar): PChar; stdcall; TFuncCalcFiscalNum = function(AKey: PChar; var AStatus: PChar): Integer; stdcall; TFuncCalcZoi = function(ATaxNumber: PChar; AIssueDate: TDateTime; AInvoiceNum: PChar; AWorkPlaceId: PChar; ADeviceId: PChar; AAmount: Double; ATaxNumVersion: Boolean): PChar; stdcall; TFuncCalcZoiFromKey = function(AKey: PChar; AIssueDate: TDateTime; AAmount: Double): PChar; stdcall; TFuncCalcQRBarcode = function(ATaxNumber: PChar; AFiscalDate: TDateTime; AZOI: PChar): PChar; stdcall; TFuncIsDocVersion = function(AFiscalDate: TDateTime; AVersion: PChar): Boolean; stdcall; const DLLName: String = 'FiscRecovery.dll'; var P: Pointer; UProcInit: TProcInit = Nil; UProcUninit: TProcUninit = Nil; UFuncGetTaxnumber: TFuncGetTaxnumber = Nil; UFuncGetWorkplace: TFuncGetWorkplace = Nil; UFuncGetDevice: TFuncGetDevice = Nil; UFuncCalcFiscalNum: TFuncCalcFiscalNum = Nil; UFuncCalcZoi: TFuncCalcZoi = Nil; UFuncCalcZoiFromKey: TFuncCalcZoiFromKey = Nil; UFuncCalcQRBarcode: TFuncCalcQRBarcode = Nil; UFuncIsDocVersion: TFuncIsDocVersion = Nil; UDLLHandle: THandle = 0; USQLServername: String; USQLDatabaseName: String; USQLUsername: String; USQLPassword: String; Procedure DLLHandleCreate; var ErrorMode: UINT; begin if (UDLLHandle <> 0) then Exit; ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); try UDLLHandle := LoadLibrary(PWideChar(DLLName)); finally SetErrorMode(ErrorMode); end; if UDLLHandle = 0 then begin ShowMessage(SysErrorMessage(GetLastError)); ShowMessage('Place ''FiscRecovery.dll'' into folder ''' + IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName)) + '''.'); end; end; procedure DLLHandleClose; begin FreeLibrary(UDLLHandle); end; procedure ParseDbCredentials(AConnectionString: String); var i: Integer; j: Integer; s: String; begin s := AConnectionString; i := Pos('Data Source=', s) + 12; s := Copy(s, i, Length(s)); j := Pos(';', s) - 1; if j <= 0 then j := Length(s); USQLServername := Copy(s, 1, j); s := AConnectionString; i := Pos('Initial Catalog=', s) + 16; s := Copy(s, i, Length(s)); j := Pos(';', s) - 1; if j <= 0 then j := Length(s); USQLDatabaseName := Copy(s, 1, j); s := AConnectionString; i := Pos('User ID=', s) + 8; s := Copy(s, i, Length(s)); j := Pos(';', s) - 1; if j <= 0 then j := Length(s); USQLUsername := Copy(s, 1, j); s := AConnectionString; i := Pos('Password=', s) + 9; s := Copy(s, i, Length(s)); j := Pos(';', s) - 1; if j <= 0 then j := Length(s); USQLPassword := Copy(s, 1, j); end; procedure Init(AConnectionString: String); begin DLLHandleCreate; if UDLLHandle = 0 then Exit; try ParseDbCredentials(AConnectionString); P := GetProcAddress(UDLLHandle, 'Init'); UProcInit := TProcInit(P); UProcInit(PChar(USQLServername), PChar(USQLDatabaseName), PChar(USQLUsername), PChar(USQLPassword)); finally //DLLHandleClose; end; end; procedure Uninit(); begin DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'Uninit'); UProcUninit := TProcUninit(P); UProcUninit(); finally //DLLHandleClose; end; end; function GetTaxnumber(AKey: PChar): PChar; begin Result := ''; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'GetTaxnumber'); UFuncGetTaxnumber := TFuncGetTaxnumber(P); Result := UFuncGetTaxnumber(AKey); finally //DLLHandleClose; end; end; function GetWorkplace(AKey: PChar): PChar; begin Result := ''; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'GetWorkplace'); UFuncGetWorkplace := TFuncGetWorkplace(P); Result := UFuncGetWorkplace(AKey); finally //DLLHandleClose; end; end; function GetDevice(AKey: PChar): PChar; begin Result := ''; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'GetDevice'); UFuncGetDevice := TFuncGetDevice(P); Result := UFuncGetDevice(AKey); finally //DLLHandleClose; end; end; function CalcFiscalNum(AKey: PChar; var AStatus: PChar): Integer; begin Result := 0; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'CalcFiscalNum'); UFuncCalcFiscalNum := TFuncCalcFiscalNum(P); Result := UFuncCalcFiscalNum(AKey, AStatus); finally //DLLHandleClose; end; end; function CalcZoi(ATaxNumber: PChar; AIssueDate: TDateTime; AInvoiceNum: PChar; AWorkPlaceId: PChar; ADeviceId: PChar; AAmount: Double; ATaxNumVersion: Boolean): PChar; begin Result := ''; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'CalcZoi'); UFuncCalcZoi := TFuncCalcZoi(P); Result := UFuncCalcZoi(ATaxNumber, AIssueDate, AInvoiceNum, AWorkPlaceId, ADeviceId, AAmount, ATaxNumVersion); finally //DLLHandleClose; end; end; function CalcZoiFromKey(AKey: PChar; AIssueDate: TDateTime; AAmount: Double): PChar; begin Result := ''; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'CalcZoiFromKey'); UFuncCalcZoiFromKey := TFuncCalcZoiFromKey(P); Result := UFuncCalcZoiFromKey(AKey, AIssueDate, AAmount); finally //DLLHandleClose; end; end; function CalcQRBarcode(ATaxNumber: PChar; AFiscalDate: TDateTime; AZOI: PChar): PChar; begin Result := ''; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'CalcQRBarcode'); UFuncCalcQRBarcode := TFuncCalcQRBarcode(P); Result := UFuncCalcQRBarcode(ATaxNumber, AFiscalDate, AZOI); finally //DLLHandleClose; end; end; procedure CalcZoiDataset(ADataset: TDataset; ACheckedName: String = 'acMarked'; AKeyName: String = 'acKey'; ADateName: String = 'adDateTimePrint'; AForPayName: String = 'anForPay'; AZoiName: String = 'acZIK'; AFiscNumName: String = 'anFiscalNOFisc'); var sKey: String; dDate: TDateTime; sZOI: String; fAmount: Double; sStatus: PChar; iFiscNum: Integer; begin iFiscNum := 0; ADataset.DisableControls; try ADataset.First; while not ADataset.Eof do begin if (ADataset.FieldByName(ACheckedName).AsString <> 'T') or (ADataset.FieldByName(AZoiName).IsNull) or (ADataset.FieldByName(AZoiName).AsString <> '') then begin ADataset.Next; end else begin sKey := ADataset.FieldByName(AKeyName).AsString; dDate := ADataset.FieldByName(ADateName).AsDateTime; fAmount := ADataset.FieldByName(AForPayName).AsFloat; try sZOI := CalcZoiFromKey(PChar(sKey), dDate, fAmount); if (ADataset.FieldByName(AFiscNumName).IsNull) or (ADataset.FieldByName(AFiscNumName).AsInteger = 0) then begin sStatus := ''; iFiscNum := CalcFiscalNum(PChar(sKey), sStatus); end; except on e: Exception do sZOI := 'Error: ' + e.Message; end; ADataset.Edit; ADataset.FieldByName(AZoiName).AsString := sZOI; if iFiscNum > 0 then begin ADataset.FieldByName(AFiscNumName).Value := iFiscNum; showmessage(IntToStr(ADataset.FieldByName(AFiscNumName).AsInteger)); end; ADataset.Post; ADataset.Next; end; end; finally ADataset.EnableControls; end; end; procedure GetFiscData(AKey: String; ADate: TDateTime; AAmount: Double; var AZoi: String; var AFiscNum: Integer); var sKey: String; sStatus: PChar; begin AZoi := ''; AFiscNum := 0; try AZoi := CalcZoiFromKey(PChar(AKey), ADate, AAmount); AFiscNum := CalcFiscalNum(PChar(AKey), sStatus); except on e: Exception do AZoi := 'Error: ' + e.Message; end; end; function IsDocVersion(AFiscalDate: TDateTime; AVersion: PChar): Boolean; begin Result := False; DLLHandleCreate; if UDLLHandle = 0 then Exit; try P := GetProcAddress(UDLLHandle, 'IsDocVersion'); UFuncIsDocVersion := TFuncIsDocVersion(P); Result := UFuncIsDocVersion(AFiscalDate, AVersion); finally //DLLHandleClose; end; end; function IsNumberStr(cStr: string): boolean; var i: integer; begin Result := True; try for i := 1 to Length(cStr) do begin if (cStr[i] < '0') or (cStr[i] > '9') then begin if (cStr[i] <> '.') then begin Result := False; Break; end end; end; except // on E: Exception do // FillError(E, Application, 'IsNumberStr'); end; end; end. 9999999GMFAENF8MBsB windows-1250Furs Xml temp tableFTIf not object_id('tempdb..#lHE_FURSFiscData') is null truncate table #lHE_FURSFiscData else create table #lHE_FURSFiscData( adDateTimePrint datetime, anValue money, acZIK varchar(100), acJIR varchar(100), acWorkPlace varchar(20), acFiscalDevice varchar(50), anFiscalNumber int ) if not object_id('tempdb..#lHE_PAFiscData') is null drop table #lHE_PAFiscData Select Y.acKey, Y.anForPay, Y.acWorkPlace, Y.anFiscalNumber, Y.acFiscalDevice, adDateTimePrint into #lHE_PAFiscData from (Select M.acKey, M.anForPay, MF.acWorkPlace, MF.anFiscalNumber, MF.acFiscalDevice, dateadd(millisecond, -datepart(millisecond, M.addateTimePrint), M.adDateTimePrint) as adDateTimePrint from tHE_Move M left join tHE_MoveFiscalisation MF on MF.acKey = M.acKey) Y 9999999GMFAENF8MBsB windows-1250Furs Xml parserFDECLARE @XML XML SET @XML = '#xmlFursData#' TRUNCATE TABLE #lHE_AresXmlData INSERT INTO #lHE_AresXmlData SELECT b.value('(./DateTime/text())[1]','DATETIME') as adDateTimePrint, b.value('(./FiskNum/text())[1]','VARCHAR(100)') as anFiscalNumber, b.value('(./Value/text())[1]','MONEY') as anForPay, b.value('(./ZOI/text())[1]','VARCHAR(100)') as acZIK, b.value('(./EOR/text())[1]','VARCHAR(100)') as acJIR FROM @xml.nodes('/Documents/Document') as a(b) 9999999 GMFAENF8MB7zB windows-1250Kreiraj podvojeneF5If not object_id('tempdb..#lHE_CreationErrors') is null truncate table #lHE_CreationErrors else create table #lHE_CreationErrors( acKey varchar(13), anNo integer, acIdent varchar(16), acError varchar(max) ) If not object_id('tempdb..#lHE_RecalcItems') is null truncate table #lHE_RecalcItems else create table #lHE_RecalcItems( acWarehouse varchar(30), acIdent varchar(16), ) declare @cDocType Char(4), @cIssuer Char(30), @cReceiver Char(30), @dDate DateTime, @dDateInv DateTime, @nUserId Integer, @cDept Char(30), @cKey Char(13), @cCheckAuthor Char(1) , @cStatus VarChar(2), @cError VarChar(1024), @cKeyOrig Char(13), @cType varchar(2), @cIdent varchar(16), @nQty decimal(19,6), @cNote varchar(max), @nNo integer, @nNoOrig integer, @nPrice decimal(19,6), @nRebate decimal(19,6), @cZOI varchar(100), @cErrorMessage NVarChar(4000), @nChgNum integer, @nChgNumSession integer, @vbContextInfoOld varbinary(128), @nForPay decimal(19, 6), @nForPayCreated decimal(19, 6), @nForPayPrev decimal(19, 6), @cSkip char(1), @dDateTimePrint DateTime, @dDateTimePrintPrev DateTime, @cStatusDescr varchar(100), @nPVOCForPay decimal(19,6), @cWarehouse varchar(30), @dCurrentDate datetime, @nExciseInc decimal(19,6), @nExciseIncP decimal(19,6), @nExciseNotInc decimal(19,6), @nExciseNotIncP decimal(19,6), @cVatCode varchar(2), @nVat decimal(19,6), @cVATExclude char(1), @cFiscExclude char(1), @dLastCh datetime, @cStatusSN Char(1), @nQtySN Decimal(19,6) , @cSurrogateIdent varchar(16), @cUseSurrogentIdent Char(1), @cDocTypeU Char(4), @cTypeOfDoc Char(1) set @cVATExclude = '#cbVATExclude#' set @cFiscExclude = '#cbFiscExclude#' set @cUseSurrogentIdent = '#cbUse#' set @cSurrogateIdent = '#lSurrogateIdent#' set @cDocTypeU = '#fDocTypeU#' if @cVATExclude is null set @cVATExclude = 'F' if @cFiscExclude is null set @cFiscExclude = 'F' --set @cDocType = (select top 1 acdoctype from tpa_Setdoctype where acdoctype like '#fDocTypeU#%') set @nUserId = ~U~ set @cSkip = 'F' set @dCurrentDate = (SubString(Convert(Char,GetDate(),102),1,10)) begin try select @vbContextInfoOld = context_info from master..sysprocesses where spid = @@SPID exec [dbo].[pPA_ContextInfo_Set] 4,1 set @nChgNumSession = Cast('#lSessionId#' as integer); begin transaction declare crHeads cursor local fast_forward for select CIA.acKey, CIA.adDate, CIA.acIssuer, CIA.acReceiver, CIA.acDept, CIA.adDate, CIA.acType, IsNull(CIA.acZik, ''), CIA.ChgNum, CIA.anForPay, CIA.adDateTimePrint, CIA.acStatusDescr, CIA._dl_LastCh, M.adDateInv, D.acTypeOfDoc from #lHE_ChangedInvoicesAnalytical CIA inner join tHE_Move M on M.acKey = CIA.acKey JOIN tPA_SetDocType D on M.acDocType = D.acDocType where CIA.acKey in (Select distinct acKey from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey and acMarked = 'T' and acChgType = 'U') order by CIA.acKey, CIA.ChgNum, CIA.adDateTimePrint, CIA.acStatusDescr desc open crHeads fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh, @dDateInv, @cTypeOfDoc WHILE (@@FETCH_STATUS = 0) BEGIN set @cStatus = '' set @cError = '' set @cDocType = IsNull(@cDocTypeU, substring(@cKeyOrig, 3, 4)) if @cDocType = '' set @cDocType = substring(@cKeyOrig, 3, 4) if @cType = 'M' and @nForPayPrev = @nForPay and @dDateTimePrintPrev = @dDateTimePrint set @cSkip = 'T' set @nForPayPrev = @nForPay set @dDateTimePrintPrev = @dDateTimePrint if @cSkip <> 'T' begin update the_setSubj set acStockManage = '0' where acSubject = @cIssuer and acStockManage = 'R' if @nChgNum > 1 OR (@nChgNum = 1 and @cType = 'M') begin exec dbo.pHE_MoveCreAll @cDocType, @cIssuer, @cReceiver, @dDate, @nUserId, @cDept, @cKey output, 'T', @cStatus output, @cError output if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, @cError) else begin update tHE_Move set adDate = @dCurrentDate, adDateVAT = @dCurrentDate, adDateInv = @dDateInv, acReceiver = @cReceiver, acIssuer = @cIssuer, acNote = acNote + 'ORIG.RA: '+ @cKeyOrig where ackey = @cKey if @cZOI <> '' update tHE_MoveFiscalisation set acKey = @cKey where acKey = @cKeyOrig end if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, @cError) else begin --KREIRANJE POZICIJ declare crItems cursor local fast_forward for select acIdent, anQty, anNo, anPrice, anRebate, anPVOCForPay, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT from #lHE_ChangedInvoicesAnalyticalItems where acKey = @cKeyOrig and ChgNum = @nChgNum and acType = @cType open crItems fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVATCode, @nVAT WHILE (@@FETCH_STATUS = 0) BEGIN if (@cSurrogateIdent <> '') and (@cUseSurrogentIdent = 'T') Set @cIdent = @cSurrogateIdent exec dbo.pHE_MoveItemsCreAll @cKey, @cIdent, @nQty, @cNote, @nUserId, @nNo output, @cError output, @cStatus output if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKeyOrig, @nNoOrig, @cIdent, @cError) else begin --UPDATE CENE, RABATA update MI Set anPrice = @nPrice, anRTPrice = @nPVOCForPay/CASE WHEN @nQty = 0 THEN 1 ELSE @nQty END, anRebate1 = @nRebate, anRebate = @nRebate, anRebate2 = 0, anRebate3 = 0, anExciseInc = @nExciseInc, anExciseIncP = @nExciseIncP, anExciseNotInc = @nExciseNotInc, anExciseNotIncP = @nExciseNotIncP, anQty = @nQty, acVATCode = @cVatCode, anVAT = @nVAT from tHE_MoveItem MI inner join tPA_SetDocType SDT on Substring(MI.acKey, 3, 4) = SDT.acDocType where ackey = @cKey and anNo = @nNo exec dbo.pHE_MoveItemOutPvItem @cKey, @nNo if @cTypeOfDoc = 'A' update MI Set anSalePrice = anPVOCForPay, anInSalePrice = anPVOCForPay from tHE_MoveItem MI where ackey = @cKey and anNo = @nNo Select @nPVOCForPay = anPVOCForPay from tHE_MoveItem where acKey = @cKey and anNo = @nNo insert into _LinksFiscItems(acKey, acKeyOrig, anUserIns, anUSerChg, adTimeIns, adTimeChg, anNoOrig, anNo, anChgNumSession, acIdent, anQty, anForPay, anRebate, anPrice) values (@cKey, @cKeyOrig, @nUserId, @nUserId, getdate(), getdate(), @nNoOrig, @nNo, @nChgNumSession, @cIdent, @nQty, @nPVOCForPay, @nRebate, @nPrice) --PRIDOBIVANJE VREDNOSTI ZA RECALC ZALOGE if (@cSurrogateIdent = '') or (@cUseSurrogentIdent = 'F') insert into #lHE_RecalcItems(acWarehouse, acIdent) values (@cIssuer, @cIdent) if exists (select acIdent from tHE_SetItem where acIdent = @cIdent and acSerialNo <> 'N') begin execute pHE_SerialNoAutoEdition '', @cIssuer, @cDocType, @cKey, @nNo, 'K', @cIdent, @nUserId, 'T', 0, @nQty, @nQtySN output, @cStatusSN output, '', '', '', 'T' if @nQty <> @nQtySN insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKey, @nNo, @cIdent, 'Izdana koliina identa in prosta koliina serijskih tevilk se ne ujemajo') end end fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVATCode, @nVAT END close crItems deallocate crItems exec dbo.pHE_MoveSetSum @cKey Select @nForPayCreated = anForPay from the_move where acKey = @cKey update the_setSubj set acStockManage = 'R' where acSubject = @cIssuer and acStockManage = '0' if @cKey <> '' begin if exists(select top 1 ackey from _linksFisc where ackey = @cKeyOrig and acKeyOrig = @cKeyOrig) update _linksFisc set acCreated = 'A' where ackey = @cKeyOrig; insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated) values (@cKey, @cKeyOrig, @cType, @nUserId, @nUserId, getdate(), getdate(), 'A', @nForPayCreated, @nChgNumSession, @cStatusDescr, 'A') end end end end if @cVATExclude = 'T' update tHE_Move set acVATExclude = 'T' where acKey = @cKey if @cFiscExclude = 'T' update tHE_Move set --adDateTimePrint = '20990101', acFiscExclude = 'T' where acKey = @cKey --KREIRANJE PLAIL if @cKey <> '' begin Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select @cKey as acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from tHE_MoveCash where acKey = @cKeyOrig and adTimeIns < @dLastCh and adTimeChg < @dLastCh if exists(Select top 1 acKey from tHE_Move_Undo where acKey = @cKeyOrig and _dl_LastCh = @dLastCh and _dl_TypeCh = 'U') begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh and adTimeIns <= @dLastCh) Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select @cKey as acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh and adTimeIns <= @dLastCh ) A where A.ChgNum = 1 end if exists(Select top 1 acKey from tHE_Move_Undo where acKey = @cKeyOrig and _dl_LastCh = @dLastCh and _dl_TypeCh = 'D') begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D' order by _dl_LastCh desc) Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select @cKey as acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh desc) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D' ) A where A.ChgNum = 1 end end set @cSkip = 'F' fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh, @dDateInv, @cTypeOfDoc END close crHeads deallocate crHeads commit transaction; set context_info @vbContextInfoOld exec [dbo].[pPA_ContextInfo_Set] 4,0 end try begin catch set @cErrorMessage = ERROR_MESSAGE() raiserror (@cErrorMessage, 16, 1); exec [dbo].[pPA_ContextInfo_Set] 4,0 rollback; end catch --PRERAUN ZALOGE NA SKLADIE in IDENT declare crRecalc cursor local for select distinct acIdent, acWarehouse from #lHE_RecalcItems open crRecalc fetch next from crRecalc into @cIdent, @cWarehouse while (@@FETCH_STATUS = 0) begin execute pPA_SerialNoStatusRecalc @cIdent, @cWarehouse, '' execute pPA_StockRecalc @cIdent, @cWarehouse fetch next from crRecalc into @cIdent, @cWarehouse end close crRecalc deallocate crRecalc update #lHE_ChangedInvoicesAnalytical set acMarked = 'F'  9999999 GMFAENF8MB*԰B windows-1250#Kreiraj storno spr in nov pravi dokF; If not object_id('tempdb..#lHE_CreationErrors') is null truncate table #lHE_CreationErrors else create table #lHE_CreationErrors( acKey varchar(13), anNo integer, acIdent varchar(16), acError varchar(max) ) If not object_id('tempdb..#lHE_RecalcItems') is null truncate table #lHE_RecalcItems else create table #lHE_RecalcItems( acWarehouse varchar(30), acIdent varchar(16), ) if not object_id('tempdb..#lHE_MoveItemStorno') is null truncate table #lHE_MoveItemStorno else create table #lHE_MoveItemStorno ( abCheck varchar(1) NULL, acKey varchar(13) NULL, anNo int NULL, acIdent char(16) NULL, acName varchar(80) NULL, anQty decimal(19,6) NULL, anPrice float NULL, anOrigQty decimal(19,6) NULL, acSerialNo char(1) NULL, anRTPrice decimal(19,6) NULL ) if not object_id('tempdb..#lHE_MoveItemStornoSerialNo') is null truncate table #lHE_MoveItemStornoSerialNo else create table #lHE_MoveItemStornoSerialNo ( abCheck varchar(1) NULL, acKey varchar(13) NULL, anNo int NULL, acIdent varchar(16) NULL, acName varchar(80) NULL, anQty decimal(19,6) NULL, acSerialNo varchar(100) NULL, adDateDue smalldatetime NULL ) if not object_id('tempdb..#lHE_MoveItemStornoKosovnica') is null truncate table #lHE_MoveItemStornoKosovnica else create table #lHE_MoveItemStornoKosovnica ( acKey varchar(13) NULL, anNo int NULL, acIdent varchar(16) NULL, anSubNo int NULL, acIdentChild varchar(16) NULL, acName varchar(80) NULL, anQty decimal(19,6) NULL, acUM varchar(3) NULL, abCheck varchar(1) NULL ) declare @cDocType Char(4), @cIssuer Char(30), @cReceiver Char(30), @dDate DateTime, @nUserId Integer, @cDept Char(30), @cKey Char(13), @cCheckAuthor Char(1) , @cStatus VarChar(2), @cError VarChar(1024), @cKeyOrig Char(13), @cType varchar(2), @cIdent varchar(16), @nQty decimal(19,6), @cNote varchar(max), @nNo integer, @nNoOrig integer, @nPrice decimal(19,6), @nRebate decimal(19,6), @cZOI varchar(100), @cErrorMessage NVarChar(4000), @nChgNum integer, @nChgNumSession integer, @vbContextInfoOld varbinary(128), @nForPay decimal(19, 6), @nForPayCreated decimal(19, 6), @nForPayPrev decimal(19, 6), @cSkip char(1), @dDateTimePrint DateTime, @dDateTimePrintPrev DateTime, @cStatusDescr varchar(100), @nPVOCForPay decimal(19,6), @cWarehouse varchar(30), @dCurrentDate datetime, @nExciseInc decimal(19,6), @nExciseIncP decimal(19,6), @nExciseNotInc decimal(19,6), @nExciseNotIncP decimal(19,6), @cVatCode varchar(2), @nVat decimal(19,6), @dLastCh datetime, @cStatusSN Char(1), @nQtySN Decimal(19,6), @cKeyStorno varchar(13), @nVATValue decimal(19,6), @nValue decimal(19,6), @nCurrValue decimal(19,6) set @nUserId = ~U~ set @cSkip = 'F' set @dCurrentDate = (SubString(Convert(Char,GetDate(),102),1,10)) begin try exec [dbo].[pPA_ContextInfo_Set] 3,1 exec [dbo].[pPA_ContextInfo_Set] 4,1 set @nChgNumSession = Cast('#lSessionId#' as integer); begin transaction /*STORNO POKVARJENEGA DOKUMENTA*/ declare crHeads cursor local fast_forward for select CIA.acKey, CIA.adDate, CIA.acIssuer, CIA.acReceiver, CIA.acDept, CIA.adDate, CIA.acType, IsNull(CIA.acZik, ''), CIA.ChgNum, CIA.anForPay, CIA.adDateTimePrint, CIA.acStatusDescr, CIA._dl_LastCh from #lHE_ChangedInvoicesAnalytical CIA where _dl_TypeCh = 'Q' and acMarked = 'T' order by CIA.acKey, CIA.ChgNum, CIA.adDateTimePrint, CIA.acStatusDescr desc open crHeads fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh WHILE (@@FETCH_STATUS = 0) BEGIN set @cStatus = '' set @cError = '' set @nForPayPrev = @nForPay select @nVATValue = anVAT, @nValue = anValue, @nCurrValue = anCurrValue from tHE_Move where acKey = @cKeyOrig update the_setSubj set acStockManage = '0' where acSubject = @cIssuer and acStockManage = 'R' /*FILL DATA FOR STORNO*/ insert into #lHE_MoveItemStorno(abCheck, acKey, anNo, acIdent, acName, anQty, anPrice, anOrigQty, acSerialNo, anRTPrice) select 'T' as abCheck, MI.ackey, MI.anNo, MI.acIdent, MI.acName, MI.anQty, MI.anPRice, MI.anQty, SI.acSerialno, MI.anRTPrice from tHE_MoveItem MI JOIN tHE_SetItem SI on MI.acIdent = SI.acIdent where MI.ackey = @cKeyOrig insert into #lHE_MoveItemStornoKosovnica(acKey, anNO, acIdent, anSubNo, acIdentChild, acName, anQty, acUM, abCheck) select MI.ackey, MI.anNo, MI.acIdent, K.anSubNo, K.acIdentChild, K.acName, K.anqty, K.acUM, 'T' as abCheck from tHE_MoveItem MI JOIN tHE_MoveItemPrSt K on MI.acKey = K.acKEy and MI.anNO = K.anNO where MI.ackey = @cKeyOrig insert into #lHE_MoveItemStornoSerialNo(acKey, anNo, acIdent, acName, anQty, acSerialNo, adDateDue, abCheck) select MI.ackey, MI.anNo, MI.acIdent, MI.acName, S.anQty, S.acSerialno, case when convert(integer, S.adDateDue) = 0 then null else S.adDateDue end as adDateDue , 'T' as abCheck from tHE_MoveItem MI JOIN tHE_MoveItemSerialNo S on MI.acKey = S.acKEy and MI.anNO = S.anNO where MI.ackey = @cKeyOrig set @cDocType = substring(@cKeyOrig, 3, 4) exec dbo.pHE_MoveStorno @cKeyOrig, @nUserID, @cDocType, '', @cKeyStorno output, @cError output, @cStatus output, 'T', 'T', 'F', 'F' delete from #lHE_MoveItemStorno if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, @cError) else begin update the_move set anValue = (-1)*@nValue, anVAT = (-1)*@nVATValue, anForPay = (-1)*@nForPayPrev, anCurrValue = (-1)* @nCurrValue where ackey = @cKeyStorno update the_setSubj set acStockManage = 'R' where acSubject = @cIssuer and acStockManage = '0' insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated) values (@cKeyStorno, @cKeyOrig, @cType, @nUserId, @nUserId, getdate(), getdate(), 'A', @nForPayCreated, @nChgNumSession, @cStatusDescr, 'A') /*END STORNO PART*/ /*CREATE NEW DOCUMENT*/ --kreiram dokument exec dbo.pHE_MoveCreAll @cDocType, @cIssuer, @cReceiver, @dDate, @nUserId, @cDept, @cKey output, 'T', @cStatus output, @cError output if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, acError) values (@cKeyOrig, @cError) --update datumov na dananji dan update tHE_Move set adDate = @dCurrentDate, adDateVAT = @dCurrentDate, acReceiver = @cReceiver, acIssuer = @cIssuer, acNote = acNote + 'ORIG.RA: '+ @cKeyOrig where ackey = @cKey --kreiranje pozicij declare crItems cursor local fast_forward for select acIdent, anQty, anNo, anPrice, anRebate, anPVOCForPay, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT from #lHE_ChangedInvoicesAnalyticalItems where acKey = @cKeyOrig and ChgNum = @nChgNum and acType = @cType open crItems fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVATCode, @nVAT WHILE (@@FETCH_STATUS = 0) BEGIN exec dbo.pHE_MoveItemsCreAll @cKey, @cIdent, @nQty, @cNote, @nUserId, @nNo output, @cError output, @cStatus output if @cStatus <> 'T' insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKeyOrig, @nNoOrig, @cIdent, @cError) else begin --UPDATE CENE, RABATA update MI Set anPrice = @nPrice, anRTPrice = @nPVOCForPay/CASE WHEN @nQty = 0 THEN 1 ELSE @nQty END, anRebate1 = @nRebate, anRebate = @nRebate, anRebate2 = 0, anRebate3 = 0, anExciseInc = @nExciseInc, anExciseIncP = @nExciseIncP, anExciseNotInc = @nExciseNotInc, anExciseNotIncP = @nExciseNotIncP, anQty = @nQty, acVATCode = @cVatCode, anVAT = @nVAT from tHE_MoveItem MI inner join tPA_SetDocType SDT on Substring(MI.acKey, 3, 4) = SDT.acDocType where ackey = @cKey and anNo = @nNo exec dbo.pHE_MoveItemOutPvItem @cKey, @nNo Select @nPVOCForPay = anPVOCForPay from tHE_MoveItem where acKey = @cKey and anNo = @nNo insert into _LinksFiscItems(acKey, acKeyOrig, anUserIns, anUSerChg, adTimeIns, adTimeChg, anNoOrig, anNo, anChgNumSession, acIdent, anQty, anForPay, anRebate, anPrice) values (@cKey, @cKeyOrig, @nUserId, @nUserId, getdate(), getdate(), @nNoOrig, @nNo, @nChgNumSession, @cIdent, @nQty, @nPVOCForPay, @nRebate, @nPrice) --PRIDOBIVANJE VREDNOSTI ZA RECALC ZALOGE insert into #lHE_RecalcItems(acWarehouse, acIdent) values (@cIssuer, @cIdent) if exists (select acIdent from tHE_SetItem where acIdent = @cIdent and acSerialNo <> 'N') begin execute pHE_SerialNoAutoEdition '', @cIssuer, @cDocType, @cKey, @nNo, 'K', @cIdent, @nUserId, 'T', 0, @nQty, @nQtySN output, @cStatusSN output, '', '', '', 'T' if @nQty <> @nQtySN insert into #lHE_CreationErrors(acKey, anNo, acIdent, acError) values (@cKey, @nNo, @cIdent, 'Izdana koliina identa in prosta koliina serijskih tevilk se ne ujemajo') end end fetch next from crItems into @cIdent, @nQty, @nNoOrig, @nPrice, @nRebate, @nPVOCForPay, @nExciseInc, @nExciseIncP, @nExciseNotInc, @nExciseNotIncP, @cVATCode, @nVAT END close crItems deallocate crItems --preraun glave exec dbo.pHE_MoveSetSum @cKey Select @nForPayCreated = anForPay from the_move where acKey = @cKey update the_setSubj set acStockManage = 'R' where acSubject = @cIssuer and acStockManage = '0' if @cKey <> '' begin insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated) values (@cKey, @cKeyOrig, @cType, @nUserId, @nUserId, getdate(), getdate(), 'A', @nForPayCreated, @nChgNumSession, @cStatusDescr, 'A') end --KREIRANJE PLAIL if @cKey <> '' begin Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select @cKey as acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from tHE_MoveCash where acKey = @cKeyOrig and adTimeIns < @dLastCh and adTimeChg < @dLastCh if exists(Select top 1 acKey from tHE_Move_Undo where acKey = @cKeyOrig and _dl_LastCh = @dLastCh and _dl_TypeCh = 'U') begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh and adTimeIns <= @dLastCh) Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select @cKey as acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh > @dLastCh and adTimeIns <= @dLastCh ) A where A.ChgNum = 1 end if exists(Select top 1 acKey from tHE_Move_Undo where acKey = @cKeyOrig and _dl_LastCh = @dLastCh and _dl_TypeCh = 'D') begin if exists(Select TOP 1 acKey from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D' order by _dl_LastCh desc) Insert into tHE_MoveCash (acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName) Select acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName from ( Select @cKey as acKey, anNo, acPayMethod, anAmount, acCurrency, anAmountCurr, acName, ROW_NUMBER() OVER(PARTITION BY acKey, anNo ORDER BY _dl_LastCh desc) as ChgNum from tHE_MoveCash_Undo where acKey = @cKeyOrig and _dl_LastCh <= @dLastCh and _dl_TypeCh = 'D' ) A where A.ChgNum = 1 end end end fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh END close crHeads deallocate crHeads commit transaction; exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 end try begin catch set @cErrorMessage = ERROR_MESSAGE() raiserror (@cErrorMessage, 16, 1); exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 rollback; end catch --PRERAUN ZALOGE NA SKLADIE in IDENT declare crRecalc cursor local for select distinct acIdent, acWarehouse from #lHE_RecalcItems open crRecalc fetch next from crRecalc into @cIdent, @cWarehouse while (@@FETCH_STATUS = 0) begin execute pPA_SerialNoStatusRecalc @cIdent, @cWarehouse, '' execute pPA_StockRecalc @cIdent, @cWarehouse fetch next from crRecalc into @cIdent, @cWarehouse end close crRecalc deallocate crRecalc update #lHE_ChangedInvoicesAnalytical set acMarked = 'F'  9999999 GMFAENF8MBrB windows-1250 Osvei marginF%DECLARE @nUserId Integer, @nMargin Float set @nUserId = ~U~ set @nMargin = #neMargin# if @nMargin > 0 set @nMargin = @nMargin/100 delete A from #lHE_ChangedInvoicesAnalyticalItems A JOIN #lHE_ChangedInvoicesAnalytical B ON A.acKey = B.acKey and B._dl_typech = 'Q' delete from #lHE_ChangedInvoicesAnalytical where _dl_typech = 'Q' --Filling document heads with missmatched heads (zero value or other) insert into #lHE_ChangedInvoicesAnalytical (acKey, acType, ChgNum, anForPay, adDateTimePrint, _dl_LastCh, _dl_LastChPrev, adDateTimePrintFiscalized, adFiscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber,_dl_TypeCh, anForPayDDVO) select ackey, actype, chgnum, anforpay, addatetimeprint, adtimechg, addatetimeprint, adFiscalDate, adFIscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber, _dl_typeCh, IsNull(anForPayDDVO,0) FROM (Select G.acKey, 'M' as acType, 1 as ChgNum, G.anForPay, G.adDateTimePrint, G.adTimeChg, F.adFiscalDate, 'Q' as acChgType, F.acZIK, F.acJIR , IsNull(ATI.acATIKey, '') as acATIKey, IsNull(LMAT.acLMATKey, '') as acLMATKey, IsNull(LMATI.acLMATIKey, '') as acLMATIKey, IsNull(LMCR.acLMCRKey, '') as acLMCRKey, '' as acStatus, '' as acStatusDescr, G.acIssuer, G.acReceiver, G.acDept, G.adDate, 'F' as acMarked, F.anFiscalNumber, 'Q' as _dl_typeCh, IsNUll(DDV.anForPayDDVO,0) as anForPayDDVO, sum(P.anPVOCForPay) as anPVOCForPay, sum(P.anPVForPay) as anPVForPay, (1-case when sum(anPVForPay) = 0 then 0 else anForPay/sum(anPVForPay) end) as anPercent, G.anRoundValue, G.anCurrValue, G.anFXRate FROM [dbo].[tHE_Move] as G INNER JOIN [dbo].[tHE_MoveItem] as P ON P.acKey = G.acKey JOIN [dbo].[tHE_MoveFiscalisation] as F ON F.acKey = G.acKey INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = G.acDocType OUTER APPLY (select TOP 1 acKey as acATIKey from tHE_AcctTransItem where acLnkKey = G.acKey) ATI OUTER APPLY (select TOP 1 acLnkKey as acLMATKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'F') LMAT OUTER APPLY (select TOP 1 acLnkKey as acLMATIKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'C') LMATI OUTER APPLY (select TOP 1 acKey as acLMCRKey from tHE_LinkMoveCashReg where acKey = G.acKey) LMCR OUTER APPLY (select sum(anField11+anField21+anField22+anField1111) as anForPayDDVO from the_vatcalclink where acKey = G.ackey)DDV WHERE G.adDateTimePrint IS NOT NULL AND G.adDate >= '20160101' AND F.acJIR <> '' group by G.acKey,G.anForPay, G.adDateTimePrint, G.adTimeChg, G.adDateTimePrint, F.adFiscalDate, F.acZIK, F.acJIR ,G.acIssuer, G.acReceiver, G.acDept, G.adDate, acATIKEy , acLMATKey, acLMATIKey, acLMCRKey, anFiscalNumber, anForpayDDVO, G.anRoundValue, G.anCurrValue, G.anFXRate ) A WHERE ((anCurrValue <> anPVOCForPay) OR (anCurrValue <> anForPay and anFXRate = 1)) and abs(anPercent) > @nMargin and ABS(anForPay - anPVForPay) > CASE WHEN A.anRoundValue < 0.01 THEN 0.01 ELSE A.anRoundValue END UNION select ackey, actype, chgnum, anforpay, addatetimeprint, adtimechg, addatetimeprint, adFiscalDate, adFIscalDate, acChgType, acZIK, acJIR, acATIKey, acLMATKey, acLMATIKey, acLMCRKey, acStatus, acStatusDescr, acIssuer, acReceiver, acDept, adDate, acMarked, anFiscalNumber, _dl_typeCh, IsNull(anForPayDDVO,0) FROM (Select G.acKey, 'M' as acType, 1 as ChgNum, G.anForPay, G.adDateTimePrint, G.adTimeChg, F.adFiscalDate, 'Q' as acChgType, F.acZIK, F.acJIR , IsNull(ATI.acATIKey, '') as acATIKey, IsNull(LMAT.acLMATKey, '') as acLMATKey, IsNull(LMATI.acLMATIKey, '') as acLMATIKey, IsNull(LMCR.acLMCRKey, '') as acLMCRKey, '' as acStatus, '' as acStatusDescr, G.acIssuer, G.acReceiver, G.acDept, G.adDate, 'F' as acMarked, F.anFiscalNumber, 'Q' as _dl_typeCh, IsNUll(DDV.anForPayDDVO,0) as anForPayDDVO, sum(P.anPVOCForPay) as anPVOCForPay FROM [dbo].[tHE_Move] as G INNER JOIN [dbo].[tHE_MoveItem] as P ON P.acKey = G.acKey JOIN [dbo].[tHE_MoveFiscalisation] as F ON F.acKey = G.acKey INNER JOIN #lHE_ValidDocTypes as vd ON vd.acDocType = G.acDocType OUTER APPLY (select TOP 1 acKey as acATIKey from tHE_AcctTransItem where acLnkKey = G.acKey) ATI OUTER APPLY (select TOP 1 acLnkKey as acLMATKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'F') LMAT OUTER APPLY (select TOP 1 acLnkKey as acLMATIKey from tHE_LinkMoveAcctTransItem where acKey = G.acKey and acType = 'C') LMATI OUTER APPLY (select TOP 1 acKey as acLMCRKey from tHE_LinkMoveCashReg where acKey = G.acKey) LMCR OUTER APPLY (select sum(anField11+anField21+anField22+anField1111) as anForPayDDVO from the_vatcalclink where acKey = G.ackey)DDV WHERE G.adDateTimePrint IS NOT NULL AND G.adDate >= '20160101' AND F.acJIR <> '' group by G.acKey,G.anForPay, G.adDateTimePrint, G.adTimeChg, G.adDateTimePrint, F.adFiscalDate, F.acZIK, F.acJIR ,G.acIssuer, G.acReceiver, G.acDept, G.adDate, acATIKEy , acLMATKey, acLMATIKey, acLMCRKey, anFiscalNumber, anForpayDDVO ) A WHERE anPVOCForPay is null and anForPay <> 0 --Filling document items with missmatched heads (zero value or other) Insert into #lHE_ChangedInvoicesAnalyticalItems (acType, acSubType, acKey, ChgNum, anNo, acIdent, acName, anQty, anPrice, anRebate, anPVOCForPay, anExciseInc, anExciseIncP, anExciseNotInc, anExciseNotIncP, acVATCode, anVAT) Select 'M', 'M', CIA.acKey, CIA.ChgNum, MIU.anNo, MIU.acIdent, MIU.acName, MIU.anQty, MIU.anPrice, MIU.anRebate, MIU.anPVOCForPay, IsNull(MIU.anExciseInc,0), IsNUll(MIU.anExciseIncP,0), IsNull(MIU.anExciseNotInc,0), IsNull(MIU.anExciseNotIncP,0), acVATCode, anVAT from #lHE_ChangedInvoicesAnalytical CIA JOIN tHE_MoveItem MIU ON CIA.acKEy = MIU.ackey WHERE CIA.acChgType = 'Q' --Filling statuses ------------------------------------------------------- Update #lHE_ChangedInvoicesAnalytical Set acStatus = CASE WHEN anForPay = 0 THEN '4' ELSE '5' END, acStatusDescr = CASE WHEN anForPay = 0 THEN 'Dokument brisanje prazni' ELSE 'Dokument brisanje' END where acChgType = 'D' Update CIA Set CIA.acStatus = '5', CIA.acStatusDescr = 'Dokument brisanje' from #lHE_ChangedInvoicesAnalytical CIA where CIA.acChgType = 'U' and exists(Select acKey from tHE_Move_Undo where acKey = CIA.acKey and _dl_TypeCh = 'D' and IsNull(adDateTimePrint, '') <> '' and _dl_LastCh >= (Select min(CIA2._dl_LastCh) from #lHE_ChangedInvoicesAnalytical CIA2 where CIA2.acKey = CIA.acKey)) Update CIA Set CIA.acStatus = '2', CIA.acStatusDescr = 'Pozicije Brisanje/Dodajanje' from #lHE_ChangedInvoicesAnalytical CIA OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh in ('U', 'D') and _dl_LastCh >= (Select min(CIA2._dl_LastCh) from #lHE_ChangedInvoicesAnalytical CIA2 where CIA2.acKey = CIA.acKey)) MU OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh = 'D' and _dl_LastCh < CIA._dl_LastCh and _dl_LastCh >= CIA._dl_LastChPrev) MU2 where acChgType = 'U' and (MU.acKEy is not null or MU2.acKey is not null) and IsNull(CIA.acStatus, '') = '' Update CIA Set acStatus = (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') = '' Update CIA Set CIA.acStatus = '3', CIA.acStatusDescr = 'Pozicije Dodajanje' from #lHE_ChangedInvoicesAnalytical CIA OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh in ('U', 'D') and _dl_LastCh >= (Select min(CIA2._dl_LastCh) from #lHE_ChangedInvoicesAnalytical CIA2 where CIA2.acKey = CIA.acKey)) MU OUTER APPLY (select acKey from tHE_MoveItem_Undo where acKey = CIA.acKey and _dl_TypeCh = 'D' and _dl_LastCh < CIA._dl_LastCh and _dl_LastCh >= CIA._dl_LastChPrev) MU2 where acChgType = 'U' and (MU.acKEy is null and MU2.acKey is null) and IsNull(CIA.acStatus, '') = '' Update CIA Set acStatus = (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') = '' Update #lHE_ChangedInvoicesAnalytical Set acStatusDescr = CASE WHEN (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) = '2' THEN 'Pozicije Brisanje/Dodajanje' WHEN (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) = '3' THEN 'Pozicije Dodajanje' WHEN (Select max(acStatus) from #lHE_ChangedInvoicesAnalytical where acKey = CIA.acKey) = '5' THEN 'Dokument brisanje' END from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') <> '' and IsNull(CIA.acStatusDescr, '') = '' Update #lHE_ChangedInvoicesAnalytical Set acStatus = '7', acStatusDescr = 'Razno' from #lHE_ChangedInvoicesAnalytical CIA where IsNull(CIA.acStatus, '') = ''  9999999 GMFAENF8MBMXB windows-1250Posodobi fiskalno stevilkoFdeclare @v_cKey varchar(13), @v_nFiscNo int set @v_cKey = '#fKey#' set @v_nFiscNo = #neFiscalNumber# exec [dbo].[pPA_ContextInfo_Set] 3,1 exec [dbo].[pPA_ContextInfo_Set] 4,1 if exists (select top 1 ackey from tHE_MoveFiscalisation where ackey = @v_cKey) begin update tHE_MoveFiscalisation set anFiscalNumber = @v_nFiscNo where ackey = @v_cKey end else begin insert into tHE_MoveFiscalisation(ackey, anFiscalNumber, acWorkPlace, acFiscalDevice, acZIk, acJIR, anUserChg, acDocType, acYearInv, adFiscalDate) select G.ackey, @v_nFiscNo, D.acWorkPlace, D.acFiscalDevice, '', '', ~U~, D.acDocType, year(G.adDate), getdate() from tHE_Move G JOIN tPA_SetDocType D on G.acDocType = D.acDocType where G.ackey = @v_cKey update tHE_Move set adDateTimePrint= getdate() where ackey = @v_cKey end exec [dbo].[pPA_ContextInfo_Set] 3,0 exec [dbo].[pPA_ContextInfo_Set] 4,0  9999999 GMFAENF8MBa+B windows-1250Poisci dokumenteFqIf not object_id('tempdb..#lHE_SearchResults') is null truncate table #lHE_SearchResults else create table #lHE_SearchResults( acKey varchar(13), adDate datetime, anValue money, anVAt money, anForPay money, acZIK varchar(100), acJIR varchar(100), anFiscalNumber int, adDateTimePrint datetime ) insert into #lHE_SearchResults(acKey, adDate, anValue, anVAT, anForPay, acZIk, acJIR, adDateTimePrint, anFiscalNUmber) select G.acKey, G.adDate, G.anValue, G.anVAT, G.anForPay, F.acZIK, F.acJIR, G.adDateTimePrint, F.anFiscalNumber from tHE_Move G left join tHE_MoveFiscalisation F on F.ackey = G.ackey join tPA_SetDocType D on D.acDocType = G.acDocType where anForPay = #neForPay# and adDate >= '2016-01-01' and D.acSetOf = 'F' and D.acType in ('I', 'M') order by G.ackey  9999999GMFAENF8MBB windows-1250Preracunaj glaveF If not object_id('tempdb..#lHE_CreationErrors') is null truncate table #lHE_CreationErrors else create table #lHE_CreationErrors( acKey varchar(13), anNo integer, acIdent varchar(16), acError varchar(max) ) declare @cDocType Char(4), @cIssuer Char(30), @cReceiver Char(30), @dDate DateTime, @nUserId Integer, @cDept Char(30), @cKey Char(13), @cCheckAuthor Char(1) , @cStatus VarChar(2), @cError VarChar(1024), @cKeyOrig Char(13), @cType varchar(2), @cIdent varchar(16), @nQty decimal(19,6), @cNote varchar(max), @nNo integer, @nNoOrig integer, @nPrice decimal(19,6), @nRebate decimal(19,6), @cZOI varchar(100), @cErrorMessage NVarChar(4000), @nChgNum integer, @nChgNumSession integer, @vbContextInfoOld varbinary(128), @nForPay decimal(19, 6), @nForPayCreated decimal(19, 6), @nForPayPrev decimal(19, 6), @cSkip char(1), @dDateTimePrint DateTime, @dDateTimePrintPrev DateTime, @cStatusDescr varchar(100), @nPVOCForPay decimal(19,6), @cWarehouse varchar(30), @dCurrentDate datetime, @nExciseInc decimal(19,6), @nExciseIncP decimal(19,6), @nExciseNotInc decimal(19,6), @nExciseNotIncP decimal(19,6), @cVatCode varchar(2), @nVat decimal(19,6), @dLastCh datetime, @cStatusSN Char(1), @nQtySN Decimal(19,6), @cKeyStorno varchar(13), @nVATValue decimal(19,6), @nValue decimal(19,6), @nCurrValue decimal(19,6) begin try exec [dbo].[pPA_ContextInfo_Set] 3,1 exec [dbo].[pPA_ContextInfo_Set] 4,1 set @nChgNumSession = Cast('#lSessionId#' as integer); begin transaction declare crHeads cursor local fast_forward for select CIA.acKey, CIA.adDate, CIA.acIssuer, CIA.acReceiver, CIA.acDept, CIA.adDate, CIA.acType, IsNull(CIA.acZik, ''), CIA.ChgNum, CIA.anForPay, CIA.adDateTimePrint, CIA.acStatusDescr, CIA._dl_LastCh from #lHE_ChangedInvoicesAnalytical CIA where _dl_TypeCh = 'Q' and acMarked = 'T' order by CIA.acKey, CIA.ChgNum, CIA.adDateTimePrint, CIA.acStatusDescr desc open crHeads fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh WHILE (@@FETCH_STATUS = 0) BEGIN set @cStatus = '' set @cError = '' exec pHE_MoveSetSum @cKeyOrig select @nForPayCreated = anForPay from the_move where acKey = @cKey insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated, acStatusCreated) values (@cKeyOrig, @cKeyOrig, @cType, @nUserId, @nUserId, getdate(), getdate(), 'A', @nForPayCreated, @nChgNumSession, @cStatusDescr, 'A', 'Potreben tehnini popravek') update #lHE_ChangedInvoicesAnalytical set acMarked = 'F', acStatusDescr = 'Vrednosti popravljene. Naredi tehnini popravek in osvei seznam.' where ackey = @cKeyOrig fetch next from crHeads into @cKeyOrig, @dDate, @cIssuer, @cReceiver, @cDept, @dDate, @cType, @cZOI, @nChgNum, @nForPay, @dDateTimePrint, @cStatusDescr, @dLastCh END close crHeads deallocate crHeads commit transaction; exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 end try begin catch set @cErrorMessage = ERROR_MESSAGE() raiserror (@cErrorMessage, 16, 1); exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 rollback; end catch 9999999GR/Poroilo o kreiranih in spremenjenih dokumentih0U3FAENF8MB B windows-1250PRN_1Fselect 1select F.acKey, F.acKeyOrig, F.acType, F.anUserIns, F.anUserChg, F.adTimeIns, F.adTimeChg, F.acCreatedType, F.anForPay, F.anChgNumSession, LTRIM(RTRIM(acStatus)) as acStatus, F.acCreated, LTRIM(RTRIM(F.acNote)) as acNote, lTRIM(RTRIM(F.acStatusCreated)) as acStatusCreated, F.anVatInCurPer, U.acUserId as acUserID, LTRIM(RTRIM(U.acName)) + ' ' + LTRIM(RTRIM(U.acSurname)) as acUserInsName from _LinksFisc F join tHE_SetSubjContact U ON F.anUserChg = U.anUserID order by F.acStatus, F.adTimeIns, F.acKey9999999GMFAENF8MBSB windows-1250Popravi valutoFIf not object_id('tempdb..#lHE_CreationErrors') is null truncate table #lHE_CreationErrors else create table #lHE_CreationErrors( acKey varchar(13), anNo integer, acIdent varchar(16), acError varchar(max) ) begin tran delete from #lHE_CreationErrors where ackey = '' and acError LIKE 'Napaka pri propravku valute%' exec [dbo].[pPA_ContextInfo_Set] 3,1 exec [dbo].[pPA_ContextInfo_Set] 4,1 begin try declare @cKey char(13) declare @nForPay money declare cFxRateFix2 cursor for select distinct acKey from #lHE_FxRateMissmatch where anSelected = 1 and isnull(acDescription, '') = '' open cFxRateFix2 fetch next from cFxRateFix2 into @cKey while @@FETCH_STATUS = 0 begin begin try set @nForPay = isnull((select anForPay from the_move where ackey = @ckey), 0) delete from #lHE_CreationErrors where ackey = @ckey and acError LIKE 'Napaka pri propravku valute%' update tHE_Move set anCurrValue = anForPay where acKey = @cKey update #lHE_FxRateMissmatch set anSelected = 0, acDescription = 'Valuta popravljena. Naredi tehnini popravek in osvei seznam.' where ackey = @cKey insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated, acStatusCreated) values (@cKey, @cKey, 'M', 0, 0, getdate(), getdate(), 'A', @nForPay, 0, 'Popravljena valuta', 'A', 'Potreben tehnini popravek') end try begin catch insert into #lHE_CreationErrors (acKey, acError) select @ckey, 'Napaka pri propravku valute: ' + ERROR_MESSAGE() end catch fetch next from cFxRateFix2 into @cKey end close cFxRateFix2; deallocate cFxRateFix2; exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 commit end try begin catch rollback insert into #lHE_CreationErrors (acKey, acError) select '', 'Napaka pri propravku valute: ' + ERROR_MESSAGE() exec [dbo].[pPA_ContextInfo_Set] 4,0 exec [dbo].[pPA_ContextInfo_Set] 3,0 end catch 9999999GMFAENF8MBUB windows-1250 Popravi valuto tehnicni popravekFinsert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated) select lf.acKey, lf.acKey, 'M', NULL, NULL, getdate(), getdate(), 'M', m.anForPay, 0, 'Tehnini popravek', 'A' from _LinksFisc as lf inner join the_move as m on m.acKey = lf.acKey LEFT JOIN _LinksFisc as lft ON lft.acKey = lf.acKey and lft.acStatus = 'Tehnini popravek' LEFT JOIN (select distinct ackey from tHE_MoveFiscalisationFix where acType = 0 and adFiscalDate is not null and isnull(acerror, '') = '') as mff on mff.acKey = lf.acKey where lf.acStatus = 'Popravljena valuta' AND lft.acKey is null AND mff.acKey is not null if @@ROWCOUNT > 0 begin update lf set acStatusCreated = '' from _LinksFisc as lf LEFT JOIN _LinksFisc as lft ON lft.acKey = lf.acKey and lft.acStatus = 'Tehnini popravek' INNER JOIN (select distinct ackey from tHE_MoveFiscalisationFix where acType = 0 and adFiscalDate is not null and isnull(acerror, '') = '') as mff on mff.acKey = lf.acKey where lf.acStatus = 'Popravljena valuta' and lft.acKey is not null and mff.acKey is not null and lf.acStatusCreated <> '' end 9999999GMFAENF8MB[UB windows-1250"Preracunaj glave tehnicni popravekFfinsert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated) select lf.acKey, lf.acKey, 'M', 0, 0, getdate(), getdate(), 'M', m.anForPay, 0, 'Tehnini popravek', 'A' from _LinksFisc as lf inner join the_move as m on m.acKey = lf.acKeyOrig LEFT JOIN _LinksFisc as lft ON lft.acKeyOrig = lf.acKeyOrig and lft.acStatus = 'Tehnini popravek' LEFT JOIN (select distinct ackey from tHE_MoveFiscalisationFix where acType = 0 and adFiscalDate is not null and isnull(acerror, '') = '') as mff on mff.acKey = lf.acKeyOrig where (lf.acStatus = 'Pozicije Dodajanje' or lf.acStatus = 'Razno') AND lft.acKey is null AND mff.acKey is not null if @@ROWCOUNT > 0 begin update lf set acStatusCreated = '' from _LinksFisc as lf LEFT JOIN _LinksFisc as lft ON lft.acKeyOrig = lf.acKeyOrig and lft.acStatus = 'Tehnini popravek' INNER JOIN (select distinct ackey from tHE_MoveFiscalisationFix where acType = 0 and adFiscalDate is not null and isnull(acerror, '') = '') as mff on mff.acKey = lf.acKeyOrig where (lf.acStatus = 'Pozicije Dodajanje' or lf.acStatus = 'Razno') and lft.acKey is not null and mff.acKey is not null and lf.acStatusCreated <> '' end 9999999GMFAENF8MB/LcXB windows-1250Refresh PAFiscDataFif not object_id('tempdb..#lHE_PAFiscData') is null drop table #lHE_PAFiscData Select Y.acKey, Y.anForPay, Y.acWorkPlace, Y.anFiscalNumber, Y.acFiscalDevice, adDateTimePrint into #lHE_PAFiscData from (Select M.acKey, M.anForPay, MF.acWorkPlace, MF.anFiscalNumber, MF.acFiscalDevice, dateadd(millisecond, -datepart(millisecond, M.addateTimePrint), M.adDateTimePrint) as adDateTimePrint from tHE_Move M left join tHE_MoveFiscalisation MF on MF.acKey = M.acKey) Y 9999999GMFAENF8MB؉XB windows-1250Remove documentF{declare @cKey Char(13), @nUserId Integer, @nForPay decimal(19,6), @nChgNumSession integer Set @cKey = '#lKeyUpd#' set @nUserId = ~U~ if @cKey <> '' begin set @nChgNumSession = Cast('#lSessionId#' as integer) Select @nForPay = anForPay from tHE_Move where acKey = @cKey insert into _LinksFisc(acKey, acKeyOrig, acType, anUserIns, anUSerChg, adTimeIns, adTimeChg, acCreatedType, anForPay, anChgNumSession, acStatus, acCreated) values (@cKey, @cKey, 'M', @nUserId, @nUserId, getdate(), getdate(), 'A', @nForPay, @nChgNumSession, 'Odstranjen', 'A') end 9999999GMFAENF8MBt 0 ROLLBACK TRANSACTION; end catch acKeyanNoanSeqNoacHField2acHType anHLengthanHDecacPField2acPTypeanPLegthanPDec acPFormat acPSeparator anUserChg anUserIns adTimeChg adTimeIns anQIdacKeyanNoanSeqNo acFieldName2 anFieldSize acFieldTitleacFieldReadOnly acEditType acFieldConst anUserChg anUserIns adTimeIns adTimeChg acFieldFormatacFieldDefault acLookupSQLanQId acKeyanNo acDataEventacDataReturnValue acKeyAndNo anUserChg anUserIns adTimeChg adTimeIns anQIdacKey acWhereKeyanNo acFieldName acParamVar acFieldType acFieldREQacFieldCaption2 acDefaultExpacDefaultValue acLookUpSQL acOperator acVarHint2 acAddApostrof anUserChg anUserIns adTimeChg adTimeIns acPrtCritanQIdanSystem acKey anVersionanNoacSQLExpacNote adTimeChg anUserChg adTimeIns anUserInsanQId*acReportacLangIdacLocalization2 acFormNamedacNamedacDefaultPrinter acPreviewanMaxPrStLevelacSubstituteSignacPrintIfEmpty acPrintToText anNoOfCopy acOrderBy acRegUserCodeacActive acKeyShortCut2 anUserIns adTimeIns anUserChg adTimeChg acText1acText2acText3acNote acReportDataacPDFPrintoptimizedanQId acPaperType2 anCanDesign anCanEdit anCanDelete anCanCopyacStoredProcedureanGFXanTXT acDocTypes adDateFrom adDateTo adTimeFrom adTimeTo anDefaultanNo0U3SI;SI;PorKreInSprDok/Poroilo o kreiranih in spremenjenih dokumentihPrivzet tiskalnikTFFFTb"B/TYB[3 Fh:acKey acUnitName acObjectName acTranslationacLocalisationanQId