kts-component-invoice-operate 3.1.17 → 3.1.18

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.
@@ -4,6 +4,7 @@ import InvoiceController from './InvoiceController';
4
4
  import GoodsList from './ui/GoodsList';
5
5
  import Seller from './ui/Seller';
6
6
  import Buyer from './ui/Buyer';
7
+ import * as calculator from './tools/calculate';
7
8
  /** 发票组件的上下文 */
8
9
  export declare const InvoiceContext: React.Context<InvoiceController>;
9
10
  export interface IInvoiceProps {
@@ -37,6 +38,8 @@ export default class Invoice extends React.PureComponent<IInvoiceProps> {
37
38
  static readonly Buyer: typeof Buyer;
38
39
  /** 货物索引生成器 */
39
40
  static idGenerator: () => string;
41
+ /** 金额计算方法 */
42
+ static calculator: typeof calculator;
40
43
  /** 获取控制器钩子 */
41
44
  static useInvoiceController: () => InvoiceController;
42
45
  render(): JSX.Element;
@@ -31,3 +31,10 @@ export declare function countTaxAmount(amountIncludeTax: string | number, deduct
31
31
  * @returns 单价
32
32
  */
33
33
  export declare function countPrice(amount: string | number, quantity: string | number, calculatingDigits?: number): number | undefined | '';
34
+ /**
35
+ * 数量 = 金额/单价
36
+ * @param amount 金额
37
+ * @param price 单价
38
+ * @returns 数量
39
+ */
40
+ export declare function countQuantity(amount: string | number, price: string | number, calculatingDigits?: number): number | undefined | '';
package/dist/index.esm.js CHANGED
@@ -1135,6 +1135,28 @@ function countPrice(amount, quantity, calculatingDigits) {
1135
1135
  if (!quantity && quantity !== 0) return undefined;
1136
1136
  return format15(chain$1(bignumber(amount)).divide(bignumber(quantity)).done().toNumber(), calculatingDigits);
1137
1137
  }
1138
+ /**
1139
+ * 数量 = 金额/单价
1140
+ * @param amount 金额
1141
+ * @param price 单价
1142
+ * @returns 数量
1143
+ */
1144
+ function countQuantity(amount, price, calculatingDigits) {
1145
+ if (!amount && amount !== 0) return undefined;
1146
+ if (!price && price !== 0) return undefined;
1147
+ return format15(chain$1(bignumber(amount)).divide(bignumber(price)).done().toNumber(), calculatingDigits);
1148
+ }
1149
+
1150
+ var calculator = /*#__PURE__*/Object.freeze({
1151
+ __proto__: null,
1152
+ format2: format2,
1153
+ format15: format15,
1154
+ countAmountIncludeTax: countAmountIncludeTax,
1155
+ countAmountExcludeTax: countAmountExcludeTax,
1156
+ countTaxAmount: countTaxAmount,
1157
+ countPrice: countPrice,
1158
+ countQuantity: countQuantity
1159
+ });
1138
1160
 
1139
1161
  /**
1140
1162
  * 设置当前的编辑货物
@@ -12832,6 +12854,8 @@ var Invoice = /*#__PURE__*/function (_React$PureComponent) {
12832
12854
 
12833
12855
  /** 货物索引生成器 */
12834
12856
 
12857
+ /** 金额计算方法 */
12858
+
12835
12859
  /** 获取控制器钩子 */
12836
12860
 
12837
12861
  function render() {
@@ -12847,6 +12871,7 @@ Invoice.Seller = Buyer;
12847
12871
  Invoice.Sign = Sign;
12848
12872
  Invoice.Buyer = Buyer$1;
12849
12873
  Invoice.idGenerator = idGenerator;
12874
+ Invoice.calculator = calculator;
12850
12875
  Invoice.useInvoiceController = function () {
12851
12876
  return React.useContext(InvoiceContext);
12852
12877
  };
package/dist/index.js CHANGED
@@ -1145,6 +1145,28 @@ function countPrice(amount, quantity, calculatingDigits) {
1145
1145
  if (!quantity && quantity !== 0) return undefined;
1146
1146
  return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(quantity)).done().toNumber(), calculatingDigits);
1147
1147
  }
1148
+ /**
1149
+ * 数量 = 金额/单价
1150
+ * @param amount 金额
1151
+ * @param price 单价
1152
+ * @returns 数量
1153
+ */
1154
+ function countQuantity(amount, price, calculatingDigits) {
1155
+ if (!amount && amount !== 0) return undefined;
1156
+ if (!price && price !== 0) return undefined;
1157
+ return format15(mathjs.chain(mathjs.bignumber(amount)).divide(mathjs.bignumber(price)).done().toNumber(), calculatingDigits);
1158
+ }
1159
+
1160
+ var calculator = /*#__PURE__*/Object.freeze({
1161
+ __proto__: null,
1162
+ format2: format2,
1163
+ format15: format15,
1164
+ countAmountIncludeTax: countAmountIncludeTax,
1165
+ countAmountExcludeTax: countAmountExcludeTax,
1166
+ countTaxAmount: countTaxAmount,
1167
+ countPrice: countPrice,
1168
+ countQuantity: countQuantity
1169
+ });
1148
1170
 
1149
1171
  /**
1150
1172
  * 设置当前的编辑货物
@@ -12842,6 +12864,8 @@ var Invoice = /*#__PURE__*/function (_React$PureComponent) {
12842
12864
 
12843
12865
  /** 货物索引生成器 */
12844
12866
 
12867
+ /** 金额计算方法 */
12868
+
12845
12869
  /** 获取控制器钩子 */
12846
12870
 
12847
12871
  function render() {
@@ -12857,6 +12881,7 @@ Invoice.Seller = Buyer;
12857
12881
  Invoice.Sign = Sign;
12858
12882
  Invoice.Buyer = Buyer$1;
12859
12883
  Invoice.idGenerator = idGenerator;
12884
+ Invoice.calculator = calculator;
12860
12885
  Invoice.useInvoiceController = function () {
12861
12886
  return React__default['default'].useContext(InvoiceContext);
12862
12887
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.1.17",
3
+ "version": "3.1.18",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -12,6 +12,8 @@ import ImportGoodsDrawer from './ui/ImportGoodsDrawer';
12
12
  import EndowCodeDrawer from './ui/EndowCodeDrawer';
13
13
  import AddComparisonDrawer from './ui/AddComparisonDrawer';
14
14
  import idGenerator from './tools/idGenerator';
15
+ import * as calculator from './tools/calculate';
16
+
15
17
 
16
18
  /** 发票组件的上下文 */
17
19
  export const InvoiceContext = React.createContext<InvoiceController>(
@@ -63,6 +65,9 @@ export default class Invoice extends React.PureComponent<IInvoiceProps> {
63
65
  /** 货物索引生成器 */
64
66
  static idGenerator = idGenerator;
65
67
 
68
+ /** 金额计算方法 */
69
+ static calculator = calculator;
70
+
66
71
  /** 获取控制器钩子 */
67
72
  static useInvoiceController = () => { return React.useContext(InvoiceContext) };
68
73
 
@@ -92,6 +92,21 @@ export function countPrice(amount: string | number, quantity: string | number, c
92
92
  }
93
93
 
94
94
 
95
+ /**
96
+ * 数量 = 金额/单价
97
+ * @param amount 金额
98
+ * @param price 单价
99
+ * @returns 数量
100
+ */
101
+ export function countQuantity(amount: string | number, price: string | number, calculatingDigits?: number): number | undefined | '' {
102
+ if (!amount && amount !== 0) return undefined;
103
+ if (!price && price !== 0) return undefined;
104
+
105
+ return format15(chain(bignumber(amount)).divide(bignumber(price))
106
+ .done()
107
+ .toNumber(), calculatingDigits)
108
+ }
109
+
95
110
 
96
111
 
97
112