Skip to content

Commit

Permalink
Merge pull request #123 from swan-io/display-fees-original-transaction
Browse files Browse the repository at this point in the history
Display fees original transaction
  • Loading branch information
Nicolas Comont authored Jul 21, 2023
2 parents e33d9cd + 89ba730 commit 432cc07
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 107 deletions.
103 changes: 81 additions & 22 deletions clients/banking/src/components/TransactionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import {
isNullishOrEmpty,
} from "@swan-io/lake/src/utils/nullish";
import { countries } from "@swan-io/shared-business/src/constants/countries";
import dayjs from "dayjs";
import { ScrollView, StyleSheet } from "react-native";
import { P, match } from "ts-pattern";
import { TransactionDetailsFragment } from "../graphql/partner";
import { formatCurrency, formatDateTime, t } from "../utils/i18n";
import { formatCurrency, formatDateTime, locale, t } from "../utils/i18n";
import {
getFeesDescription,
getTransactionRejectedReasonLabel,
Expand Down Expand Up @@ -162,11 +163,11 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
})
.with(
{
type: P.union("SepaCreditTransferOut", "SepaCreditTransferIn"),
originTransactionId: P.string,
originTransaction: {
type: P.union("SepaInstantCreditTransferIn", "SepaInstantCreditTransferOut"),
},
},
() => (
// TODO: update the condition to display the warning message as soon as the original transaction is available
<LakeAlert
anchored={true}
variant="warning"
Expand Down Expand Up @@ -547,26 +548,84 @@ export const TransactionDetail = ({ transaction, large }: Props) => {
{transactionId}
</ReadOnlyFieldList>
))
.with({ __typename: "FeeTransaction" }, ({ counterparty }) => (
<ReadOnlyFieldList>
{bookingDateTime}
{executionDateTime}
.with(
{ __typename: "FeeTransaction" },
({ counterparty, feesType, originTransaction }) => (
<ReadOnlyFieldList>
{bookingDateTime}
{executionDateTime}

<LakeLabel
type="viewSmall"
label={t("transaction.creditorName")}
render={() => (
<LakeText variant="regular" color={colors.gray[900]}>
{counterparty}
</LakeText>
)}
/>
<LakeLabel
type="viewSmall"
label={t("transaction.creditorName")}
render={() => (
<LakeText variant="regular" color={colors.gray[900]}>
{counterparty}
</LakeText>
)}
/>

{rejectedDate}
{rejectedReason}
{transactionId}
</ReadOnlyFieldList>
))
{rejectedDate}
{rejectedReason}
{transactionId}

{originTransaction != null && [
<LakeLabel
type="viewSmall"
label={t("transaction.originalTransactionId")}
render={() => (
<LakeText variant="regular" color={colors.gray[900]}>
{originTransaction.id}
</LakeText>
)}
/>,

<LakeLabel
type="viewSmall"
label={t("transaction.originalTransactionDate")}
render={() => (
<LakeText variant="regular" color={colors.gray[900]}>
{dayjs(originTransaction.executionDate).format(
`${locale.dateFormat} ${locale.timeFormat}`,
)}
</LakeText>
)}
/>,

match(feesType)
.with("CashWithdrawalsOutsideSEPA", "CardPaymentsOutsideSEPA", () => (
<LakeLabel
type="viewSmall"
label={t("transaction.originalTransactionAmount")}
render={() => (
<LakeText variant="regular" color={colors.gray[900]}>
{formatCurrency(
Number(originTransaction.amount.value),
originTransaction.amount.currency,
)}
</LakeText>
)}
/>
))
.with("DirectDebitRejection", () => (
<LakeLabel
type="viewSmall"
label={t("transaction.rejectedAmount")}
render={() => (
<LakeText variant="regular" color={colors.gray[900]}>
{formatCurrency(
Number(originTransaction.amount.value),
originTransaction.amount.currency,
)}
</LakeText>
)}
/>
))
.otherwise(() => null),
]}
</ReadOnlyFieldList>
),
)
.with({ __typename: "CheckTransaction" }, ({ cmc7, rlmcKey }) => {
// The check number is the first 7 numbers of the cmc7
const checkNumber = cmc7.slice(0, 7);
Expand Down
10 changes: 9 additions & 1 deletion clients/banking/src/graphql/partner.gql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ fragment TransactionDetails on Transaction {
id
createdAt
}
originTransactionId
originTransaction {
id
type
executionDate
amount {
currency
value
}
}
statusInfo {
status
__typename
Expand Down
4 changes: 4 additions & 0 deletions clients/banking/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,13 @@
"transaction.instantTransferUnavailable": "Instant transfer unavailable",
"transaction.instantTransferUnavailable.description": "Unfortunately, instant transfers are not available right now. We'll send this as a standard transfer instead.",
"transaction.maskedPan": "Card number",
"transaction.originalTransactionAmount": "Original transaction amount",
"transaction.originalTransactionDate": "Original transaction date",
"transaction.originalTransactionId": "Original transaction ID",
"transaction.paymentDateTime": "Payment date",
"transaction.place": "Place",
"transaction.reference": "Reference",
"transaction.rejectedAmount": "Rejected amount",
"transaction.rejectedDate": "Rejected date",
"transaction.rejectedReason": "Reason",
"transaction.rlmcKey": "RLMCKey",
Expand Down
10 changes: 8 additions & 2 deletions scripts/graphql/dist/partner-idless-objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"AddSingleUseVirtualCardSuccessForProjectOwnerPayload",
"AddSingleUseVirtualCardSuccessForUserPayload",
"AddVirtualIbanEntrySuccessPayload",
"AllowedValue",
"AllowSddSuccessPayload",
"AllowSddVirtualIbanEntrySuccessPayload",
"AlreadyValidPhysicalCardRejection",
Expand Down Expand Up @@ -107,6 +108,7 @@
"CreateCapitalDepositCaseSuccessPayload",
"CreateMultiConsentSuccessPayload",
"CsvStatement",
"DateField",
"DebtorAccountClosedRejection",
"DebtorAccountNotAllowedRejection",
"DenySddSuccessPayload",
Expand Down Expand Up @@ -189,6 +191,7 @@
"InternalErrorRejection",
"InternalPaymentMandateDebtor",
"InternalReceivedDirectDebitMandateCreditor",
"InternationalBeneficiaryDynamicForms",
"InvalidArgumentRejection",
"InvalidArgumentRejectionField",
"InvalidIban",
Expand Down Expand Up @@ -269,6 +272,7 @@
"ProjectSettingsNotFound",
"ProjectSettingsStatusNotReachable",
"PublicOnboardingDisabledRejection",
"RadioField",
"Reachability",
"ReceivedDirectDebitMandateConnection",
"ReceivedDirectDebitMandateEdge",
Expand All @@ -287,15 +291,17 @@
"ReleasedTransactionStatusInfo",
"ReportExchangeRate",
"RequestMerchantPaymentMethodsSuccessPayload",
"RequestMerchantProfileUpdateSuccessPayload",
"RequestSupportingDocumentCollectionReviewSuccessPayload",
"RequestUpdateMerchantProfileSuccessPayload",
"RestrictedTo",
"RestrictedToUserRejection",
"ResumeAccountMembershipSuccessPayload",
"ResumePhysicalCardSuccessPayload",
"RollingReserve",
"ScheduleStandingOrderSuccessPayload",
"Scheme",
"SchemeWrongRejection",
"SelectField",
"SEPACreditTransferInCreditor",
"SEPACreditTransferInDebtor",
"SEPACreditTransferInternalInDebtor",
Expand Down Expand Up @@ -357,12 +363,12 @@
"SuspendPhysicalCardSuccessPayload",
"SuspendReceivedDirectDebitMandatedRejection",
"SuspendReceivedDirectDebitMandateSuccessPayload",
"TextField",
"TooManyChildConsentsRejection",
"TooManyItemsRejection",
"TransactionConnection",
"TransactionEdge",
"TransactionNotFoundRejection",
"TransactionReservedAmount",
"UpcomingTransactionStatusInfo",
"UpdateAccountHolderSuccessPayload",
"UpdateAccountMembershipSuccessPayload",
Expand Down
Loading

0 comments on commit 432cc07

Please sign in to comment.