use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CpeTipoSistemaIsc {
SistemaAlValor,
AplicacionMontoFijo,
SistemaPreciosVentaAlPublico,
Otro(String),
}
impl CpeTipoSistemaIsc {
#[must_use]
pub fn codigo(&self) -> &str {
match self {
Self::SistemaAlValor => "01",
Self::AplicacionMontoFijo => "02",
Self::SistemaPreciosVentaAlPublico => "03",
Self::Otro(c) => c.as_str(),
}
}
#[must_use]
pub fn descripcion(&self) -> &str {
match self {
Self::SistemaAlValor => "Sistema al Valor",
Self::AplicacionMontoFijo => "Aplicación del Monto Fijo (Específico)",
Self::SistemaPreciosVentaAlPublico => "Sistema de Precios de Venta al Público",
Self::Otro(_) => "Otro Sistema de Cálculo ISC",
}
}
#[must_use]
pub fn desde_codigo(codigo: &str) -> Self {
match codigo.trim() {
"01" => Self::SistemaAlValor,
"02" => Self::AplicacionMontoFijo,
"03" => Self::SistemaPreciosVentaAlPublico,
otro => Self::Otro(otro.to_string()),
}
}
}
impl fmt::Display for CpeTipoSistemaIsc {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.codigo())
}
}