Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mis): 计费调整精确到分 #1236

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/mis-web/src/pageComponents/admin/DataBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ export const DataBarChart: React.FC<Props> = ({
xLabel = "",
toolTipFormatter = (value) => value,
}) => {

const tickFormatter = (value) => {
cuvalign marked this conversation as resolved.
Show resolved Hide resolved
if (typeof value === "number") {
const decimalPart = value.toString().split(".")[1];
if (decimalPart && decimalPart.length > 2) {
return value.toFixed(2);
}
}
return value;
};
ddadaal marked this conversation as resolved.
Show resolved Hide resolved
return (
<StatisticContainer>
{isLoading ? <Spin /> : (
Expand All @@ -64,7 +72,7 @@ export const DataBarChart: React.FC<Props> = ({
label={{ value: xLabel, position: "insideBottom", offset: 0 }}
height={40}
/>
<YAxis padding={{ top: 20 }} />
<YAxis padding={{ top: 20 }} tickFormatter={tickFormatter} />
<Tooltip
formatter={toolTipFormatter}
/>
Expand Down
8 changes: 5 additions & 3 deletions apps/mis-web/src/pageComponents/admin/StatisticCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Props {
loading: boolean
icon: React.ReactNode | React.ForwardRefExoticComponent<{}>;
iconColor?: string
precision?: number | undefined
}

const Container = styled.div`
Expand All @@ -40,7 +41,8 @@ const iconToNode = (Icon: any, color?: string) => {

const p = prefix("pageComp.admin.statisticCard.");

export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0, totalValue = 0, loading, icon, iconColor }) =>
export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0,
totalValue = 0, loading, icon, iconColor, precision = 0 }) =>
{
const t = useI18nTranslateToString();

Expand All @@ -52,7 +54,7 @@ export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0, totalVa
<Statistic
title={title}
value={newAddValue}
precision={0}
precision={precision}
loading={loading}
valueStyle={{ color: "#94070A" }}
/>
Expand All @@ -63,7 +65,7 @@ export const StatisticCard: React.FC<Props> = ({ title, newAddValue = 0, totalVa
title={`${t(p("total"))}${title}: `}
value={totalValue}
loading={loading}
precision={0}
precision={precision}
valueStyle={{ color: "grey", marginLeft: "10px", fontSize: 14, marginBottom: 4 }}
/>
</Card>
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pageComponents/common/PaymentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const PaymentTable: React.FC<Props> = ({ accountName, searchType }) => {
</Form.Item>
<Form.Item label={t(p("sum"))}>
<strong>
{data ? data.total.toFixed(3) : 0}
{data ? data.total.toFixed(2) : 0}
</strong>
</Form.Item>
<Form.Item>
Expand Down Expand Up @@ -234,7 +234,7 @@ export const PaymentTable: React.FC<Props> = ({ accountName, searchType }) => {
: undefined
}
<Table.Column dataIndex="time" title={t(p("paymentDate"))} width="13.5%" render={(v) => formatDateTime(v)} />
<Table.Column dataIndex="amount" title={t(p("paymentAmount"))} width="10%" render={(v) => v.toFixed(3)} />
<Table.Column dataIndex="amount" title={t(p("paymentAmount"))} width="10%" render={(v) => v.toFixed(2)} />
<Table.Column
dataIndex="type"
title={t(pCommon("type"))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const AccountInfoSection: React.FC<Props> = ({ info }) => {
title={t("dashboard.account.balance")}
valueStyle={{ color: minOne < 0 ? "red" : undefined }}
prefix={"¥"}
value={minOne.toFixed(3)}
value={minOne.toFixed(2)}
/>
</Row>
</StatCard>
Expand Down
2 changes: 1 addition & 1 deletion apps/mis-web/src/pageComponents/finance/ChargeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const ChargeForm: React.FC = () => {
<Input />
</Form.Item>
<Form.Item name="amount" label={t(pCommon("amount"))} rules={[{ required: true }]}>
<InputNumber step={0.01} addonAfter={t(pCommon("unit"))} />
<InputNumber step={0.01} addonAfter={t(pCommon("unit"))} precision={2} />
</Form.Item>
<Form.Item
name="type"
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pageComponents/finance/ChargeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export const ChargeTable: React.FC<Props> = ({
</Form.Item>
<Form.Item label={t(pCommon("sum"))}>
<strong>
{totalResultData?.totalAmount ?? 0}
{totalResultData?.totalAmount?.toFixed(2) ?? 0}
</strong>
</Form.Item>
<Form.Item>
Expand Down Expand Up @@ -300,7 +300,7 @@ export const ChargeTable: React.FC<Props> = ({
render={(_, r) => r.userId ? (`${r.userId} (${r.userName})`) : ""}
/>
<Table.Column<ChargeInfo> dataIndex="time" title={t(p("time"))} render={(v) => formatDateTime(v)} />
<Table.Column<ChargeInfo> dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(3)} />
<Table.Column<ChargeInfo> dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(2)} />
<Table.Column<ChargeInfo> dataIndex="type" title={t(pCommon("type"))} />
<Table.Column<ChargeInfo>
dataIndex="comment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const EditPriceModal: React.FC<CommonModalProps & {
<Select options={Object.values(AmountStrategy).map((x) => ({ label: x, value: x }))} />
</Form.Item>
<Form.Item label={t(p("price"))} name="price" rules={[{ required: true }]}>
<InputNumber precision={3} min={0} />
<InputNumber precision={2} min={0} />
</Form.Item>
<Form.Item label={t(pCommon("comment"))} name="description">
<Input />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const EditPriceModal: React.FC<CommonModalProps & {
/>
</Form.Item>
<Form.Item label={t(p("price"))} name="price" initialValue={0} rules={[{ required: true }]}>
<InputNumber precision={3} min={0} />
<InputNumber precision={2} min={0} />
</Form.Item>
<Form.Item label={t(pCommon("comment"))} name="description">
<Input />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const AccountWhitelistTable: React.FC<Props> = ({
<>
<Divider type="vertical" />
<span>
{t(p("debtSum"))}:<strong>{getTotalDebtAmount(data).toFixed(3)} {t(pCommon("unit"))}</strong>
{t(p("debtSum"))}:<strong>{getTotalDebtAmount(data).toFixed(2)} {t(pCommon("unit"))}</strong>
</span>
</>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pages/accounts/[accountName]/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export const AccountInfoPage: NextPage<Props> = requireAuth(
</Tag>
</Descriptions.Item>
<Descriptions.Item label={t("common.accountBalance")}>
{balance.toFixed(3)} {t("common.unit")}
{balance.toFixed(2)} {t("common.unit")}
</Descriptions.Item>
<Descriptions.Item label={t("common.blockThresholdAmount")}>
{blockThresholdAmount.toFixed(3)} {t("common.unit")}
{blockThresholdAmount.toFixed(2)} {t("common.unit")}
</Descriptions.Item>
</Descriptions>

Expand Down
9 changes: 5 additions & 4 deletions apps/mis-web/src/pages/admin/statistic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))

return topChargeAccount?.results.map((r) => ({
x: r.accountName,
y: moneyToNumber(r.chargedAmount),
y: moneyToNumber(r.chargedAmount).toFixed(2),
})) || [];
}, [query, topChargeAccount]);

const topPayAccountData = useMemo(() => {

return topPayAccount?.results.map((r) => ({
x: r.accountName,
y: moneyToNumber(r.payAmount),
y: moneyToNumber(r.payAmount).toFixed(2),
})) || [];
}, [query, topPayAccount]);

Expand Down Expand Up @@ -383,6 +383,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))
loading={totalChargeAmountLoading || dailyChargeLoading}
icon={MoneyCollectOutlined}
iconColor="#feca57"
precision={2}
/>
</Col>
<Col span={24}>
Expand Down Expand Up @@ -446,7 +447,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))
<DataLineChart
data={dailyChargeData.map((d) => ({
x: d.date.format("YYYY-MM-DD"),
y: d.count,
y: d.count.toFixed(2),
}))}
title={t(p("chargeAmount"))}
isLoading={dailyChargeLoading}
Expand All @@ -468,7 +469,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN))
<DataLineChart
data={dailyPayData.map((d) => ({
x: d.date.format("YYYY-MM-DD"),
y: d.count,
y: d.count.toFixed(2),
}))}
title={t(p("payAmount"))}
toolTipFormatter={amountToolTipFormatter}
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/pages/tenant/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ export const TenantInfoPage: NextPage<Props> = requireAuth((u) => u.tenantRoles.
{userCount}
</Descriptions.Item>
<Descriptions.Item label={t("common.tenantBalance")}>
{moneyToNumber(balance).toFixed(3)} {t("common.unit")}
{moneyToNumber(balance).toFixed(2)} {t("common.unit")}
</Descriptions.Item>
<Descriptions.Item label={t("common.defaultAccountBlockThreshold")}>
<Space>
<span>
{moneyToNumber(defaultAccountBlockThreshold).toFixed(3)} {t("common.unit")}
{moneyToNumber(defaultAccountBlockThreshold).toFixed(2)} {t("common.unit")}
</span>
<ChangeDefaultAccountBlockThresholdLink
tenantName={tenantName}
Expand Down
4 changes: 2 additions & 2 deletions apps/mis-web/src/utils/money.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { moneyToNumber } from "@scow/lib-decimal";
import type { Money } from "@scow/protos/build/common/money";

export function moneyToString(money: Money) {
return moneyToNumber(money).toFixed(3);
return moneyToNumber(money).toFixed(2);
}

export function nullableMoneyToString(money: Money | undefined) {
return money ? moneyToString(money) : Number.prototype.toFixed.call(0, 3);
return money ? moneyToString(money) : Number.prototype.toFixed.call(0, 2);
}
Loading