payment-kit 1.13.241 → 1.13.243

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.
@@ -154,8 +154,8 @@ export function createUsageRecordQueryFn(doc?: Subscription) {
154
154
  where: {
155
155
  subscription_item_id: query.subscription_item_id,
156
156
  timestamp: {
157
- [Op.gte]: query.start || subscription.current_period_start,
158
- [Op.lt]: query.end || subscription.current_period_end,
157
+ [Op.gt]: query.start || subscription.current_period_start,
158
+ [Op.lte]: query.end || subscription.current_period_end,
159
159
  },
160
160
  },
161
161
  order: [['created_at', 'ASC']],
@@ -112,8 +112,8 @@ export class UsageRecord extends Model<InferAttributes<UsageRecord>, InferCreati
112
112
  subscription_item_id: id,
113
113
  billed: false,
114
114
  timestamp: {
115
- [Op.gte]: start,
116
- [Op.lt]: end,
115
+ [Op.gt]: start,
116
+ [Op.lte]: end,
117
117
  },
118
118
  },
119
119
  order: [['timestamp', 'DESC']],
package/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.13.241
17
+ version: 1.13.243
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.13.241",
3
+ "version": "1.13.243",
4
4
  "scripts": {
5
5
  "dev": "cross-env COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev --open",
6
6
  "eject": "vite eject",
@@ -51,10 +51,10 @@
51
51
  "@arcblock/ux": "^2.9.77",
52
52
  "@arcblock/validator": "^1.18.116",
53
53
  "@blocklet/logger": "1.16.26",
54
- "@blocklet/payment-react": "1.13.241",
54
+ "@blocklet/payment-react": "1.13.243",
55
55
  "@blocklet/sdk": "1.16.26",
56
56
  "@blocklet/ui-react": "^2.9.77",
57
- "@blocklet/uploader": "^0.1.2",
57
+ "@blocklet/uploader": "^0.1.6",
58
58
  "@mui/icons-material": "^5.15.16",
59
59
  "@mui/lab": "^5.0.0-alpha.170",
60
60
  "@mui/material": "^5.15.16",
@@ -116,7 +116,7 @@
116
116
  "devDependencies": {
117
117
  "@abtnode/types": "1.16.26",
118
118
  "@arcblock/eslint-config-ts": "^0.3.0",
119
- "@blocklet/payment-types": "1.13.241",
119
+ "@blocklet/payment-types": "1.13.243",
120
120
  "@types/cookie-parser": "^1.4.7",
121
121
  "@types/cors": "^2.8.17",
122
122
  "@types/dotenv-flow": "^3.3.3",
@@ -155,5 +155,5 @@
155
155
  "parser": "typescript"
156
156
  }
157
157
  },
158
- "gitHead": "f6d0bd360dc5783230fdc3d1197663a76a837797"
158
+ "gitHead": "b699d54327e794d3b63e5c217ba5cddf759187b7"
159
159
  }
@@ -211,8 +211,8 @@ export default function InvoiceTable({ invoice, simple }: Props) {
211
211
  subscriptionId={state.subscriptionId}
212
212
  id={state.subscriptionItemId}
213
213
  onConfirm={onCloseUsageRecords}
214
- start={invoice.period_start}
215
- end={invoice.period_end}
214
+ start={invoice.metadata?.usage_start || invoice.period_start}
215
+ end={invoice.metadata?.usage_end || invoice.period_end}
216
216
  />
217
217
  )}
218
218
  </Box>
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable react/require-default-props */
2
+ import Empty from '@arcblock/ux/lib/Empty';
2
3
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
4
  import { ConfirmDialog, api } from '@blocklet/payment-react';
4
5
  import type { TUsageRecord } from '@blocklet/payment-types';
@@ -82,24 +83,32 @@ export function UsageRecordDialog({
82
83
  <ConfirmDialog
83
84
  title={t('admin.subscription.usage.current')}
84
85
  message={
85
- <BarChart
86
- width={480}
87
- height={240}
88
- data={data.list.map((item) => ({
89
- ...item,
90
- date: new Date(item.timestamp * 1000).toLocaleString(),
91
- }))}
92
- margin={{
93
- top: 5,
94
- right: 5,
95
- left: 0,
96
- bottom: 5,
97
- }}>
98
- <Tooltip />
99
- <Bar dataKey="quantity" fill={colors.normal} activeBar={<Rectangle fill={colors.active} strokeWidth={0} />} />
100
- <XAxis dataKey="date" />
101
- <YAxis mirror />
102
- </BarChart>
86
+ data.list.length > 0 ? (
87
+ <BarChart
88
+ width={480}
89
+ height={240}
90
+ data={data.list.map((item) => ({
91
+ ...item,
92
+ date: new Date(item.timestamp * 1000).toLocaleString(),
93
+ }))}
94
+ margin={{
95
+ top: 5,
96
+ right: 5,
97
+ left: 0,
98
+ bottom: 5,
99
+ }}>
100
+ <Tooltip />
101
+ <Bar
102
+ dataKey="quantity"
103
+ fill={colors.normal}
104
+ activeBar={<Rectangle fill={colors.active} strokeWidth={0} />}
105
+ />
106
+ <XAxis dataKey="date" />
107
+ <YAxis mirror />
108
+ </BarChart>
109
+ ) : (
110
+ <Empty>{t('admin.usageRecord.empty')}</Empty>
111
+ )
103
112
  }
104
113
  onConfirm={onConfirm}
105
114
  onCancel={onConfirm}
@@ -9,10 +9,11 @@ type Props = {
9
9
  onUploaded: (result: any) => void;
10
10
  preview?: string;
11
11
  maxFileSize?: number;
12
- allowedFileTypes?: string[];
12
+ maxNumberOfFiles?: number;
13
+ allowedFileExts?: string[];
13
14
  };
14
15
 
15
- export default function Uploader({ onUploaded, preview, maxFileSize, allowedFileTypes }: Props) {
16
+ export default function Uploader({ onUploaded, preview, maxFileSize, maxNumberOfFiles, allowedFileExts }: Props) {
16
17
  const uploaderRef = useRef<any>(null);
17
18
  const handleOpen = useCallback(() => {
18
19
  if (!uploaderRef.current) return;
@@ -37,6 +38,7 @@ export default function Uploader({ onUploaded, preview, maxFileSize, allowedFile
37
38
  backgroundImage: preview ? `url(${preview})` : 'none',
38
39
  backgroundRepeat: 'no-repeat',
39
40
  backgroundSize: 'contain',
41
+ backgroundPosition: 'center',
40
42
  }}>
41
43
  <Button fullWidth variant={preview ? 'contained' : 'text'} color="inherit" size="small">
42
44
  <UploadFileOutlined sx={{ mr: 1 }} fontSize="small" />
@@ -50,8 +52,9 @@ export default function Uploader({ onUploaded, preview, maxFileSize, allowedFile
50
52
  onUploadFinish={(result: any) => onUploaded({ url: result.data.url })}
51
53
  coreProps={{
52
54
  restrictions: {
53
- allowedFileTypes,
55
+ allowedFileExts,
54
56
  maxFileSize,
57
+ maxNumberOfFiles,
55
58
  },
56
59
  }}
57
60
  apiPathProps={{
@@ -66,7 +69,8 @@ export default function Uploader({ onUploaded, preview, maxFileSize, allowedFile
66
69
  Uploader.defaultProps = {
67
70
  preview: '',
68
71
  maxFileSize: undefined,
69
- allowedFileTypes: ['image/png', 'image/jpeg', 'image/webp'],
72
+ maxNumberOfFiles: 1,
73
+ allowedFileExts: ['.png', '.jpeg', '.webp'],
70
74
  };
71
75
 
72
76
  const Div = styled(Box)`
@@ -360,6 +360,7 @@ export default flat({
360
360
  from: 'Billed from',
361
361
  empty: 'No invoice',
362
362
  number: 'Invoice Number',
363
+ description: 'Billing Description',
363
364
  dueDate: 'Due',
364
365
  finalizedAt: 'Finalized At',
365
366
  paidAt: 'Payment Date',
@@ -501,5 +502,8 @@ export default flat({
501
502
  view: 'View refund detail',
502
503
  attention: 'Failed refunds',
503
504
  },
505
+ usageRecord: {
506
+ empty: 'No usage records',
507
+ },
504
508
  },
505
509
  });
@@ -351,6 +351,7 @@ export default flat({
351
351
  from: '账单来自',
352
352
  empty: '没有账单',
353
353
  number: '账单编号',
354
+ description: '账单说明',
354
355
  dueDate: '截止日期',
355
356
  finalizedAt: '已完成时间',
356
357
  paidAt: '支付日期',
@@ -491,5 +492,8 @@ export default flat({
491
492
  attention: '失败的退款',
492
493
  view: '查看退款详情',
493
494
  },
495
+ usageRecord: {
496
+ empty: '用量记录为空',
497
+ },
494
498
  },
495
499
  });
@@ -116,6 +116,7 @@ export default function InvoiceDetail(props: { id: string }) {
116
116
  <SectionHeader title={t('admin.details')} />
117
117
  <Stack>
118
118
  <InfoRow label={t('admin.invoice.number')} value={data.number} />
119
+ <InfoRow label={t('admin.invoice.description')} value={data.description} />
119
120
  <InfoRow label={t('admin.invoice.billTo')} value={<CustomerLink customer={data.customer} />} />
120
121
  <InfoRow
121
122
  label={t('admin.subscription.currentPeriod')}
@@ -124,6 +124,7 @@ export default function CustomerInvoiceDetail() {
124
124
  <Stack className="invoice-summary-wrapper">
125
125
  <InfoRow label={t('admin.invoice.from')} value={data.statement_descriptor || blocklet.appName} />
126
126
  <InfoRow label={t('admin.invoice.number')} value={data.number} />
127
+ <InfoRow label={t('admin.invoice.description')} value={data.description} />
127
128
  <InfoRow
128
129
  label={t('common.status')}
129
130
  value={<Status label={data.status} color={getInvoiceStatusColor(data.status)} />}