簡體   English   中英

Smalltalk-海邊報告

[英]Smalltalk - Seaside Reporting

我將交易添加到字典中,使用UUID作為鍵,使用交易對象作為值-這就是我所說的ledger

示例(entriesForPosting是一Set Array ,每個Array都包含貸方條目和借方條目):

   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. 

但這在渲染時引發錯誤: 在此處輸入圖片說明

  1. WAReportColumn理解#sortBlock: 該塊初始化為[ :a :b | a <= b ] [ :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. 

如果您將以下內容添加到分類帳中,

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)。 在這里,您可以使用單獨的對象定義字段,然后僅告訴報告要呈現的字段。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM