外贸开发工具库 - 报价计算、币种换算、贸易术语解释

如果这个项目对你有帮助,欢迎赞助支持持续开发!
| 档位 | 价格 | 权益 |
|---|---|---|
| ☕ 咖啡支持者 | ¥5/月 | 名字上感谢名单 |
| 🚀 核心支持者 | ¥29/月 | 优先 issue 响应 + 答疑群 |
| 💼 金牌赞助商 | ¥99/月 | 定制功能咨询 + 投票权 |
| 🏢 企业合作伙伴 | ¥299/月 | logo 展示 + 专属技术支持 |
npm install trade-toolsconst trade = require('trade-tools');
// 计算 FOB 价格
const foBResult = trade.calculateFOB({
productCost: 50, // 产品成本 50 元/件
quantity: 1000, // 1000 件
packagingCost: 500, // 包装费 500 元
domesticFreight: 200, // 国内运费 200 元
portMisc: 300, // 港杂费 300 元
customsFee: 100, // 报关费 100 元
profitRate: 0.2, // 20% 利润
exchangeRate: 7.2 // 汇率 7.2
});
console.log(foBResult);
/*
{
tradeTerm: 'FOB',
totalCostCNY: 51100,
profitCNY: 10220,
totalCNY: 61320,
totalUSD: 8516.67,
unitPriceUSD: 8.52,
exchangeRate: 7.2,
profitRate: '20.0%',
breakdown: { ... }
}
*/
// 计算 CIF 价格
const cifResult = trade.calculateCIF({
...上面的参数,
seaFreight: 1200, // 海运费 1200 美元
insuranceRate: 0.001 // 保险费率 0.1%
});
console.log(cifResult);
// 快速报价
const quick = trade.quickQuote(10000, 0.2, 7.2);
console.log(quick);
// { costCNY: 10000, profitCNY: 2000, totalCNY: 12000, totalUSD: 1666.67, ... }const trade = require('trade-tools');
// 美元换算人民币
const usd2cny = trade.convert(1000, 'USD', 'CNY');
console.log(usd2cny);
// { from: { amount: 1000, currency: 'USD' }, to: { amount: 7200, currency: 'CNY' }, rate: 7.2 }
// 人民币换算欧元
const cny2eur = trade.convert(10000, 'CNY', 'EUR');
console.log(cny2eur);
// 批量换算
const multiple = trade.convertMultiple(1000, 'USD', ['CNY', 'EUR', 'GBP', 'JPY']);
console.log(multiple);
// 更新汇率(从实时 API 获取后更新)
trade.updateRates({ USD: 1, CNY: 7.25, EUR: 0.93 });const trade = require('trade-tools');
// 查询 FOB 术语
const foBInfo = trade.getIncoterm('FOB');
console.log(foBInfo);
/*
{
code: 'FOB',
name: '装运港船上交货',
nameEn: 'Free On Board',
description: '卖方在指定装运港将货物装上买方指定的船舶时完成交货...',
sellerResponsibilities: [...],
buyerResponsibilities: [...],
riskTransfer: '货物装上船时转移',
suitableFor: '海运或内河运输',
tip: '最常用的外贸术语之一,适合传统海运'
}
*/
// 查询 CIF 术语
const cifInfo = trade.getIncoterm('CIF');
// 比较两个术语
const comparison = trade.compareTerms('FOB', 'CIF');
console.log(comparison);
// 获取所有支持的术语
const terms = trade.getSupportedTerms();
console.log(terms);
// ['EXW', 'FOB', 'CIF', 'CFR', 'DAP', 'DDP', 'FCA']| 方法 | 参数 | 返回值 | 说明 |
|---|---|---|---|
calculateFOB(params) |
QuoteParams | Object | 计算 FOB 价格 |
calculateCIF(params) |
QuoteParams | Object | 计算 CIF 价格 |
quickQuote(cost, profitRate, exchangeRate) |
number, number, number | Object | 快速报价 |
| 方法 | 参数 | 返回值 | 说明 |
|---|---|---|---|
convert(amount, from, to, rates) |
number, string, string, Object | Object | 货币换算 |
convertMultiple(amount, from, toCurrencies, rates) |
number, string, string[], Object | Object[] | 批量换算 |
getSupportedCurrencies() |
- | string[] | 获取支持的货币列表 |
updateRates(newRates) |
Object | void | 更新汇率 |
| 方法 | 参数 | 返回值 | 说明 |
|---|---|---|---|
getIncoterm(term) |
string | Object | 获取术语详情 |
getSupportedTerms() |
- | string[] | 获取支持的术语列表 |
compareTerms(term1, term2) |
string, string | Object | 比较两个术语 |
# 克隆项目
git clone https://github.com/steibach/trade-tools.git
cd trade-tools
# 安装依赖
npm install
# 运行示例
npm start
# 运行测试
npm test- ✨ 初始版本发布
- ✅ FOB/CIF报价计算
- ✅ 币种换算(支持 15 种货币)
- ✅ 7 种常用贸易术语解释
欢迎提交 Issue 和 Pull Request!
- Bug 报告:https://github.com/steibach/trade-tools/issues
- 功能建议:https://github.com/steibach/trade-tools/issues
- 代码贡献:Fork 后提交 PR
MIT License - 详见 LICENSE 文件
steibach - 外贸行业开发者
- GitHub: @steibach
- 爱发电:afdian.com/a/steibach
感谢所有赞助支持者!你们的赞助让开源项目得以持续开发!
如果这个项目对你有帮助,请给个 ⭐ Star 支持一下!
爱发电赞助 | GitHub Issues | npm