use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CpeTipoNotaDebito {
InteresesPorMora,
AumentoEnValor,
PenalidadesOtrosConceptos,
AjustesExportacion,
AjustesIvap,
Otro(String),
}
impl CpeTipoNotaDebito {
#[must_use]
pub fn codigo(&self) -> &str {
match self {
Self::InteresesPorMora => "01",
Self::AumentoEnValor => "02",
Self::PenalidadesOtrosConceptos => "03",
Self::AjustesExportacion => "10",
Self::AjustesIvap => "11",
Self::Otro(c) => c.as_str(),
}
}
#[must_use]
pub fn descripcion(&self) -> &str {
match self {
Self::InteresesPorMora => "Intereses por mora",
Self::AumentoEnValor => "Aumento en el valor",
Self::PenalidadesOtrosConceptos => "Penalidades / otros conceptos",
Self::AjustesExportacion => "Ajustes de operaciones de exportación",
Self::AjustesIvap => "Ajustes afectos al IVAP",
Self::Otro(_) => "Otro motivo de Nota de Débito",
}
}
#[must_use]
pub fn desde_codigo(codigo: &str) -> Self {
match codigo.trim() {
"01" => Self::InteresesPorMora,
"02" => Self::AumentoEnValor,
"03" => Self::PenalidadesOtrosConceptos,
"10" => Self::AjustesExportacion,
"11" => Self::AjustesIvap,
otro => Self::Otro(otro.to_string()),
}
}
}
impl fmt::Display for CpeTipoNotaDebito {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.codigo())
}
}