Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Expand payment section
dominik-zeglena260a60811d4
diff --git a/saleor/static/dashboard-next/components/Money/index.ts b/saleor/static/dashboard-next/components/Money/index.tsindex ace2118caa..e8e2d3a596 100644--- a/saleor/static/dashboard-next/components/Money/index.ts+++ b/saleor/static/dashboard-next/components/Money/index.ts@@ -1,2 +1,17 @@+import Money from "./Money";+export { default } from "./Money";export * from "./Money";++export function addMoney(init: Money, ...args: Money[]): Money {+ return {+ amount: args.reduce((acc, curr) => acc + curr.amount, init.amount),+ currency: init.currency+ };+}+export function subtractMoney(init: Money, ...args: Money[]): Money {+ return {+ amount: args.reduce((acc, curr) => acc - curr.amount, init.amount),+ currency: init.currency+ };+}diff --git a/saleor/static/dashboard-next/orders/components/OrderPayment/OrderPayment.tsx b/saleor/static/dashboard-next/orders/components/OrderPayment/OrderPayment.tsxindex 75ed762c0f..a8ab1c54bb 100644--- a/saleor/static/dashboard-next/orders/components/OrderPayment/OrderPayment.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderPayment/OrderPayment.tsx@@ -12,7 +12,7 @@ import * as React from "react";import CardTitle from "../../../components/CardTitle";import { Hr } from "../../../components/Hr";-import Money from "../../../components/Money";+import Money, { subtractMoney } from "../../../components/Money";import Skeleton from "../../../components/Skeleton";import StatusLabel from "../../../components/StatusLabel";import i18n from "../../../i18n";@@ -151,6 +151,50 @@ const OrderPayment = withStyles(styles, { name: "OrderPayment" })(</tbody></table></CardContent>+ <Hr />+ <CardContent>+ <table className={classes.root}>+ <tbody>+ <tr>+ <td>{i18n.t("Preauthorized amount")}</td>+ <td className={classes.textRight}>+ {maybe(() => order.totalAuthorized.amount) === undefined ? (+ <Skeleton />+ ) : (+ <Money money={order.totalAuthorized} />+ )}+ </td>+ </tr>+ <tr>+ <td>{i18n.t("Captured amount")}</td>+ <td className={classes.textRight}>+ {maybe(() => order.totalCaptured.amount) === undefined ? (+ <Skeleton />+ ) : (+ <Money money={order.totalCaptured} />+ )}+ </td>+ </tr>+ <tr className={classes.totalRow}>+ <td>{i18n.t("Balance")}</td>+ <td className={classes.textRight}>+ {maybe(+ () => order.total.gross.amount && order.totalCaptured.amount+ ) === undefined ? (+ <Skeleton />+ ) : (+ <Money+ money={subtractMoney(+ order.totalCaptured,+ order.total.gross+ )}+ />+ )}+ </td>+ </tr>+ </tbody>+ </table>+ </CardContent>{maybe(() => order.status) !== OrderStatus.CANCELED &&(canCapture || canRefund || canVoid || canMarkAsPaid) && (<>diff --git a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snapindex 6f66548e0a..0008d53e28 100644--- a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap+++ b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap@@ -22253,6 +22253,51 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `</tbody></table></div>+ <hr+ class="Hr-root-id"+ />+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div></div><divclass="OrderHistory-root-id"@@ -23156,6 +23201,51 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -24137,6 +24227,51 @@ exports[`Storyshots Views / Orders / Order details fulfilled 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -24846,6 +24981,63 @@ exports[`Storyshots Views / Orders / Order details loading 1`] = `</tbody></table></div>+ <hr+ class="Hr-root-id"+ />+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ <span+ class="Skeleton-skeleton-id"+ >+ + </span>+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ <span+ class="Skeleton-skeleton-id"+ >+ + </span>+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ <span+ class="Skeleton-skeleton-id"+ >+ + </span>+ </td>+ </tr>+ </tbody>+ </table>+ </div></div><divclass="OrderHistory-root-id"@@ -25652,6 +25844,51 @@ exports[`Storyshots Views / Orders / Order details no customer note 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -26633,6 +26870,51 @@ exports[`Storyshots Views / Orders / Order details no payment 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -27614,6 +27896,51 @@ exports[`Storyshots Views / Orders / Order details no shipping address 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -28565,28 +28892,73 @@ exports[`Storyshots Views / Orders / Order details partially fulfilled 1`] = `</tr><tr><td>- Shipping- </td>- <td>- Registred priority+ Shipping+ </td>+ <td>+ Registred priority+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $19.98+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Total+ </td>+ <td />+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ />+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount</td><tdclass="OrderPayment-textRight-id">- $19.98+ $0.00</td></tr><trclass="OrderPayment-totalRow-id"><td>- Total+ Balance</td>- <td /><tdclass="OrderPayment-textRight-id">- $234.93+ -$234.93</td></tr></tbody>@@ -29576,6 +29948,51 @@ exports[`Storyshots Views / Orders / Order details payment confirmed 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -30557,6 +30974,51 @@ exports[`Storyshots Views / Orders / Order details payment error 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -31538,6 +32000,51 @@ exports[`Storyshots Views / Orders / Order details pending payment 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -32519,6 +33026,51 @@ exports[`Storyshots Views / Orders / Order details refunded payment 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -33500,6 +34052,51 @@ exports[`Storyshots Views / Orders / Order details rejected payment 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">@@ -34481,6 +35078,51 @@ exports[`Storyshots Views / Orders / Order details unfulfilled 1`] = `<hrclass="Hr-root-id"/>+ <div+ class="MuiCardContent-root-id"+ >+ <table+ class="OrderPayment-root-id"+ >+ <tbody>+ <tr>+ <td>+ Preauthorized amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $234.93+ </td>+ </tr>+ <tr>+ <td>+ Captured amount+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ $0.00+ </td>+ </tr>+ <tr+ class="OrderPayment-totalRow-id"+ >+ <td>+ Balance+ </td>+ <td+ class="OrderPayment-textRight-id"+ >+ -$234.93+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <hr+ class="Hr-root-id"+ /><divclass="MuiCardActions-root-id">