2

我将我的事务添加到字典中,使用 UUID 作为键,事务对象作为值 - 这就是我所说的ledger

示例(entriesForPosting 是SetsArray中的一个,每个包含一个贷方条目和一个借方条目):

   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. 

但这会在渲染时引发错误: 在此处输入图像描述

4

2 回答 2

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. 
    
于 2013-07-09T05:20:50.050 回答
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].

如果您需要不同类型的报告,开始使用 Magritte(或 Deltawerken)是有意义的。在那里,您使用单独的对象定义字段,并告诉报告要呈现哪些字段。

于 2013-07-14T15:36:17.453 回答