@@ -117,6 +117,44 @@ func TestOrganizationDefaultTaxCodesService(t *testing.T) {
117117 assert .True (t , taxcode .IsTaxCodeNotFoundError (err ), "tax code from another namespace must not resolve" )
118118 })
119119
120+ t .Run ("SoftDeleted/InvoicingTaxCodeIsDeleted" , func (t * testing.T ) {
121+ dns := testutils .NameGenerator .Generate ().Key
122+ env .SetupNamespaceDefaults (t , dns )
123+ deleted := env .CreateTaxCode (t , dns )
124+ active := env .CreateTaxCode (t , dns )
125+
126+ require .NoError (t , env .Service .DeleteTaxCode (t .Context (), taxcode.DeleteTaxCodeInput {
127+ NamespacedID : models.NamespacedID {Namespace : dns , ID : deleted .ID },
128+ }))
129+
130+ _ , err := env .Service .UpsertOrganizationDefaultTaxCodes (t .Context (), taxcode.UpsertOrganizationDefaultTaxCodesInput {
131+ Namespace : dns ,
132+ InvoicingTaxCodeID : deleted .ID ,
133+ CreditGrantTaxCodeID : active .ID ,
134+ })
135+ require .Error (t , err )
136+ assert .True (t , taxcode .IsTaxCodeNotFoundError (err ), "soft-deleted tax code must not be settable as an organization default" )
137+ })
138+
139+ t .Run ("SoftDeleted/CreditGrantTaxCodeIsDeleted" , func (t * testing.T ) {
140+ dns := testutils .NameGenerator .Generate ().Key
141+ env .SetupNamespaceDefaults (t , dns )
142+ active := env .CreateTaxCode (t , dns )
143+ deleted := env .CreateTaxCode (t , dns )
144+
145+ require .NoError (t , env .Service .DeleteTaxCode (t .Context (), taxcode.DeleteTaxCodeInput {
146+ NamespacedID : models.NamespacedID {Namespace : dns , ID : deleted .ID },
147+ }))
148+
149+ _ , err := env .Service .UpsertOrganizationDefaultTaxCodes (t .Context (), taxcode.UpsertOrganizationDefaultTaxCodesInput {
150+ Namespace : dns ,
151+ InvoicingTaxCodeID : active .ID ,
152+ CreditGrantTaxCodeID : deleted .ID ,
153+ })
154+ require .Error (t , err )
155+ assert .True (t , taxcode .IsTaxCodeNotFoundError (err ), "soft-deleted tax code must not be settable as an organization default" )
156+ })
157+
120158 t .Run ("Create" , func (t * testing.T ) {
121159 ns2 := testutils .NameGenerator .Generate ().Key
122160 invoicing := env .CreateTaxCode (t , ns2 )
0 commit comments