Skip to content

Commit

Permalink
Ignoring VAT lines without a percent, sneakily removing (the) from co…
Browse files Browse the repository at this point in the history
…untry names
  • Loading branch information
samlown committed May 5, 2023
1 parent bf4553c commit 3db85db
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 40 deletions.
74 changes: 37 additions & 37 deletions l10n/countries.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ var CountryDefinitions = []CountryDef{
{AR, "Argentina", "ar"},
{AM, "Armenia", "am"},
{AW, "Aruba", "aw"},
{AU, "Australia", "au"},
{AU, "Australia", "au"},
{AT, "Austria", "at"},
{AZ, "Azerbaijan", "az"},
{BS, "Bahamas (the)", "bs"},
{BS, "Bahamas", "bs"},
{BH, "Bahrain", "bh"},
{BD, "Bangladesh", "bd"},
{BB, "Barbados", "bb"},
Expand All @@ -283,13 +283,13 @@ var CountryDefinitions = []CountryDef{
{BJ, "Benin", "bj"},
{BM, "Bermuda", "bm"},
{BT, "Bhutan", "bt"},
{BO, "Bolivia (Plurinational State of)", "bo"},
{BO, "Bolivia, Plurinational State of", "bo"},
{BQ, "Bonaire, Sint Eustatius and Saba", "bq"},
{BA, "Bosnia and Herzegovina", "ba"},
{BW, "Botswana", "bw"},
{BV, "Bouvet Island", "bv"},
{BR, "Brazil", "br"},
{IO, "British Indian Ocean Territory (the)", "io"},
{IO, "British Indian Ocean Territory", "io"},
{BN, "Brunei Darussalam", "bn"},
{BG, "Bulgaria", "bg"},
{BF, "Burkina Faso", "bf"},
Expand All @@ -298,18 +298,18 @@ var CountryDefinitions = []CountryDef{
{KH, "Cambodia", "kh"},
{CM, "Cameroon", "cm"},
{CA, "Canada", "ca"},
{KY, "Cayman Islands (the)", "ky"},
{CF, "Central African Republic (the)", "cf"},
{KY, "Cayman Islands", "ky"},
{CF, "Central African Republic", "cf"},
{TD, "Chad", "td"},
{CL, "Chile", "cl"},
{CN, "China", "cn"},
{CX, "Christmas Island", "cx"},
{CC, "Cocos (Keeling) Islands (the)", "cc"},
{CC, "Cocos (Keeling) Islands", "cc"},
{CO, "Colombia", "co"},
{KM, "Comoros (the)", "km"},
{CG, "Congo (the Democratic Republic of the)", "cd"},
{CD, "Congo (the)", "cd"},
{CK, "Cook Islands (the)", "ck"},
{KM, "Comoros", "km"},
{CG, "Congo", "cg"},
{CD, "Congo, Democratic Republic of the", "cd"},
{CK, "Cook Islands", "ck"},
{CR, "Costa Rica", "cr"},
{CI, "Côte d'Ivoire", "ci"},
{HR, "Croatia", "hr"},
Expand All @@ -320,7 +320,7 @@ var CountryDefinitions = []CountryDef{
{DK, "Denmark", "dk"},
{DJ, "Djibouti", "dj"},
{DM, "Dominica", "dm"},
{DO, "Dominican Republic (the)", "do"},
{DO, "Dominican Republic", "do"},
{EC, "Ecuador", "ec"},
{EG, "Egypt", "eg"},
{SV, "El Salvador", "sv"},
Expand All @@ -329,16 +329,16 @@ var CountryDefinitions = []CountryDef{
{EE, "Estonia", "ee"},
{SZ, "Eswatini", "sz"},
{ET, "Ethiopia", "et"},
{FK, "Falkland Islands (the)", "fk"},
{FO, "Faroe Islands (the)", "fo"},
{FK, "Falkland Islands", "fk"},
{FO, "Faroe Islands", "fo"},
{FJ, "Fiji", "fj"},
{FI, "Finland", "fi"},
{FR, "France", "fr"},
{GF, "French Guiana", "gf"},
{PF, "French Polynesia", "pf"},
{TF, "French Southern Territories (the) ", "tf"},
{TF, "French Southern Territories", "tf"},
{GA, "Gabon", "ga"},
{GM, "Gambia (the)", "gm"},
{GM, "Gambia", "gm"},
{GE, "Georgia", "ge"},
{DE, "Germany", "de"},
{GH, "Ghana", "gh"},
Expand All @@ -362,7 +362,7 @@ var CountryDefinitions = []CountryDef{
{IS, "Iceland", "is"},
{IN, "India", "in"},
{ID, "Indonesia", "id"},
{IR, "Iran (Islamic Republic of)", "ir"},
{IR, "Iran, Islamic Republic of", "ir"},
{IQ, "Iraq", "iq"},
{IE, "Ireland", "ie"},
{IM, "Isle of Man", "im"},
Expand All @@ -375,11 +375,11 @@ var CountryDefinitions = []CountryDef{
{KZ, "Kazakhstan", "kz"},
{KE, "Kenya", "ke"},
{KI, "Kiribati", "ki"},
{KP, "Korea (the Democratic People's Republic of)", "kp"},
{KR, "Korea (the Republic of)", "kr"},
{KP, "Korea, Democratic People's Republic of", "kp"},
{KR, "Korea, Republic of", "kr"},
{KW, "Kuwait", "kw"},
{KG, "Kyrgyzstan", "kg"},
{LA, "Lao People's Democratic Republic (the)", "la"},
{LA, "Lao People's Democratic Republic", "la"},
{LV, "Latvia", "lv"},
{LB, "Lebanon", "lb"},
{LS, "Lesotho", "ls"},
Expand All @@ -396,14 +396,14 @@ var CountryDefinitions = []CountryDef{
{MV, "Maldives", "mv"},
{ML, "Mali", "ml"},
{MT, "Malta", "mt"},
{MH, "Marshall Islands (the)", "mh"},
{MH, "Marshall Islands", "mh"},
{MQ, "Martinique", "mq"},
{MR, "Mauritania", "mr"},
{MU, "Mauritius", "mu"},
{YT, "Mayotte", "yt"},
{MX, "Mexico", "mx"},
{FM, "Micronesia (Federated States of)", "fm"},
{MD, "Moldova (the Republic of)", "md"},
{FM, "Micronesia, Federated States of", "fm"},
{MD, "Moldova, Republic of", "md"},
{MC, "Monaco", "mc"},
{MN, "Mongolia", "mn"},
{ME, "Montenegro", "me"},
Expand All @@ -414,15 +414,15 @@ var CountryDefinitions = []CountryDef{
{NA, "Namibia", "na"},
{NR, "Nauru", "nr"},
{NP, "Nepal", "np"},
{NL, "Netherlands (the)", "nl"},
{NL, "Netherlands", "nl"},
{NC, "New Caledonia", "nc"},
{NZ, "New Zealand", "nz"},
{NI, "Nicaragua", "ni"},
{NE, "Niger (the)", "ne"},
{NE, "Niger", "ne"},
{NG, "Nigeria", "ng"},
{NU, "Niue", "nu"},
{NF, "Norfolk Island", "nf"},
{MP, "Northern Mariana Islands (the)", "mp"},
{MP, "Northern Mariana Islands", "mp"},
{NO, "Norway", "no"},
{OM, "Oman", "om"},
{PK, "Pakistan", "pk"},
Expand All @@ -432,15 +432,15 @@ var CountryDefinitions = []CountryDef{
{PG, "Papua New Guinea", "pg"},
{PY, "Paraguay", "py"},
{PE, "Peru", "pe"},
{PH, "Philippines (the)", "ph"},
{PH, "Philippines", "ph"},
{PN, "Pitcairn", "pn"},
{PL, "Poland", "pl"},
{PT, "Portugal", "pt"},
{PR, "Puerto Rico", "pr"},
{QA, "Qatar", "qa"},
{RE, "Réunion", "re"},
{RO, "Romania", "ro"},
{RU, "Russian Federation (the)", "ru"},
{RU, "Russian Federation", "ru"},
{RW, "Rwanda", "rw"},
{BL, "Saint Barthélemy", "bl"},
{SH, "Saint Helena, Ascension and Tristan da Cunha", "sh"},
Expand Down Expand Up @@ -468,36 +468,36 @@ var CountryDefinitions = []CountryDef{
{SS, "South Sudan", "ss"},
{ES, "Spain", "es"},
{LK, "Sri Lanka", "lk"},
{SD, "Sudan (the)", "sd"},
{SD, "Sudan", "sd"},
{SR, "Suriname", "sr"},
{SJ, "Svalbard and Jan Mayen", ""},
{SE, "Sweden", "se"},
{CH, "Switzerland", "ch"},
{SY, "Syrian Arab Republic (the)", "sy"},
{SY, "Syrian Arab Republic", "sy"},
{TW, "Taiwan (Province of China)", "tw"},
{TJ, "Tajikistan", "tj"},
{TZ, "Tanzania, the United Republic of", "tz"},
{TH, "Thailand", "th"},
{TL, "Timor-Leste", "tl"},
{TL, "Timor-Leste", "tl"},
{TG, "Togo", "tg"},
{TK, "Tokelau", "tk"},
{TO, "Tonga", "to"},
{TT, "Trinidad and Tobago", "tt"},
{TN, "Tunisia", "tn"},
{TR, "Türkiye", "tr"},
{TM, "Turkmenistan", "tm"},
{TC, "Turks and Caicos Islands (the)", "tc"},
{TC, "Turks and Caicos Islands", "tc"},
{TV, "Tuvalu", "tv"},
{UG, "Uganda", "ug"},
{UA, "Ukraine", "ua"},
{AE, "United Arab Emirates (the)", "ae"},
{GB, "United Kingdom of Great Britain and Northern Ireland (the)", "uk"},
{US, "United States of America (the)", "us"},
{UM, "United States Minor Outlying Islands (the)", ""},
{AE, "United Arab Emirates", "ae"},
{GB, "United Kingdom", "uk"},
{US, "United States of America", "us"},
{UM, "United States Minor Outlying Islands", ""},
{UY, "Uruguay", "uy"},
{UZ, "Uzbekistan", "uz"},
{VU, "Vanuatu", "vu"},
{VE, "Venezuela (Bolivarian Republic of)", "ve"},
{VE, "Venezuela, Bolivarian Republic of", "ve"},
{VN, "Viet Nam", "vn"},
{VG, "Virgin Islands (British)", "vg"},
{VI, "Virgin Islands (U.S.)", "vi"},
Expand Down
3 changes: 2 additions & 1 deletion tax/totals.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func (tc *TotalCalculator) Calculate(t *Total) error {
return ErrInvalidPricesInclude.WithMessage("cannot include retained category '%s'", tc.Includes.String())
}
if c.Percent == nil {
return ErrInvalidRate.WithMessage("missing '%s' percentage", tc.Includes.String())
// can't work without a percent value, just skip
continue
}

// update the price scale, add two 0s, this will be removed later.
Expand Down
7 changes: 5 additions & 2 deletions tax/totals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,14 +766,17 @@ func TestTotalCalculate(t *testing.T) {
taxes: tax.Set{
{
Category: common.TaxCategoryVAT,
Tags: []cbc.Key{"random"},
},
},
amount: num.MakeAmount(10000, 2),
},
},
taxIncluded: common.TaxCategoryVAT,
err: tax.ErrInvalidRate,
errContent: "missing 'VAT' percentage",
want: &tax.Total{
Categories: []*tax.CategoryTotal{},
Sum: num.MakeAmount(0, 2),
},
},
}

Expand Down

0 comments on commit 3db85db

Please sign in to comment.