Smalltalk-海边报道

Smalltalk-海边报道,smalltalk,seaside,Smalltalk,Seaside,我将我的交易添加到字典中,使用UUID作为键,使用交易对象作为值-这就是我所说的我的分类账: 示例(entriesForPosting是一组数组s,每个数组包含一个贷方分录和一个借方分录): 然后,我们按如下方式报告此分类账: renderReport GLReport := WATableReport new rows: GeneralLedger getGLPostings asOrderedCollection ; columns: (Ordered

我将我的交易添加到字典中,使用UUID作为键,使用交易对象作为值-这就是我所说的我的
分类账

示例(entriesForPosting是一组
数组
s,每个数组包含一个贷方分录和一个借方分录):

然后,我们按如下方式报告此分类账:

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. 
但这会在渲染时引发错误:


  • WAReportColumn
    理解
    #sortBlock:
    。如果您在分类账中添加以下内容,则此块将初始化为
    [:a:b | a

    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].
    
    如果您需要不同类型的报告,那么开始使用Magritte是有意义的 (或Deltawerken)。在这里,您可以用单独的对象定义字段,然后告诉
    要呈现哪些字段的报告。

    您发现了一个非常难看的错误。您传递到
    #renderBlock:title:
    的块包含两个参数(正如您从示例中正确收集的).但是
    WAReportColumn
    将只使用一个参数调用该块。这里没有快速的解决方案。我的建议是引入一个名为
    renderBlock
    的新实例变量,并使用一个不同的
    valueBlock
    。您可以将
    valueBlock
    初始化为
    [:row | row]
    renderBlock
    [:row:html | html render:(self-valueForRow:row)asString]
    。谢谢您的帮助!有什么地方可以报告这个吗?不客气。讨论和支持的地方是海边邮件列表()。
    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].