kts-component-invoice-operate 1.2.20 → 1.2.21
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.
- package/dist/index.esm.js +80 -98
- package/dist/index.js +80 -98
- package/docs/index.md +2 -2
- package/docs-dist/umi.js +1 -1
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +1 -1
- package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +4 -3
- package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +6 -24
- package/src/Invoice/ui/GoodsList/ui/AddDiscountRowButton/index.tsx +6 -16
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ import { chain, bignumber } from 'mathjs';
|
|
|
12
12
|
import { InvoiceControllerState } from '../';
|
|
13
13
|
import LineAttributeType from '../InvoiceControllerState/GoodsListState/LineAttributeType';
|
|
14
14
|
import idGenerator from '../../tools/idGenerator';
|
|
15
|
+
import { format2 } from '../../../Invoice/tools/calculate';
|
|
15
16
|
|
|
16
17
|
export interface IOptions {
|
|
17
18
|
/** 需要添加的 索引列表 */
|
|
@@ -29,7 +30,7 @@ export interface IOptions {
|
|
|
29
30
|
*/
|
|
30
31
|
export default async (state: InvoiceControllerState, options?: IOptions) => {
|
|
31
32
|
if (!options) return;
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
const { indexList = [] } = options;
|
|
34
35
|
const discount = chain(bignumber(options.discount || 0)).dotDivide(bignumber(100)).done();
|
|
35
36
|
const goodsMap = state.goodsListState.goodsMap;
|
|
@@ -89,9 +90,9 @@ export default async (state: InvoiceControllerState, options?: IOptions) => {
|
|
|
89
90
|
amountSum = amountSum.add(bignumber(lineAmountExcludeTax));
|
|
90
91
|
|
|
91
92
|
/** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
|
|
92
|
-
lineAmountIncludeTax = chain(bignumber(lineAmountExcludeTax))
|
|
93
|
+
lineAmountIncludeTax = format2(chain(bignumber(lineAmountExcludeTax))
|
|
93
94
|
.multiply(chain(bignumber(1)).add(taxRate).done())
|
|
94
|
-
.done().toNumber()
|
|
95
|
+
.done().toNumber()) as number
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
/** 税额 */
|
|
@@ -291,6 +291,12 @@ export function dutyFree(controller: InvoiceController, taxRate: number, form: W
|
|
|
291
291
|
const invoiceType = controller.state.invoiceType;
|
|
292
292
|
|
|
293
293
|
// 4月1日至12月31日
|
|
294
|
+
console.log('===> 小规模纳税人免税逻辑');
|
|
295
|
+
console.log('===> invoiceType', invoiceType);
|
|
296
|
+
console.log('===> en', controller.state.en);
|
|
297
|
+
console.log('===> taxRate', taxRate);
|
|
298
|
+
console.log('===> state', controller.state);
|
|
299
|
+
|
|
294
300
|
if (moment().valueOf() > moment('2022-12-31 23:59').valueOf()) return taxRate;
|
|
295
301
|
if (controller.state.en !== '08') return taxRate;
|
|
296
302
|
if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
|
|
@@ -304,30 +310,6 @@ export function dutyFree(controller: InvoiceController, taxRate: number, form: W
|
|
|
304
310
|
form.setFieldsValue({ taxRate: 0 });
|
|
305
311
|
return 0;
|
|
306
312
|
}
|
|
307
|
-
|
|
308
|
-
// 选择的 1或者3
|
|
309
|
-
// if (taxRate === 1 || taxRate === 3) {
|
|
310
|
-
// 是否处理过
|
|
311
|
-
// if (cache[record.$index]) {
|
|
312
|
-
// return taxRate;
|
|
313
|
-
// } else {
|
|
314
|
-
// cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark,taxFreeType:record.taxFreeType }
|
|
315
|
-
// record.favouredPolicyName = '免税';
|
|
316
|
-
// record.taxRate = 0;
|
|
317
|
-
// record.favouredPolicyMark = 1;
|
|
318
|
-
// record.taxFreeType = 1 as any;
|
|
319
|
-
// form.setFieldsValue({ taxRate: 0 });
|
|
320
|
-
// return 0;
|
|
321
|
-
// }
|
|
322
|
-
// } else {
|
|
323
|
-
// if (cache[record.$index] && cache[record.$index] !== true) {
|
|
324
|
-
// record.favouredPolicyName = cache[record.$index].favouredPolicyName;
|
|
325
|
-
// record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
|
|
326
|
-
// record.taxFreeType = cache[record.$index].taxFreeType;
|
|
327
|
-
// cache[record.$index] = true;
|
|
328
|
-
// }
|
|
329
|
-
// return taxRate;
|
|
330
|
-
// }
|
|
331
313
|
}
|
|
332
314
|
|
|
333
315
|
/** 含税 => 更新(不含税) */
|
|
@@ -139,9 +139,7 @@ const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
|
|
|
139
139
|
|
|
140
140
|
/** 关闭抽屉 */
|
|
141
141
|
const onClose = React.useCallback(() => {
|
|
142
|
-
controller.pipeline(async (s) => {
|
|
143
|
-
s.goodsListState.discountGoodIndex = [];
|
|
144
|
-
})();
|
|
142
|
+
controller.pipeline(async (s) => { s.goodsListState.discountGoodIndex = [] })();
|
|
145
143
|
}, []);
|
|
146
144
|
|
|
147
145
|
/** 点击了保存 */
|
|
@@ -151,9 +149,7 @@ const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
|
|
|
151
149
|
const discolineAmountunt = parseFloat(parseFloat(values.discolineAmountunt).toFixed(2));
|
|
152
150
|
const discount = parseFloat(parseFloat(values.discount).toFixed(4));
|
|
153
151
|
const indexList = discountGoodIndex;
|
|
154
|
-
controller.pipeline(async s => {
|
|
155
|
-
s.goodsListState.discountGoodIndex = [];
|
|
156
|
-
})();
|
|
152
|
+
controller.pipeline(async s => { s.goodsListState.discountGoodIndex = []; })();
|
|
157
153
|
controller.addGoodDiscount({ indexList, discount, discolineAmountunt });
|
|
158
154
|
});
|
|
159
155
|
}, [controller, form, discountGoodIndex]);
|
|
@@ -163,26 +159,20 @@ const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
|
|
|
163
159
|
lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
164
160
|
form.validateFields((err, values) => {
|
|
165
161
|
if (err && err.discount) return;
|
|
166
|
-
const discolineAmountunt = evaluate(
|
|
167
|
-
`${lineAmountSum} * (${values.discount}/100)`,
|
|
168
|
-
).toFixed(2);
|
|
162
|
+
const discolineAmountunt = evaluate(`${lineAmountSum} * (${values.discount}/100)`).toFixed(2);
|
|
169
163
|
form.setFieldsValue({ discolineAmountunt });
|
|
170
164
|
});
|
|
171
165
|
}, 300),
|
|
172
166
|
[form, lineAmountSum],
|
|
173
167
|
);
|
|
174
168
|
|
|
175
|
-
/**
|
|
169
|
+
/** 折扣变化 */
|
|
176
170
|
const onChangeDiscolineAmountunt = React.useCallback(
|
|
177
171
|
lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
178
172
|
form.validateFields((err, values) => {
|
|
179
173
|
if (err && err.discolineAmountunt) return;
|
|
180
|
-
const discolineAmountunt = parseFloat(
|
|
181
|
-
|
|
182
|
-
).toFixed(2);
|
|
183
|
-
const discount = evaluate(
|
|
184
|
-
`(${discolineAmountunt} / ${lineAmountSum}) * 100`,
|
|
185
|
-
).toFixed(4);
|
|
174
|
+
const discolineAmountunt = parseFloat(values.discolineAmountunt).toFixed(2);
|
|
175
|
+
const discount = evaluate(`(${discolineAmountunt} / ${lineAmountSum}) * 100`).toFixed(4);
|
|
186
176
|
form.setFieldsValue({ discount });
|
|
187
177
|
});
|
|
188
178
|
}, 300),
|