sbd-npm 1.3.50 → 1.3.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/stock_basics.js +20 -20
  3. package/util.js +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.3.50",
3
+ "version": "1.3.51",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -28,7 +28,7 @@ let Stock = {
28
28
  hist_start_date: "",
29
29
  hist_end_date: "",
30
30
  data: {},
31
- profit_data: [], // 盈利数据
31
+ income_statement_data: [], // 利润表数据
32
32
 
33
33
  fetch_data: function () {
34
34
  let active_div = localStorage[Stock.tab_token];
@@ -604,23 +604,19 @@ let Stock = {
604
604
  Util.init_table_skeleton({
605
605
  "element_id": "profit_table",
606
606
  "head_cols": [
607
- {"name": "年份季度"},
607
+ {"name": "年份-季度"},
608
608
  {"name": "净利率(%)"},
609
609
  {"name": "毛利率"},
610
610
  {"name": "EPS", "tooltip": "每股收益(Earnings Per Share)"},
611
611
  {"name": "ROE", "tooltip": "净资产收益率(Return On Equity)"},
612
612
  {"name": "营业收入"},
613
613
  {"name": "净利润"},
614
- {"name": "每股主营业务收入"},
614
+ {"name": "扣非净利润"},
615
615
  ]
616
616
  });
617
617
  Util.post("/stock/" + Stock["code"], {action: "finance"}, function (j) {
618
- // 现金流
619
- let _html = [];
620
- let total_ncf_from_oa = 0;
621
- let total_cash_paid_for_assets = 0;
622
- let total_free_cash_flow = 0;
623
- let total_ncf_from_fa = 0;
618
+ // 现金流量表
619
+ let _html = [], total_ncf_from_oa = 0, total_cash_paid_for_assets = 0, total_free_cash_flow = 0, total_ncf_from_fa = 0;
624
620
  j["cash_flow_data"].forEach(function (item) {
625
621
  total_ncf_from_oa += item["ncf_from_oa"];
626
622
  total_cash_paid_for_assets += item["cash_paid_for_assets"];
@@ -641,7 +637,7 @@ let Stock = {
641
637
  total_ncf_from_fa = total_ncf_from_fa >= 0 ? (Util.to_hundred_million(total_ncf_from_fa) + "亿") : ("<b class='text-danger'>" + Util.to_hundred_million(total_ncf_from_fa) + "亿</b>");
642
638
  _html.push("<tr><td>总计</td><td>" + total_ncf_from_oa + "</td><td>" + total_cash_paid_for_assets + "</td><td>" + total_free_cash_flow + "</td><td>" + total_ncf_from_fa + "</td></tr>");
643
639
  Util.render_table_html("cash_flow_table_body", _html);
644
- // 资产负债
640
+ // 资产负债表
645
641
  _html = [];
646
642
  j["assets_liabilities_data"].forEach(function (item) {
647
643
  let net_assets = item["total_assets"] - item["total_liabilities"];
@@ -675,30 +671,34 @@ let Stock = {
675
671
  _html.push("</tr>");
676
672
  });
677
673
  Util.render_table_html("assets_liabilities_table_body", _html);
678
- Stock.profit_data = j["profit_data"];
679
- Stock.render_profit_data();
674
+ Stock.income_statement_data = j["income_statement_data"] ? j["income_statement_data"] : [];
675
+ Stock.render_income_statement_data();
680
676
  $("#quarter").change(function () {
681
- Stock.render_profit_data();
677
+ Stock.render_income_statement_data();
682
678
  });
683
679
  Util.hide_tips();
684
680
  });
685
681
  },
686
682
 
687
- render_profit_data: function () {
683
+ /**
684
+ * 利润表
685
+ */
686
+ render_income_statement_data: function () {
688
687
  let _html = [];
689
688
  let quarter = parseInt($("#quarter").val());
690
- Stock["profit_data"].forEach(function (item) {
689
+ Stock["income_statement_data"].forEach(function (item) {
690
+ item["quarter"] = Util.get_quarter(item["date"]);
691
691
  if (quarter === 0 || quarter === item["quarter"]) {
692
692
  let tr_cls = (quarter === 0 && item["quarter"] === 4) ? "success" : "";
693
693
  _html.push("<tr class='", tr_cls, "'>");
694
- _html.push("<td>", item["year"], "-", item["quarter"], "</td>");
695
- _html.push("<td>", item["net_profit_ratio"], "</td>");
694
+ _html.push("<td>", Util.get_year(item["date"]), "-", item["quarter"], "</td>");
695
+ _html.push("<td>", item["net_profit_rate"], "%</td>");
696
696
  _html.push("<td>", Util.to_float(item["gross_profit_rate"], 2), "%</td>");
697
697
  _html.push("<td>", Util.to_float(item["eps"], 2), "元</td>");
698
698
  _html.push("<td>", item["roe"], "%</td>");
699
- _html.push("<td>", Util.to_unit(item["business_income"] * 1000000), "</td>");
700
- _html.push("<td>", Util.to_unit(item["net_profits"] * 1000000, 3), "</td>");
701
- _html.push("<td>", Util.to_float(item["bips"], 2), "元</td>");
699
+ _html.push("<td>", Util.to_unit(item["total_revenue"], 3), "</td>");
700
+ _html.push("<td>", Util.to_unit(item["net_profit"], 3), "</td>");
701
+ _html.push("<td>", Util.to_unit(item["adjusted_net_profit"], 3), "</td>");
702
702
  _html.push("</tr>");
703
703
  }
704
704
  });
package/util.js CHANGED
@@ -1791,6 +1791,24 @@ const Util = {
1791
1791
  return Util.format_to_second(year + "-01-01");
1792
1792
  },
1793
1793
 
1794
+ /**
1795
+ * 获取是哪个季度
1796
+ * @param seconds
1797
+ * @returns {*|number}
1798
+ */
1799
+ get_quarter: function(seconds = 0) {
1800
+ seconds = seconds > 0 ? seconds : Util.now();
1801
+ let month = Util.get_month(seconds);
1802
+ if (month >= 1 && month <= 3) {
1803
+ return 1;
1804
+ } else if (month >= 4 && month <= 6) {
1805
+ return 2;
1806
+ } else if (month >= 7 && month <= 9) {
1807
+ return 3;
1808
+ }
1809
+ return 4;
1810
+ },
1811
+
1794
1812
  /**
1795
1813
  * 一周的哪一天(1-7,星期一:1,星期二:2,...星期日:7)
1796
1814
  * @returns {*|number}