1#![allow(non_camel_case_types)]
2
3#[cfg_attr(feature = "specta", derive(specta::Type))]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
6pub enum Payment {
7 InstrumentNotDefined,
9 AutomatedClearingHouseCredit,
11 AutomatedClearingHouseDebit,
13 AchDemandDebitReversal,
15 AchDemandCreditReversal,
17 AchDemandCredit,
19 AchDemandDebit,
21 Hold,
23 NationalOrRegionalClearing,
25 InCash,
27 AchSavingsCreditReversal,
29 AchSavingsDebitReversal,
31 AchSavingsCredit,
33 AchSavingsDebit,
35 BookentryCredit,
37 BookentryDebit,
39 AchDemandCashConcentrationDisbursementCcdCredit,
41 AchDemandCashConcentrationDisbursementCcdDebit,
43 AchDemandCorporateTradePaymentCtpCredit,
45 Cheque,
47 BankersDraft,
49 CertifiedBankersDraft,
51 BankChequeIssuedByABankingOrSimilarEstablishment,
53 BillExchangeAwaitingAcceptance,
55 CertifiedCheque,
57 LocalCheque,
59 AchDemandCorporateTradePaymentCtpDebit,
61 AchDemandCorporateTradeExchangeCtxCredit,
63 AchDemandCorporateTradeExchangeCtxDebit,
65 CreditTransfer,
69 DebitTransfer,
73 AchDemandCashConcentrationDisbursementPlusCcd,
75 AchDemandCashConcentrationDisbursementPlusCcd_Dup,
77 AchPrearrangedPaymentAndDepositPpd,
79 AchSavingsCashConcentrationDisbursementCcdCredit,
81 AchSavingsCashConcentrationDisbursementCcdDebit,
83 AchSavingsCorporateTradePaymentCtpCredit,
85 AchSavingsCorporateTradePaymentCtpDebit,
87 AchSavingsCorporateTradeExchangeCtxCredit,
89 AchSavingsCorporateTradeExchangeCtxDebit,
91 AchSavingsCashConcentrationDisbursementPlusCcd,
93 PaymentToBankAccount,
95 AchSavingsCashConcentrationDisbursementPlusCcd_Dup,
97 AcceptedBillExchange,
99 ReferencedHomeBankingCreditTransfer,
101 InterbankDebitTransfer,
103 HomeBankingDebitTransfer,
105 BankCard,
109 DirectDebit,
111 PaymentByPostgiro,
113 FrNorme697TelereglementCfonbFrenchOrganisationFor,
115 UrgentCommercialPayment,
117 UrgentTreasuryPayment,
119 CreditCard,
121 DebitCard,
123 Bankgiro,
125 StandingAgreement,
129 SepaCreditTransfer,
133 SepaDirectDebit,
137 PromissoryNote,
139 PromissoryNoteSignedByDebtor,
141 PromissoryNoteSignedByDebtorAndEndorsedByABank,
143 PromissoryNoteSignedByDebtorAndEndorsedByA,
145 PromissoryNoteSignedByABank,
147 PromissoryNoteSignedByABankAndEndorsedByAnother,
149 PromissoryNoteSignedByAThirdParty,
151 PromissoryNoteSignedByAThirdPartyAndEndorsedByA,
153 OnlinePaymentService,
155 TransferAdvice,
157 BillDrawnByCreditorOnDebtor,
159 BillDrawnByCreditorOnABank,
161 BillDrawnByCreditorEndorsedByAnotherBank,
163 BillDrawnByCreditorOnABankAndEndorsedByA,
165 BillDrawnByCreditorOnAThirdParty,
167 BillDrawnByCreditorOnThirdPartyAcceptedAnd,
169 NotTransferableBankersDraft,
171 NotTransferableLocalCheque,
173 ReferenceGiro,
175 UrgentGiro,
177 FreeFormatGiro,
179 RequestedMethodForPaymentWasNotUsed,
181 ClearingBetweenPartners,
183 JpElectronicallyRecordedMonetaryClaims,
185 MutuallyDefined,
187}
188
189impl std::fmt::Display for Payment {
190 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
191 write!(f, "{}", <Self as crate::Code>::code(*self))
192 }
193}
194
195impl std::str::FromStr for Payment {
196 type Err = ();
197 fn from_str(s: &str) -> Result<Self, Self::Err> {
198 <Self as crate::FromCode>::from_code(s).ok_or(())
199 }
200}
201
202impl crate::Code for Payment {
203 fn code(self) -> &'static str {
204 match self {
205 Payment::InstrumentNotDefined => "1",
206 Payment::AutomatedClearingHouseCredit => "2",
207 Payment::AutomatedClearingHouseDebit => "3",
208 Payment::AchDemandDebitReversal => "4",
209 Payment::AchDemandCreditReversal => "5",
210 Payment::AchDemandCredit => "6",
211 Payment::AchDemandDebit => "7",
212 Payment::Hold => "8",
213 Payment::NationalOrRegionalClearing => "9",
214 Payment::InCash => "10",
215 Payment::AchSavingsCreditReversal => "11",
216 Payment::AchSavingsDebitReversal => "12",
217 Payment::AchSavingsCredit => "13",
218 Payment::AchSavingsDebit => "14",
219 Payment::BookentryCredit => "15",
220 Payment::BookentryDebit => "16",
221 Payment::AchDemandCashConcentrationDisbursementCcdCredit => "17",
222 Payment::AchDemandCashConcentrationDisbursementCcdDebit => "18",
223 Payment::AchDemandCorporateTradePaymentCtpCredit => "19",
224 Payment::Cheque => "20",
225 Payment::BankersDraft => "21",
226 Payment::CertifiedBankersDraft => "22",
227 Payment::BankChequeIssuedByABankingOrSimilarEstablishment => "23",
228 Payment::BillExchangeAwaitingAcceptance => "24",
229 Payment::CertifiedCheque => "25",
230 Payment::LocalCheque => "26",
231 Payment::AchDemandCorporateTradePaymentCtpDebit => "27",
232 Payment::AchDemandCorporateTradeExchangeCtxCredit => "28",
233 Payment::AchDemandCorporateTradeExchangeCtxDebit => "29",
234 Payment::CreditTransfer => "30",
235 Payment::DebitTransfer => "31",
236 Payment::AchDemandCashConcentrationDisbursementPlusCcd => "32",
237 Payment::AchDemandCashConcentrationDisbursementPlusCcd_Dup => "33",
238 Payment::AchPrearrangedPaymentAndDepositPpd => "34",
239 Payment::AchSavingsCashConcentrationDisbursementCcdCredit => "35",
240 Payment::AchSavingsCashConcentrationDisbursementCcdDebit => "36",
241 Payment::AchSavingsCorporateTradePaymentCtpCredit => "37",
242 Payment::AchSavingsCorporateTradePaymentCtpDebit => "38",
243 Payment::AchSavingsCorporateTradeExchangeCtxCredit => "39",
244 Payment::AchSavingsCorporateTradeExchangeCtxDebit => "40",
245 Payment::AchSavingsCashConcentrationDisbursementPlusCcd => "41",
246 Payment::PaymentToBankAccount => "42",
247 Payment::AchSavingsCashConcentrationDisbursementPlusCcd_Dup => "43",
248 Payment::AcceptedBillExchange => "44",
249 Payment::ReferencedHomeBankingCreditTransfer => "45",
250 Payment::InterbankDebitTransfer => "46",
251 Payment::HomeBankingDebitTransfer => "47",
252 Payment::BankCard => "48",
253 Payment::DirectDebit => "49",
254 Payment::PaymentByPostgiro => "50",
255 Payment::FrNorme697TelereglementCfonbFrenchOrganisationFor => "51",
256 Payment::UrgentCommercialPayment => "52",
257 Payment::UrgentTreasuryPayment => "53",
258 Payment::CreditCard => "54",
259 Payment::DebitCard => "55",
260 Payment::Bankgiro => "56",
261 Payment::StandingAgreement => "57",
262 Payment::SepaCreditTransfer => "58",
263 Payment::SepaDirectDebit => "59",
264 Payment::PromissoryNote => "60",
265 Payment::PromissoryNoteSignedByDebtor => "61",
266 Payment::PromissoryNoteSignedByDebtorAndEndorsedByABank => "62",
267 Payment::PromissoryNoteSignedByDebtorAndEndorsedByA => "63",
268 Payment::PromissoryNoteSignedByABank => "64",
269 Payment::PromissoryNoteSignedByABankAndEndorsedByAnother => "65",
270 Payment::PromissoryNoteSignedByAThirdParty => "66",
271 Payment::PromissoryNoteSignedByAThirdPartyAndEndorsedByA => "67",
272 Payment::OnlinePaymentService => "68",
273 Payment::TransferAdvice => "69",
274 Payment::BillDrawnByCreditorOnDebtor => "70",
275 Payment::BillDrawnByCreditorOnABank => "74",
276 Payment::BillDrawnByCreditorEndorsedByAnotherBank => "75",
277 Payment::BillDrawnByCreditorOnABankAndEndorsedByA => "76",
278 Payment::BillDrawnByCreditorOnAThirdParty => "77",
279 Payment::BillDrawnByCreditorOnThirdPartyAcceptedAnd => "78",
280 Payment::NotTransferableBankersDraft => "91",
281 Payment::NotTransferableLocalCheque => "92",
282 Payment::ReferenceGiro => "93",
283 Payment::UrgentGiro => "94",
284 Payment::FreeFormatGiro => "95",
285 Payment::RequestedMethodForPaymentWasNotUsed => "96",
286 Payment::ClearingBetweenPartners => "97",
287 Payment::JpElectronicallyRecordedMonetaryClaims => "98",
288 Payment::MutuallyDefined => "ZZZ",
289 }
290 }
291}
292
293impl crate::Description for Payment {
294 fn description(self) -> &'static str {
295 match self {
296 Payment::InstrumentNotDefined => "Instrument not defined",
297 Payment::AutomatedClearingHouseCredit => "Automated clearing house credit",
298 Payment::AutomatedClearingHouseDebit => "Automated clearing house debit",
299 Payment::AchDemandDebitReversal => "ACH demand debit reversal",
300 Payment::AchDemandCreditReversal => "ACH demand credit reversal",
301 Payment::AchDemandCredit => "ACH demand credit",
302 Payment::AchDemandDebit => "ACH demand debit",
303 Payment::Hold => "Hold",
304 Payment::NationalOrRegionalClearing => "National or regional clearing",
305 Payment::InCash => "In cash",
306 Payment::AchSavingsCreditReversal => "ACH savings credit reversal",
307 Payment::AchSavingsDebitReversal => "ACH savings debit reversal",
308 Payment::AchSavingsCredit => "ACH savings credit",
309 Payment::AchSavingsDebit => "ACH savings debit",
310 Payment::BookentryCredit => "Bookentry credit",
311 Payment::BookentryDebit => "Bookentry debit",
312 Payment::AchDemandCashConcentrationDisbursementCcdCredit => {
313 "ACH demand cash concentration/disbursement (CCD) credit"
314 }
315 Payment::AchDemandCashConcentrationDisbursementCcdDebit => {
316 "ACH demand cash concentration/disbursement (CCD) debit"
317 }
318 Payment::AchDemandCorporateTradePaymentCtpCredit => {
319 "ACH demand corporate trade payment (CTP) credit"
320 }
321 Payment::Cheque => "Cheque",
322 Payment::BankersDraft => "Banker's draft",
323 Payment::CertifiedBankersDraft => "Certified banker's draft",
324 Payment::BankChequeIssuedByABankingOrSimilarEstablishment => {
325 "Bank cheque (issued by a banking or similar establishment)"
326 }
327 Payment::BillExchangeAwaitingAcceptance => "Bill of exchange awaiting acceptance",
328 Payment::CertifiedCheque => "Certified cheque",
329 Payment::LocalCheque => "Local cheque",
330 Payment::AchDemandCorporateTradePaymentCtpDebit => {
331 "ACH demand corporate trade payment (CTP) debit"
332 }
333 Payment::AchDemandCorporateTradeExchangeCtxCredit => {
334 "ACH demand corporate trade exchange (CTX) credit"
335 }
336 Payment::AchDemandCorporateTradeExchangeCtxDebit => {
337 "ACH demand corporate trade exchange (CTX) debit"
338 }
339 Payment::CreditTransfer => "Credit transfer",
340 Payment::DebitTransfer => "Debit transfer",
341 Payment::AchDemandCashConcentrationDisbursementPlusCcd => {
342 "ACH demand cash concentration/disbursement plus (CCD+)"
343 }
344 Payment::AchDemandCashConcentrationDisbursementPlusCcd_Dup => {
345 "ACH demand cash concentration/disbursement plus (CCD+)"
346 }
347 Payment::AchPrearrangedPaymentAndDepositPpd => {
348 "ACH prearranged payment and deposit (PPD)"
349 }
350 Payment::AchSavingsCashConcentrationDisbursementCcdCredit => {
351 "ACH savings cash concentration/disbursement (CCD) credit"
352 }
353 Payment::AchSavingsCashConcentrationDisbursementCcdDebit => {
354 "ACH savings cash concentration/disbursement (CCD) debit"
355 }
356 Payment::AchSavingsCorporateTradePaymentCtpCredit => {
357 "ACH savings corporate trade payment (CTP) credit"
358 }
359 Payment::AchSavingsCorporateTradePaymentCtpDebit => {
360 "ACH savings corporate trade payment (CTP) debit"
361 }
362 Payment::AchSavingsCorporateTradeExchangeCtxCredit => {
363 "ACH savings corporate trade exchange (CTX) credit"
364 }
365 Payment::AchSavingsCorporateTradeExchangeCtxDebit => {
366 "ACH savings corporate trade exchange (CTX) debit"
367 }
368 Payment::AchSavingsCashConcentrationDisbursementPlusCcd => {
369 "ACH savings cash concentration/disbursement plus (CCD+)"
370 }
371 Payment::PaymentToBankAccount => "Payment to bank account",
372 Payment::AchSavingsCashConcentrationDisbursementPlusCcd_Dup => {
373 "ACH savings cash concentration/disbursement plus (CCD+)"
374 }
375 Payment::AcceptedBillExchange => "Accepted bill of exchange",
376 Payment::ReferencedHomeBankingCreditTransfer => {
377 "Referenced home-banking credit transfer"
378 }
379 Payment::InterbankDebitTransfer => "Interbank debit transfer",
380 Payment::HomeBankingDebitTransfer => "Home-banking debit transfer",
381 Payment::BankCard => "Bank card",
382 Payment::DirectDebit => "Direct debit",
383 Payment::PaymentByPostgiro => "Payment by postgiro",
384 Payment::FrNorme697TelereglementCfonbFrenchOrganisationFor => {
385 "FR, norme 6 97-Telereglement CFONB (French Organisation for"
386 }
387 Payment::UrgentCommercialPayment => "Urgent commercial payment",
388 Payment::UrgentTreasuryPayment => "Urgent Treasury Payment",
389 Payment::CreditCard => "Credit card",
390 Payment::DebitCard => "Debit card",
391 Payment::Bankgiro => "Bankgiro",
392 Payment::StandingAgreement => "Standing agreement",
393 Payment::SepaCreditTransfer => "SEPA credit transfer",
394 Payment::SepaDirectDebit => "SEPA direct debit",
395 Payment::PromissoryNote => "Promissory note",
396 Payment::PromissoryNoteSignedByDebtor => "Promissory note signed by the debtor",
397 Payment::PromissoryNoteSignedByDebtorAndEndorsedByABank => {
398 "Promissory note signed by the debtor and endorsed by a bank"
399 }
400 Payment::PromissoryNoteSignedByDebtorAndEndorsedByA => {
401 "Promissory note signed by the debtor and endorsed by a"
402 }
403 Payment::PromissoryNoteSignedByABank => "Promissory note signed by a bank",
404 Payment::PromissoryNoteSignedByABankAndEndorsedByAnother => {
405 "Promissory note signed by a bank and endorsed by another"
406 }
407 Payment::PromissoryNoteSignedByAThirdParty => "Promissory note signed by a third party",
408 Payment::PromissoryNoteSignedByAThirdPartyAndEndorsedByA => {
409 "Promissory note signed by a third party and endorsed by a"
410 }
411 Payment::OnlinePaymentService => "Online payment service",
412 Payment::TransferAdvice => "Transfer Advice",
413 Payment::BillDrawnByCreditorOnDebtor => "Bill drawn by the creditor on the debtor",
414 Payment::BillDrawnByCreditorOnABank => "Bill drawn by the creditor on a bank",
415 Payment::BillDrawnByCreditorEndorsedByAnotherBank => {
416 "Bill drawn by the creditor, endorsed by another bank"
417 }
418 Payment::BillDrawnByCreditorOnABankAndEndorsedByA => {
419 "Bill drawn by the creditor on a bank and endorsed by a"
420 }
421 Payment::BillDrawnByCreditorOnAThirdParty => {
422 "Bill drawn by the creditor on a third party"
423 }
424 Payment::BillDrawnByCreditorOnThirdPartyAcceptedAnd => {
425 "Bill drawn by creditor on third party, accepted and"
426 }
427 Payment::NotTransferableBankersDraft => "Not transferable banker's draft",
428 Payment::NotTransferableLocalCheque => "Not transferable local cheque",
429 Payment::ReferenceGiro => "Reference giro",
430 Payment::UrgentGiro => "Urgent giro",
431 Payment::FreeFormatGiro => "Free format giro",
432 Payment::RequestedMethodForPaymentWasNotUsed => {
433 "Requested method for payment was not used"
434 }
435 Payment::ClearingBetweenPartners => "Clearing between partners",
436 Payment::JpElectronicallyRecordedMonetaryClaims => {
437 "JP, Electronically Recorded Monetary Claims"
438 }
439 Payment::MutuallyDefined => "Mutually defined",
440 }
441 }
442}
443
444impl crate::FromCode for Payment {
445 fn from_code(code: &str) -> Option<Self>
446 where
447 Self: Sized,
448 {
449 match code {
450 "1" => Some(Payment::InstrumentNotDefined),
451 "2" => Some(Payment::AutomatedClearingHouseCredit),
452 "3" => Some(Payment::AutomatedClearingHouseDebit),
453 "4" => Some(Payment::AchDemandDebitReversal),
454 "5" => Some(Payment::AchDemandCreditReversal),
455 "6" => Some(Payment::AchDemandCredit),
456 "7" => Some(Payment::AchDemandDebit),
457 "8" => Some(Payment::Hold),
458 "9" => Some(Payment::NationalOrRegionalClearing),
459 "10" => Some(Payment::InCash),
460 "11" => Some(Payment::AchSavingsCreditReversal),
461 "12" => Some(Payment::AchSavingsDebitReversal),
462 "13" => Some(Payment::AchSavingsCredit),
463 "14" => Some(Payment::AchSavingsDebit),
464 "15" => Some(Payment::BookentryCredit),
465 "16" => Some(Payment::BookentryDebit),
466 "17" => Some(Payment::AchDemandCashConcentrationDisbursementCcdCredit),
467 "18" => Some(Payment::AchDemandCashConcentrationDisbursementCcdDebit),
468 "19" => Some(Payment::AchDemandCorporateTradePaymentCtpCredit),
469 "20" => Some(Payment::Cheque),
470 "21" => Some(Payment::BankersDraft),
471 "22" => Some(Payment::CertifiedBankersDraft),
472 "23" => Some(Payment::BankChequeIssuedByABankingOrSimilarEstablishment),
473 "24" => Some(Payment::BillExchangeAwaitingAcceptance),
474 "25" => Some(Payment::CertifiedCheque),
475 "26" => Some(Payment::LocalCheque),
476 "27" => Some(Payment::AchDemandCorporateTradePaymentCtpDebit),
477 "28" => Some(Payment::AchDemandCorporateTradeExchangeCtxCredit),
478 "29" => Some(Payment::AchDemandCorporateTradeExchangeCtxDebit),
479 "30" => Some(Payment::CreditTransfer),
480 "31" => Some(Payment::DebitTransfer),
481 "32" => Some(Payment::AchDemandCashConcentrationDisbursementPlusCcd),
482 "33" => Some(Payment::AchDemandCashConcentrationDisbursementPlusCcd_Dup),
483 "34" => Some(Payment::AchPrearrangedPaymentAndDepositPpd),
484 "35" => Some(Payment::AchSavingsCashConcentrationDisbursementCcdCredit),
485 "36" => Some(Payment::AchSavingsCashConcentrationDisbursementCcdDebit),
486 "37" => Some(Payment::AchSavingsCorporateTradePaymentCtpCredit),
487 "38" => Some(Payment::AchSavingsCorporateTradePaymentCtpDebit),
488 "39" => Some(Payment::AchSavingsCorporateTradeExchangeCtxCredit),
489 "40" => Some(Payment::AchSavingsCorporateTradeExchangeCtxDebit),
490 "41" => Some(Payment::AchSavingsCashConcentrationDisbursementPlusCcd),
491 "42" => Some(Payment::PaymentToBankAccount),
492 "43" => Some(Payment::AchSavingsCashConcentrationDisbursementPlusCcd_Dup),
493 "44" => Some(Payment::AcceptedBillExchange),
494 "45" => Some(Payment::ReferencedHomeBankingCreditTransfer),
495 "46" => Some(Payment::InterbankDebitTransfer),
496 "47" => Some(Payment::HomeBankingDebitTransfer),
497 "48" => Some(Payment::BankCard),
498 "49" => Some(Payment::DirectDebit),
499 "50" => Some(Payment::PaymentByPostgiro),
500 "51" => Some(Payment::FrNorme697TelereglementCfonbFrenchOrganisationFor),
501 "52" => Some(Payment::UrgentCommercialPayment),
502 "53" => Some(Payment::UrgentTreasuryPayment),
503 "54" => Some(Payment::CreditCard),
504 "55" => Some(Payment::DebitCard),
505 "56" => Some(Payment::Bankgiro),
506 "57" => Some(Payment::StandingAgreement),
507 "58" => Some(Payment::SepaCreditTransfer),
508 "59" => Some(Payment::SepaDirectDebit),
509 "60" => Some(Payment::PromissoryNote),
510 "61" => Some(Payment::PromissoryNoteSignedByDebtor),
511 "62" => Some(Payment::PromissoryNoteSignedByDebtorAndEndorsedByABank),
512 "63" => Some(Payment::PromissoryNoteSignedByDebtorAndEndorsedByA),
513 "64" => Some(Payment::PromissoryNoteSignedByABank),
514 "65" => Some(Payment::PromissoryNoteSignedByABankAndEndorsedByAnother),
515 "66" => Some(Payment::PromissoryNoteSignedByAThirdParty),
516 "67" => Some(Payment::PromissoryNoteSignedByAThirdPartyAndEndorsedByA),
517 "68" => Some(Payment::OnlinePaymentService),
518 "69" => Some(Payment::TransferAdvice),
519 "70" => Some(Payment::BillDrawnByCreditorOnDebtor),
520 "74" => Some(Payment::BillDrawnByCreditorOnABank),
521 "75" => Some(Payment::BillDrawnByCreditorEndorsedByAnotherBank),
522 "76" => Some(Payment::BillDrawnByCreditorOnABankAndEndorsedByA),
523 "77" => Some(Payment::BillDrawnByCreditorOnAThirdParty),
524 "78" => Some(Payment::BillDrawnByCreditorOnThirdPartyAcceptedAnd),
525 "91" => Some(Payment::NotTransferableBankersDraft),
526 "92" => Some(Payment::NotTransferableLocalCheque),
527 "93" => Some(Payment::ReferenceGiro),
528 "94" => Some(Payment::UrgentGiro),
529 "95" => Some(Payment::FreeFormatGiro),
530 "96" => Some(Payment::RequestedMethodForPaymentWasNotUsed),
531 "97" => Some(Payment::ClearingBetweenPartners),
532 "98" => Some(Payment::JpElectronicallyRecordedMonetaryClaims),
533 "ZZZ" => Some(Payment::MutuallyDefined),
534 _ => None,
535 }
536 }
537}