77 lines
1.9 KiB
Rust
77 lines
1.9 KiB
Rust
//! 资产分类和GNACS编码
|
||
|
||
use serde::{Deserialize, Serialize};
|
||
|
||
/// 资产类型(基于GNACS编码)
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||
pub enum AssetType {
|
||
/// 不动产(住宅、商业、工业、土地)
|
||
RealEstate,
|
||
/// 大宗商品(能源、金属、农产品)
|
||
Commodity,
|
||
/// 金融资产(股票、债券、衍生品)
|
||
FinancialAsset,
|
||
/// 数字资产(加密货币、NFT、代币)
|
||
DigitalAsset,
|
||
/// 知识产权(专利、商标、版权)
|
||
IntellectualProperty,
|
||
/// 艺术品收藏品
|
||
ArtCollectible,
|
||
/// 动产(设备、车辆、库存)
|
||
Movable,
|
||
/// 应收账款
|
||
Receivable,
|
||
/// 基础设施
|
||
Infrastructure,
|
||
/// 自然资源
|
||
NaturalResource,
|
||
/// ESG资产(绿色债券、碳信用)
|
||
ESGAsset,
|
||
/// 其他资产
|
||
Other,
|
||
}
|
||
|
||
/// 资产详细信息
|
||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
pub struct Asset {
|
||
/// 资产ID
|
||
pub id: String,
|
||
/// 资产类型
|
||
pub asset_type: AssetType,
|
||
/// GNACS编码
|
||
pub gnacs_code: String,
|
||
/// 资产名称
|
||
pub name: String,
|
||
/// 资产描述
|
||
pub description: String,
|
||
/// 基础估值(本地货币)
|
||
pub base_valuation_local: rust_decimal::Decimal,
|
||
/// 本地货币代码
|
||
pub local_currency: String,
|
||
/// 资产元数据
|
||
pub metadata: serde_json::Value,
|
||
}
|
||
|
||
impl Asset {
|
||
/// 创建新资产
|
||
pub fn new(
|
||
id: String,
|
||
asset_type: AssetType,
|
||
gnacs_code: String,
|
||
name: String,
|
||
base_valuation_local: rust_decimal::Decimal,
|
||
local_currency: String,
|
||
) -> Self {
|
||
Self {
|
||
id,
|
||
asset_type,
|
||
gnacs_code,
|
||
name,
|
||
description: String::new(),
|
||
base_valuation_local,
|
||
local_currency,
|
||
metadata: serde_json::json!({}),
|
||
}
|
||
}
|
||
}
|