Total Pageviews

2015/11/19

[AngularJS] Round to at most 2 decimal places in ng-grid CellFilter

Problem
I utilize ng-grid to implement the grid as bellows:

The value of 利率 has 4 decimal places, customer ask to change to 2 decimal places.
The ng-grid definition is as following:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 $scope.itemGrid = {
            multiSelect : false,
   data : 'itemData',
            showFooter : false,
            keepLastSelected: false,
   enableColumnResize: true,
            columnDefs : [ {
                field : 'fundName',
                displayName : '借入基金專戶',
                width : '21%',
                cellClass : "text-left",
                cellFilter:'dbm035eFundFilter:row.entity.toFundName : row.entity.debtType=="B"'
            }, {
                field : 'toFundName',
                displayName : '借出基金專戶',
                width : '21%',
                cellClass : "text-left",
                cellFilter:'dbm035eFundFilter:row.entity.fundName : row.entity.debtType=="B"'
            }, {
                field : 'debtDateB',
                displayName : '調借起日',
                width : '10%',
                cellClass : "text-left",
                cellFilter:"dbm035eToStringFilter|dateFilter" 
            }, {
                field : "debtDateE",
                displayName : "調借迄日",
                width : '10%',
                cellClass : "text-left",
                cellFilter:"dbm035eToStringFilter|dateFilter" 
            }, {
                field : "debtAmt",
                displayName : "調借金額",
                width : '10%',
                cellClass : "text-right",
                cellFilter:"dbm035eAmountFilter | number"
            }, {
                field : "debtRate",
                displayName : "利率",
                width : '8%',
                cellClass : "text-right"
            }, {
                field : "remark",
                displayName : "備註",
                width : '20%',
                cellClass : "text-left"
            }
   //....
 }];


How-To
Step 1. Create a cellFilter to debtRate field
1
2
3
4
5
    app.filter('dbm035eRateFilter', function() {
        return function(input) {
            return null==input?null:(Math.round(input * 100)/100);
        };
    });

Step 2. Add this cellFilter to debtRate field
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 $scope.itemGrid = {
            multiSelect : false,
   data : 'itemData',
            showFooter : false,
            keepLastSelected: false,
   enableColumnResize: true,
            columnDefs : [ {
                field : 'fundName',
                displayName : '借入基金專戶',
                width : '21%',
                cellClass : "text-left",
                cellFilter:'dbm035eFundFilter:row.entity.toFundName : row.entity.debtType=="B"'
            }, {
                field : 'toFundName',
                displayName : '借出基金專戶',
                width : '21%',
                cellClass : "text-left",
                cellFilter:'dbm035eFundFilter:row.entity.fundName : row.entity.debtType=="B"'
            }, {
                field : 'debtDateB',
                displayName : '調借起日',
                width : '10%',
                cellClass : "text-left",
                cellFilter:"dbm035eToStringFilter|dateFilter" 
            }, {
                field : "debtDateE",
                displayName : "調借迄日",
                width : '10%',
                cellClass : "text-left",
                cellFilter:"dbm035eToStringFilter|dateFilter" 
            }, {
                field : "debtAmt",
                displayName : "調借金額",
                width : '10%',
                cellClass : "text-right",
                cellFilter:"dbm035eAmountFilter | number"
            }, {
                field : "debtRate",
                displayName : "利率",
                width : '8%',
                cellClass : "text-right",
                cellFilter:"dbm035eRateFilter" 
            }, {
                field : "remark",
                displayName : "備註",
                width : '20%',
                cellClass : "text-left"
            }
   //....
 }];

Check the result


Reference
[1] http://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-in-javascript

[iReport] How to Set Line Break in Text Field

Problem
Here is my existing report design template:

You can see the report column is dynamic.
The report, with PDF format, is generating as following:

But our customer ask to set line break between 一般政府 and (基金或法人名稱).


How-To
1. Click the textfield

2. Set Markup property to styled
3. Java code should amend as bellows:
1
2
3
4
5
6
7
    Dbm037rVo header = new Dbm037rVo();
    header.setFundName("<style>公共公司<br />(基金或法人名稱)</style>");
    header.setRate1Year(Integer.toString(Integer.valueOf(accountYr) - 2).concat(" 年度(比率)"));
    header.setRate1Year(Integer.toString(Integer.valueOf(accountYr) - 1).concat(" 年度(比率)"));
    header.setRate1Year(accountYr.concat(" 年度(比率)"));
    
    result.add(header);


Reference
[1] http://www.tutorialspoint.com/jasper_reports/jasper_report_styles.htm

How to set system properties in JBoss 6.1

Problem
I'm using JBoss 6.1, how to set system properties in JBoss?

How-to
You have two approaches to do:
Approach 1: Edit standalone.xml in [JBOSS_HOME]\standalone\configuration as bellows:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?xml version='1.0' encoding='UTF-8'?>

<server xmlns="urn:jboss:domain:1.4">

    <extensions>
        <extension module="org.jboss.as.clustering.infinispan"/>
        <extension module="org.jboss.as.connector"/>
        <extension module="org.jboss.as.deployment-scanner"/>
        <extension module="org.jboss.as.ee"/>
        <extension module="org.jboss.as.ejb3"/>
        <extension module="org.jboss.as.jaxrs"/>
        <extension module="org.jboss.as.jdr"/>
        <extension module="org.jboss.as.jmx"/>
        <extension module="org.jboss.as.jpa"/>
        <extension module="org.jboss.as.jsf"/>
        <extension module="org.jboss.as.logging"/>
        <extension module="org.jboss.as.mail"/>
        <extension module="org.jboss.as.naming"/>
        <extension module="org.jboss.as.pojo"/>
        <extension module="org.jboss.as.remoting"/>
        <extension module="org.jboss.as.sar"/>
        <extension module="org.jboss.as.security"/>
        <extension module="org.jboss.as.threads"/>
        <extension module="org.jboss.as.transactions"/>
        <extension module="org.jboss.as.web"/>
        <extension module="org.jboss.as.webservices"/>
        <extension module="org.jboss.as.weld"/>
    </extensions>

    <system-properties>
        <property name="spring.profiles.active" value="INTERNET"/>
    </system-properties>
 <!--
 ................................................
 -->

</server>

Approach 2: Log into JBoss Admin console to do configuration
Step 1: Click Profile

Step 2: Click System Properties

Step 3: Click Add button

Step 4: Fill in Name and Value, then click Save button




No matter which approach you utilize, remember to RESTART JBoss after configuration.

Reference
[1] https://docs.jboss.org/author/display/AS7/Admin+Guide#AdminGuide-SystemProperties

2015/11/16

[Oracle to SQL Server Migration] ROWNUM

Problem
We used rownum = 1 in Oracle as bellows:

If we migrate to Microsoft SQL Server, how to translate it?
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
SELECT to_char(STA_DATE, 'YYYY') - 1911 ACCOUNT_YR,
       age,
       fund_id,
       (select fund_name from dbm031fa where fund_id=dbm034fa.fund_id and rownum=1) fund_name,
       mge_type,
       IN_AMT,
       OUT_AMT,
       (IN_AMT/OUT_AMT)*100 RATIO
FROM dbm034fa
WHERE to_char(STA_DATE, 'YYYY') - 1911 BETWEEN '101' AND '103'
      AND age = '379000000A'
      AND fund_id='010401C00010'
      AND mge_type='G'

How-To
We can use TOP N to fulfill this requirement.
The SQL statement will be amended as following:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
SELECT YEAR(STA_DATE) - 1911 ACCOUNT_YR,
       age,
       fund_id,
       (select TOP 1 fund_name from dbm031fa where fund_id=dbm034fa.fund_id) fund_name,
       mge_type,
       IN_AMT,
       OUT_AMT,
       (IN_AMT/OUT_AMT)*100 RATIO
FROM dbm034fa
WHERE YEAR(STA_DATE) - 1911 BETWEEN '101' AND '103'
      AND age = '379000000A'
      AND fund_id='010401C00010'
      AND mge_type='G'


Reference
[1] http://www.w3schools.com/sql/sql_top.asp
[2] https://msdn.microsoft.com/zh-tw/library/ms189463(v=sql.120).aspx

[SQL Server] Year function

Problem
Here is my table schema in Microsoft SQL Server. If I would like to retrieve an integer that represents the year of the STA_DATE (with datetime data type).


How-To
We can use YEAR function, Microsoft SQL Server build-in function, to fulfill this requirement.
SELECT sta_date,
       year(sta_date) YEAR
FROM dbm034fa

Check the result :


Reference
[1] https://msdn.microsoft.com/en-us/library/ms186313.aspx



2015/11/05

[AngularJS] How to format a number value in ng-grid cell to two decimal places?

Problem
We are using ng-grid to implement data grid as bellows:

Our customer asks the amount column should set to two decimal places (小數點第二位).
The column definitions in this ng-grid are as following:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 columnDefs : [ {
                field : 'belongFlag',
                displayName : '分類類別',
                width : '15%',
                cellClass : "text-left",
                cellFilter:'dbm034eBelongFilter:row.entity.mgeType'
            }, {
                field : "ageTypeName",
                displayName : '基金法人類別',
                width : '20%',
                cellClass : "text-left"
            }
            , {
                field : 'fundName',
                displayName : '基金法人名稱',
                width : '20%',
                cellClass : "text-left"
            }, {
                field : 'rate2Year',
                displayName : ($scope.model.year * 1 - 2) + '年度',
                width : '10%',
                cellClass : "text-right"
            }, {
                field : "rate1Year",
                displayName : ($scope.model.year * 1 - 1) + '年度',
                width : '10%',
                cellClass : "text-right"
            }, {
                field : "rate",
                displayName : ($scope.model.year * 1) + '年度',
                width : '10%',
                cellClass : "text-right"
            }, {
                field : "ageType",
                displayName : 'ageType',
                width : '0%',
                cellClass : "text-right",
                visable : false
            }
            ]


How-To
Set cellFiter to amount fields as bellows can fulfill this requirement:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 columnDefs : [ {
                field : 'belongFlag',
                displayName : '分類類別',
                width : '15%',
                cellClass : "text-left",
                cellFilter:'dbm034eBelongFilter:row.entity.mgeType'
            }, {
                field : "ageTypeName",
                displayName : '基金法人類別',
                width : '20%',
                cellClass : "text-left"
            }
            , {
                field : 'fundName',
                displayName : '基金法人名稱',
                width : '20%',
                cellClass : "text-left"
            }, {
                field : 'rate2Year',
                displayName : ($scope.model.year * 1 - 2) + '年度',
                width : '10%',
                cellClass : "text-right",
                cellFilter:'number:2'
            }, {
                field : "rate1Year",
                displayName : ($scope.model.year * 1 - 1) + '年度',
                width : '10%',
                cellClass : "text-right",
                cellFilter:'number:2'
            }, {
                field : "rate",
                displayName : ($scope.model.year * 1) + '年度',
                width : '10%',
                cellClass : "text-right",
                cellFilter:'number:2'
            }, {
                field : "ageType",
                displayName : 'ageType',
                width : '0%',
                cellClass : "text-right",
                visable : false
            }
            ]

Check the result


Reference
[1] http://stackoverflow.com/questions/30382666/how-to-format-a-number-value-in-angularjs-ui-grid-cell-to-two-decimal

2015/11/03

[iReport] How to remove extra row and column when export to excel file

Problem
When I export report with excel format via iReport/JasperReports, the excel file always has extra blank row and extra blank column as following:

User asked to remove the unnecessary row and column. 

How-to
Add two properties to this jrxml file, and set to true

1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="dbm506r1" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d1c3bf81-aa19-4e0e-ad82-0a34f472e482">
 <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
 <property name="ireport.zoom" value="1.3310000000000004"/>
 <property name="ireport.x" value="0"/>
 <property name="ireport.y" value="0"/>
 <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/>
 <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/>

Check the result:



Reference
[1] http://stackoverflow.com/questions/8354126/ireport-jasperreports-extra-row-issue

2015/11/02

[iReport] How to format numeric data with Excel exporter

Problem
We use JasperReports API to export report with xls format.
But the problem is : data is numeric type, but in formula area its has been applied 1000 separator. It is String data type, no numeric data type.

We provide List of value object for this iReport file. The attributes of value object is as bellows (amount-related attributes' data type had been set to BigDecimal):
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
@Data
public class Dbm506rVo implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    /** 年度 */
    private int year = 0;
    private String staYear = "";
    private BigDecimal gdp = BigDecimal.ZERO;
    private BigDecimal capitalAmount = BigDecimal.ZERO;
    private BigDecimal interestAmount = BigDecimal.ZERO;
    private BigDecimal yearExpend = BigDecimal.ZERO;
    private BigDecimal ttlAmt = BigDecimal.ZERO;
    private BigDecimal percentage1 = BigDecimal.ZERO;
    private BigDecimal percentage2 = BigDecimal.ZERO;
}


How-to
Set net.sf.jasperreports.export.xls.detect.cell.type to true (the default value is false) in this jrxml file.

Quote from document: Property whose value is used as default state of the IS_DETECT_CELL_TYPE export flag. Specifies whether the exporter should take into consideration the type of the original text field expressions and set the cell types and values accordingly.

1
2
3
4
5
6
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="dbm506r1" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d1c3bf81-aa19-4e0e-ad82-0a34f472e482">
 <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
 <property name="ireport.zoom" value="1.3310000000000004"/>
 <property name="ireport.x" value="0"/>
 <property name="ireport.y" value="0"/>



The problem will be solved:

Reference
[1] http://stackoverflow.com/questions/10714709/jasperreports-how-to-format-numeric-data-with-excel-exporter

How to add more spaces between radio button and its text?

Problem
Our customer asked to add more spaces between radio button and its text

Original code snippet:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<div class="row">
  <div class="col-sm-12">
      <div class="col-sm-6 ">
          <label class="control-label label-width-4 text-right">預算階段</label> 
          <input type="radio" value="P0" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusP0">
                 {{budgetStatusP0Text}}
          <input type="radio" value="P1" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusP1">
                 {{budgetStatusP1Text}}
          <input type="radio" value="F0" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusF0">
                 {{budgetStatusF0Text}}
          <input type="radio" value="F1" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusF1">
                 {{budgetStatusF1Text}}
          <input type="radio" value="F2" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusF2">
                 {{budgetStatusF2Text}}
      </div>
      
      <div class="col-sm-6 ">
      </div>
  </div>
</div>  

How-To
Modify the margin value for each input radio element.
i.e. margin:0px 0px 0px 6px;

  • top margin is 0px
  • right margin is 0px
  • bottom margin is 0px
  • left margin is 6px

Check the following updated code snippet:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<div class="row">
  <div class="col-sm-12">
      <div class="col-sm-12 ">
          <label class="control-label label-width-4 text-right">預算階段</label> 
          <input type="radio" value="P0" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusP0"
                 style="margin: 0px 0px 0px 6px">
                 {{budgetStatusP0Text}}
          <input type="radio" value="P1" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusP1"
                 style="margin: 0px 0px 0px 6px">
                 {{budgetStatusP1Text}}
          <input type="radio" value="F0" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusF0"
                 style="margin: 0px 0px 0px 6px">
                 {{budgetStatusF0Text}}
          <input type="radio" value="F1" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusF1"
                 style="margin: 0px 0px 0px 6px">
                 {{budgetStatusF1Text}}
          <input type="radio" value="F2" 
                 data-ng-model="dbm003eFormBean.budgetStatus" 
                 data-ng-hide="hideBudgetStatusF2"
                 style="margin: 0px 0px 0px 6px">
                 {{budgetStatusF2Text}}
      </div>
  </div>
</div>

Check result:


Reference
[1] http://www.w3schools.com/cssref/pr_margin.asp

2015/11/01

[閱讀筆記] The Intelligent Investor (Part 3)


  1. 與其恐懼熊市,智慧型投資者應該在熊市時,持續買進、強力買進、勇敢買進
  2. 不要想預測未來股市,你應該做的是定期定額投資,讓你的投資變成autopilot mode,你該專注的是你的long-term financial goals,而不是預測未來股市
  3. 所謂的"Performance" Funds,其投資標的聚焦於相對小型的產業,相信小型的產業會比大型的產業有較高的成長動能,冀望能打敗S&P 500指數,但是通常這類的funds的表現都只會是曇花一現
  4. 不要購買balanced funds(平衡型基金, 即股債混合型基金),其表現欠佳,若要在投資組合中投資債券,建議購買美國儲蓄債券、評等A級以上的公司債券或免稅債券等
  5. 若完全只根據其過去的表現來購買基金,那會是一件很愚蠢的事情
  6. 購買基金須注意:一般的基金並沒有做到很好的選股;基金所收取的費用越高,收益越低;當一檔基金越頻繁交易股票,其收益就會越低;高度不穩定的基金,其價格就會傾向不穩定;過去的績效,不代表未來的績效
  7. 一檔表現優異的基金,或許無法幫助你打敗大盤表現,但是至少提供你一個較為經濟的方式,幫你節省掉選股的時間,讓你的投資組合多樣化
  8. Index fund囊括市場大部份的股票,長期來說,其績效會打敗大部分的基金,交易成本也較低,唯一缺點是很無聊,你無法去吹噓你如何選股
  9. Graham 建議,每月定期定額買進index fund,經過二十年,你會發現你的績效打敗大部分的理財專家
  10. 根據研究證明,基金收取的費用越高,其未來的收益會越低。high returns只會是暫時的,但是high expenses卻是固定的
  11. 在挑選基金的時候,記得把fund expenses當作第一優先的過濾條件。未來的收益無法預測,但是fund expenses則是唯一可以預測的,故若兩個表現差不多的基金,挑選fund expenses較低的那檔基金
  12. 不要只單看過去的績效來預測未來的績效,過去的贏家常常是未來的輸家,但是過去的輸家未必會是未來的贏家。所以,挑選基金時,避免挑選績效一直表現不好,且fund expenses高於平均的基金
  13. 想要購買封閉型基金(closed-end stock funds)的投資人,必須從其他股東手中買進他的股份,而其價格的高低,就要看供需的狀況而定
  14. Graham 建議,出現以下情形時,可以考慮賣掉此檔基金:投資策略大改變(如價值型基金突然買進科技股、成長型基金突然買進保險股)、突然增加基金費用、基金公司突然頻繁的交易以及突然的不穩定的收益(如突然的巨額收益或損失)
  15. 如果你還沒準備好結婚,那你就不應該結婚。相同的,如果你還沒準備好忍受至少三年的基金低谷期,那你一開始的時候,就不應該買進基金。記住,耐性是投資人唯一且最有力量的盟友
  16. 人們希望尋求理專的理財建議來投資賺錢,是一件很天真的事情。如同商人會尋找專家或顧問來解決業務的問題,但是商人不會去問這些專家如何獲利
  17. 未來成長的潛力是由本益比來決定,本益比比風險、股利政策的評估都還要重要;然而許多分析師在進行買進股票評比時,常常只看到最近的價格,卻忽略了公司未來長期的展望
  18. 在挑選理專時,你可以問他:你如何選擇投資標的?你認為最成功的投資方法是什麼,有沒有實際的成功案例可以佐證?如果有一個投資標的持續一整年表現不佳,你會怎麼做? (當理專回答「賣出」的時候,可以跟這位理專說再見)
  19. 在挑選理專時,你可以問他:你的投資哲學是什麼?你是使用股票或是共同基金?你有使用技術分析嗎?你有使用適時進出市場法(market timing)嗎?(最後兩個問題如果至少出現一個YES,那你可以跟這位理專說NO)
  20. 理專要能告訴你完整的財務規劃,描述你未來會賺、存、花、借多少錢,以及如何幫你做投資;要提供你投資策略報告書,告訴你投資方法;要提供你資產配置計畫,詳述在不同的投資類別會放多少錢。
  21. Graham 說:我在華爾街44年的經驗與研究,無論是採用簡單的算數、基礎或高等的幾何代數,我還沒有看過對於股票價值有可靠的計算方式
  22. 若投資標的沒有多樣化,是愚蠢的行為;但若過度多樣化,也是愚蠢的行為,因其會稀釋你的獲利。一般人很難去做汰弱留強的選擇,最理想的選擇是去買total stock market index fund,你不需要選股且享有低交易成本的優勢
  23. 選股的分析動作,通常從過去績效開始研究,記住,那是過去的績效,不代表未來就會跟過去的績效一樣(持續成長)。畢竟,未來一定會有各種有別於過去的新的競爭,在在影響著企業的獲利、穩定與成長。
  24. 根據歷史資料顯示,快速成長的公司,容易過熱和消失不見。每年稅後盈餘成長約6~7%的公司(溫和且穩定地成長),反而存活比較久
  25. Graham認為,選股五大要素包含:公司的長期展望、公司管理的品質、公司的財務強度與資本結構、每年的股利分配記錄以及股息率(殖利率)
  26. 積極型投資者於選股前,至少要去下載近五年的財報,了解公司成長動能從哪來?公司過去與未來的獲利從哪來?
  27. 要注意OPM(Other People's Money)的公司,其獲利來源不是來自本業,而是來自投資活動,這類公司不會存活太久。其可從現金流量表看出,若營運活動的現金流入為負,主要現金流入是靠投資活動,即為OPM addict公司
  28. Graham認為,好的企業的定義是:產生的現金大於支出。企業管理者持續尋找方法來有效運用現金。長期來說,不管股票市場怎麼變動,符合此定義的企業,其企業價值一定會持續成長
  29. 公司會計相當狡猾,所以安全分析相當複雜,股票價值分析只有在特殊案例才會是可靠的。對於大部分的投資人來說,能做的是在適當的價格買入,然後長久持有。
  30. 資本支出是讓經營者讓企業成長的更大更好的基本工具。會計法允許經營者將營運成本轉換成資本支出,一些不肖的公司會用此美化公司營收。智慧型投資者,應該去了解公司的資本使用狀況