2013-07-09 33 views
2

我加入我的交易,以一本字典,使用UUID作爲關鍵和交易對象的價值 - 這是我打電話給我的ledgerSmalltalk的 - 海上活動報告

例(entriesForPosting是一個SetArray S,每個包含貸記和借記):

postToGL 
    entriesForPosting do: [ :ea | GeneralLedger ledger at: (ea at: 1) mUID put: (ea at: 1). "credit" 
            GeneralLedger ledger at:(ea at: 2) mUID put: (ea at: 2) ]. "debit" 

然後我們報告這個賬是這樣的:

renderReport 
    GLReport := WATableReport new 
     rows: GeneralLedger getGLPostings asOrderedCollection ; 
     columns: (OrderedCollection new 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: each ] 
       title: 'ID'); 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: (GeneralLedger getTransactionByID: each) mDate ] 
       title: 'Transaction Date'); 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: (GeneralLedger getTransactionByID: each) mAmount ] 
       title: 'Amount'); 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: ((GeneralLedger getTransactionByID: each) mGLAC mAccountCode)] 
       title: 'GLAC'); 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: ((GeneralLedger getTransactionByID: each) mFund mFundCode)] 
       title: 'Fund'); 
      yourself); 
     rowColors: #(lightblue lightyellow); 
     rowPeriod: 1; 
     yourself. 

我遇到的問題是,此報告沒有訂購。即,交易顯示出的順序 - 我看不出有任何韻或理由,爲什麼他們報告說,他們是如何:

例如,

spndMgr buildTransactionFor: 100 against: someGLAC. 
spndMgr buildTransactionFor: 110 against: someGLAC. 
spndMgr buildTransactionFor: 120 against: someGLAC. 
spndMgr buildTransactionFor: 130 against: someGLAC. 
spndMgr buildTransactionFor: 140 against: someGLAC. 
spndMgr buildTransactionFor: 150 against: someGLAC. 
spndMgr buildTransactionFor: 160 against: someGLAC. 
spndMgr buildTransactionFor: 170 against: someGLAC. 
spndMgr buildTransactionFor: 180 against: someGLAC. 
spndMgr buildTransactionFor: 190 against: someGLAC. 
spndMgr buildTransactionFor: 200 against: someGLAC. 
spndMgr postTransactions. 

給了我以下內容: enter image description here


我已經試過如下:

renderReport 
    |columnToSortBy| 

    GLReport := WATableReport new 
     rows: GeneralLedger getGLPostings asOrderedCollection ; 
     columns: (OrderedCollection new 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: (GeneralLedger getTransactionByID: each) mIdentity ] 
       title: 'Identity'); 
      add: (columnToSortBy := (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: (GeneralLedger getTransactionByID: each) mDate ] 
       title: 'Transaction Date'));    
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: (GeneralLedger getTransactionByID: each) mAmount ] 
       title: 'Amount'); 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: ((GeneralLedger getTransactionByID: each) mGLAC mAccountCode)] 
       title: 'GLAC'); 
      add: (WAReportColumn 
       renderBlock: [ :each :html | html emphasis: ((GeneralLedger getTransactionByID: each) mFund mFundCode)] 
       title: 'Fund'); 
      yourself); 
     rowColors: #(lightblue lightyellow); 
     rowPeriod: 1; 
     sortColumn: columnToSortBy; 
     yourself. 

但是,這將引發上呈現的錯誤: enter image description here

回答

5
  1. WAReportColumn理解#sortBlock:。該塊初始化爲[ :a :b | a <= b ],其中a和b將是我假設的某些glPosting對象。如果這種排序行爲不適合您,只需將不同的排序塊傳遞給列。

  2. WAReportTable瞭解#sortColumn:。通過列你希望有默認排序像這樣:

    ... 
    add: (columnToSortBy := (WAReportColumn 
        renderBlock: [ :each :html | html emphasis: (GeneralLedger getTransactionByID: each) mAmount ] 
        title: 'Amount'; 
        yourself)); 
    ... 
    rowColors: #(lightblue lightyellow); 
    rowPeriod: 1; 
    sortColumn: columnToSortBy; 
    yourself. 
    
+0

我似乎無法得到這個工作 - 請參閱我的編輯。 – MrDuk

+1

你發現了一個非常醜陋的錯誤。你傳遞給'#renderBlock:title:'的塊有兩個參數(正如您從示例中正確收集的那樣)。但是'WAReportColumn'會用**只有一個**參數來調用該塊。這裏沒有快速解決方案。我的建議是引入一個名爲'renderBlock'的新實例變量,並使用不同的'valueBlock'。你可以初始化'valueBlock'到'[:row |行]'和'renderBlock'到'[:row:html | html render:(self valueForRow:row)asString]'。 –

+0

感謝您的幫助!有什麼地方可以報告嗎? – MrDuk

1

如果添加類似以下內容到你的賬,

GeneralLedger>>columnDescriptions 
    ^#('Transaction Date' #(mDate) 
     'Amount' #(mAmount) 
     'GLAC' #(mGlac mAccountCode) 
     'Fund' #(mFund mFundCode)) 

你可以建立你的報告中列這樣的

ledger columnDescriptions pairsDo: [ :title :accessorCollection | |column| 
    column := WAReportColumn new 
     title: title; 
     renderBlock: [:each :html | |temp| 
      temp := GeneralLedger getTransactionById: each. 
      accessorCollection do: [ :accessor | 
       temp := temp perform: accessor ]. 
      html emphasis: temp]; 
     yourself. 
    report columns add: column]. 

如果你需要不同類型的報告,它是有道理的開始使用馬格利特 (或Deltawerken)。在那裏你可以用不同的對象來定義字段,並告訴 報告要渲染的字段。