style(src-tauri): cargo fmt

Pure mechanical rustfmt reformat (default config, no rustfmt.toml).
This commit is contained in:
soubarna
2026-10-05 17:19:13 +05:30
parent e1031b3ecc
commit b6cf46b883
27 changed files with 4430 additions and 1042 deletions
+55 -12
View File
@@ -75,7 +75,11 @@ pub fn derive_tax_type(registration: &str, supplier_state: &str, pos_state: &str
if registration == "unregistered" {
return TaxType::None;
}
let pos = if pos_state.trim().is_empty() { supplier_state } else { pos_state };
let pos = if pos_state.trim().is_empty() {
supplier_state
} else {
pos_state
};
if pos == supplier_state {
TaxType::CgstSgst
} else {
@@ -225,8 +229,26 @@ pub fn compute_totals(
}
const ONES: [&str; 20] = [
"", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
"Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen",
"",
"One",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten",
"Eleven",
"Twelve",
"Thirteen",
"Fourteen",
"Fifteen",
"Sixteen",
"Seventeen",
"Eighteen",
"Nineteen",
];
const TENS: [&str; 10] = [
@@ -353,9 +375,18 @@ mod tests {
#[test]
fn tax_type_serde_strings() {
assert_eq!(serde_json::to_string(&TaxType::CgstSgst).unwrap(), "\"cgst_sgst\"");
assert_eq!(serde_json::from_str::<TaxType>("\"igst\"").unwrap(), TaxType::Igst);
assert_eq!(serde_json::from_str::<TaxType>("\"none\"").unwrap(), TaxType::None);
assert_eq!(
serde_json::to_string(&TaxType::CgstSgst).unwrap(),
"\"cgst_sgst\""
);
assert_eq!(
serde_json::from_str::<TaxType>("\"igst\"").unwrap(),
TaxType::Igst
);
assert_eq!(
serde_json::from_str::<TaxType>("\"none\"").unwrap(),
TaxType::None
);
}
#[test]
@@ -384,17 +415,29 @@ mod tests {
assert_eq!(validate_gstin("29abcde1234f1zw"), Ok(()));
// The algorithm gives W for this body, so a trailing 5 is a typo.
assert_eq!(validate_gstin("29ABCDE1234F1ZW"), Ok(()));
assert!(validate_gstin("29ABCDE1234F1Z5").unwrap_err().contains("check digit"));
assert!(validate_gstin("27AAPFU0939F1ZX").unwrap_err().contains("check digit"));
assert!(validate_gstin("29ABCDE1234F1Z5")
.unwrap_err()
.contains("check digit"));
assert!(validate_gstin("27AAPFU0939F1ZX")
.unwrap_err()
.contains("check digit"));
}
#[test]
fn gstin_rejects_bad_shapes() {
assert!(validate_gstin("").unwrap_err().contains("15 characters"));
assert!(validate_gstin("27AAPFU0939F1Z").unwrap_err().contains("15 characters"));
assert!(validate_gstin("27AAPFU0939F1ZVV").unwrap_err().contains("15 characters"));
assert!(validate_gstin("2XAAPFU0939F1ZV").unwrap_err().contains("format"));
assert!(validate_gstin("27AAPFU0939F1AV").unwrap_err().contains("format"));
assert!(validate_gstin("27AAPFU0939F1Z")
.unwrap_err()
.contains("15 characters"));
assert!(validate_gstin("27AAPFU0939F1ZVV")
.unwrap_err()
.contains("15 characters"));
assert!(validate_gstin("2XAAPFU0939F1ZV")
.unwrap_err()
.contains("format"));
assert!(validate_gstin("27AAPFU0939F1AV")
.unwrap_err()
.contains("format"));
// Valid shape and checksum but state 99 does not exist.
let body = b"99AAPFU0939F1Z";
let mut g = String::from_utf8(body.to_vec()).unwrap();