Skip to content

steibach/trade-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔧 trade-tools

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

npm version License: MIT ![Sponsor](https://img.shields.io/badge/赞助 - 爱发电-pink.svg)


💖 赞助支持

如果这个项目对你有帮助,欢迎赞助支持持续开发!

⚡ 爱发电赞助

档位 价格 权益
☕ 咖啡支持者 ¥5/月 名字上感谢名单
🚀 核心支持者 ¥29/月 优先 issue 响应 + 答疑群
💼 金牌赞助商 ¥99/月 定制功能咨询 + 投票权
🏢 企业合作伙伴 ¥299/月 logo 展示 + 专属技术支持

📦 安装

npm install trade-tools

🚀 快速开始

1. 报价计算

const 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, ... }

2. 币种换算

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 });

3. 贸易术语查询

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']

📚 API 文档

报价计算

方法 参数 返回值 说明
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

📝 更新日志

v1.0.0 (2026-04-19)

  • ✨ 初始版本发布
  • ✅ FOB/CIF报价计算
  • ✅ 币种换算(支持 15 种货币)
  • ✅ 7 种常用贸易术语解释

🤝 贡献

欢迎提交 Issue 和 Pull Request!


📄 许可证

MIT License - 详见 LICENSE 文件


👨‍💻 作者

steibach - 外贸行业开发者


🙏 感谢

感谢所有赞助支持者!你们的赞助让开源项目得以持续开发!

⚡ 成为赞助者


如果这个项目对你有帮助,请给个 ⭐ Star 支持一下!

爱发电赞助 | GitHub Issues | npm

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors