currency-money-calc

Use currency.js in the browser to perform high-precision monetary calculations (addition, subtraction, multiplication) to avoid floating-point precision errors. Suitable for quoting totals, payment accumulation, and other scenarios that require precise currency handling or to address issues like 0.1 + 0.2 ≠ 0.3.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "currency-money-calc" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-9121a41443fade40112e314b23e5b61012913433059b4e60e2bade4a32596146. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/tas20260539 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Use currency.js in the browser to perform high-precision monetary calculations (addition, subtraction, multiplication) to avoid floating-point precision errors. Suitable for quoting totals, payment accumulation, and other scenarios that require precise currency handling or to address issues like 0.1 + 0.2 ≠ 0.3.

0 Downloads

Introduction source: third_party · user_f1b049da · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: currency-money-calc
slug: tas20260539
displayName: 高精度金额
version: 1.0.0
summary: 用 currency.js 规避浮点误差,本地算报价与回款合计。
license: MIT
description: 用 currency.js 在浏览器内做高精度金额加减乘,规避浮点误差,用于报价合计、回款累加。当用户需要 currency.js、金额精度、报价合计、回款汇总、避免 0.1+0.2 问题时使用。

高精度金额(currency.js)

灵感:能力工具箱 currency-money(pkg: currency.js)。

CRM 报价、回款、佣金本地加减时,用 currency.js 代替裸 number 运算,避免 0.1 + 0.2 类误差展示到分位。

何时使用

  • 报价行合计、含税/未税累加
  • 回款流水合计、已收/未收
  • 需要「分」为单位的稳定展示(默认 2 位小数)

硬约束

  1. 依赖 currency.js;金额字符串/数字经 currency() 包装后再运算。
  2. 展示用 .format() 或固定 toFixed(2) 等价输出;禁止直接 a + b 裸浮点累加业务金额。
  3. 币种符号可配置(默认 ¥ 或空,按项目 UI);不发起汇率网络请求。
  4. 输入非法时返回可读错误,不抛未捕获异常到 UI。
  5. 与「安全公式求值」分工:复杂表达式可用 mathjs;金额累加优先 currency.js。

推荐实现要点

import currency from 'currency.js'

const cny = (v: currency.Any) =>
  currency(v, { symbol: '¥', precision: 2, separator: ',', decimal: '.' })

export function sumAmounts(values: Array<string | number>): string {
  const total = values.reduce((acc, v) => acc.add(v), cny(0))
  return total.format()
}

export function quoteTotal(lines: { price: number; qty: number }[]) {
  const total = lines.reduce(
    (acc, line) => acc.add(cny(line.price).multiply(line.qty)),
    cny(0),
  )
  return {
    value: total.value,
    display: total.format(),
  }
}

export function remaining(receivable: number, receivedList: number[]) {
  const left = receivedList.reduce((acc, v) => acc.subtract(v), cny(receivable))
  return { value: left.value, display: left.format() }
}

Agent 步骤

  1. 安装 currency.js,封装 cny 与 sumAmounts / quoteTotal。
  2. 自测:0.1+0.2 经封装后展示为 ¥0.30;多行报价合计与手工一致。
  3. 列表/表单金额字段统一走封装,避免混用裸 number 加法。

附加

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value72/100

Highlights

  • 解决浮点数精度误差的实际业务痛点
  • 适用于报价合计、回款累加等高频场景
Trigger Precision85/100

Highlights

  • 触发词覆盖全面,边界清晰
Structure and Standards78/100

Areas to improve

  • 缺少端到端完整示例 Reported severity: Minor

    文档中提供了代码片段,但缺少一个从输入到输出的完整端到端示例。

    Recommendation: 补充一个完整的端到端示例,展示从数据输入到最终结果输出的完整流程。

Highlights

  • 结构完整,包含何时使用、硬约束、实现要点和步骤
Execution Reliability88/100

Highlights

  • 工具来源明确,参数配置清晰
  • 覆盖非法输入处理和错误返回机制
Evidence Verifiability (mean of the first four)81/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.