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