我将我的事务添加到字典中,使用UUID作为键,将事务对象作为值 - 这就是我所说的ledger:
实施例(entriesForPosting是一个Set的ArrayS,各自含有信用条目和借记):
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"
Run Code Online (Sandbox Code Playgroud)
然后我们报告这个分类帐:
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.
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,这个报告没有订购.即,交易显示无序 - 我没有看到任何押韵或理由为什么他们被报告如何:
例如,
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.
Run Code Online (Sandbox Code Playgroud)
给我以下内容:

我尝试过以下方法:
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.
Run Code Online (Sandbox Code Playgroud)
但这会在渲染时抛出错误:

WAReportColumn理解#sortBlock:.该块初始化为[ :a :b | a <= b ]a和b将是glPosting我假设的一些对象.如果此排序行为不适合您,只需将不同的排序块传递给该列.
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.
Run Code Online (Sandbox Code Playgroud)