我加入我的交易,以一本字典,使用UUID作爲關鍵和交易對象的價值 - 這是我打電話給我的ledger
:Smalltalk的 - 海上活動報告
例(entriesForPosting是一個Set
Array
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.
給了我以下內容:
我已經試過如下:
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.
但是,這將引發上呈現的錯誤:
我似乎無法得到這個工作 - 請參閱我的編輯。 – MrDuk
你發現了一個非常醜陋的錯誤。你傳遞給'#renderBlock:title:'的塊有兩個參數(正如您從示例中正確收集的那樣)。但是'WAReportColumn'會用**只有一個**參數來調用該塊。這裏沒有快速解決方案。我的建議是引入一個名爲'renderBlock'的新實例變量,並使用不同的'valueBlock'。你可以初始化'valueBlock'到'[:row |行]'和'renderBlock'到'[:row:html | html render:(self valueForRow:row)asString]'。 –
感謝您的幫助!有什麼地方可以報告嗎? – MrDuk