/*
Tworzenie nowego typu dokuemntu
*/

begin transaction  



/*
Kroki
1. Kopiowanie z istniejacego typu dokumentu
2. kopiowanie wydruków
3. zmaina nazwy
4. w aplikacji musi byc wyczyszczony cache zeby bylo widoczne 
  - system > reset cache


*/

insert into [document].[documentType]
(
[documentType], [description], [componentName], [baseDocumentType], [displayOrder], [documentCategory], [correctiveDocumentType], [cooperationDocumentType], [includeInProductionPlan], [isForeignDocument], [isProforma], [isAdvanceInvoice], [forAgreement], 
--[fullTextID], 
[outcomeDocumentType], [createOutcomeDefault], [accountingTYPE], [accountingRegister], [masterDocumentCategory], [realizeOrder], [isExportDocument], [isEUnionDocument], [isServiceDocument], [printoutDescription], [printoutExportDescription], [isInventoryRelated], [altersLastPrice], [calculateSysNetValueFromHeader], [hideFirm], [calculationType], [fiscalDocumentType], [jpkTag]
)

SELECT 'GM'
      ,[description]
      ,[componentName]
      ,[baseDocumentType]
      ,[displayOrder]
      ,[documentCategory]
      ,[correctiveDocumentType]
      ,[cooperationDocumentType]
      ,[includeInProductionPlan]
      ,[isForeignDocument]
      ,[isProforma]
      ,[isAdvanceInvoice]
      ,[forAgreement]
     -- ,[fullTextID]
      ,[outcomeDocumentType]
      ,[createOutcomeDefault]
      ,[accountingTYPE]
      ,[accountingRegister]
      ,[masterDocumentCategory]
      ,[realizeOrder]
      ,[isExportDocument]
      ,[isEUnionDocument]
      ,[isServiceDocument]
      ,[printoutDescription]
      ,[printoutExportDescription]
      ,[isInventoryRelated]
      ,[altersLastPrice]
      ,[calculateSysNetValueFromHeader]
      ,[hideFirm]
      ,[calculationType]
      ,[fiscalDocumentType]
      ,[jpkTag]
  FROM [document].[documentType]
WHERE (documentType = 'pe') AND (componentName = 'commisionservice')
  
  
  
/*wydruki*/

insert into  [configuration].[printout]
(
[documentType], [printoutName], [template], [componentName], [isDefault], [printoutHeader], [printoutFooter], [printoutLogo], [printoutFilters], [test], [contentType], [onClickHandler], [reportFooter], [printOrder], [permission]
)

SELECT 'GM'
      ,[printoutName]
      ,[template]
      ,[componentName]
      ,[isDefault]
      ,[printoutHeader]
      ,[printoutFooter]
      ,[printoutLogo]
      ,[printoutFilters]
      ,[test]
      ,[contentType]
      ,[onClickHandler]
      ,[reportFooter]
      ,[printOrder]
      ,[permission]
  FROM [configuration].[printout]
  where  (documentType = 'pe') AND (componentName = 'commisionservice')


/*nazwa*/
ROLLBACK TRANSACTION