Added receipt print out at end of payment processing BOD-93
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<babeledit_project be_version="2.6.1" version="1.2">
|
||||
<babeledit_project version="1.2" be_version="2.6.1">
|
||||
<!--
|
||||
|
||||
BabelEdit project file
|
||||
@@ -6072,6 +6072,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>print</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>search</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -6114,6 +6135,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>sendby</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>text</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CardElement } from "@stripe/react-stripe-js";
|
||||
import { Checkbox, Form, Input } from "antd";
|
||||
import { Checkbox, Form, Input, Radio } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -76,6 +76,17 @@ export function PaymentFormComponent({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t("general.labels.sendby")}
|
||||
name="sendby"
|
||||
initialValue="email"
|
||||
>
|
||||
<Radio.Group>
|
||||
<Radio.Button value="email">{t("general.labels.email")}</Radio.Button>
|
||||
<Radio.Button value="print">{t("general.labels.print")}</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
|
||||
{!!!bodyshop.stripe_acct_id ? (
|
||||
<div style={{ fontStyle: "italic" }}>{t("payments.labels.signup")}</div>
|
||||
) : null}
|
||||
|
||||
@@ -14,6 +14,11 @@ import PaymentForm from "../payment-form/payment-form.container";
|
||||
import axios from "axios";
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import { INSERT_NEW_PAYMENT } from "../../graphql/payments.queries";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import RenderTemplate, {
|
||||
displayTemplateInWindow,
|
||||
} from "../../utils/RenderTemplate";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
paymentModal: selectPayment,
|
||||
@@ -22,6 +27,7 @@ const mapStateToProps = createStructuredSelector({
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("payment")),
|
||||
});
|
||||
|
||||
@@ -30,6 +36,7 @@ function InvoiceEnterModalContainer({
|
||||
toggleModalVisible,
|
||||
bodyshop,
|
||||
currentUser,
|
||||
setEmailOptions,
|
||||
}) {
|
||||
const [form] = Form.useForm();
|
||||
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
||||
@@ -48,7 +55,7 @@ function InvoiceEnterModalContainer({
|
||||
const cardValid = !!!stripeState.error && stripeState.cardComplete;
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
const { useStripe, ...paymentObj } = values;
|
||||
const { useStripe, sendby, ...paymentObj } = values;
|
||||
if (useStripe && !cardValid) return;
|
||||
|
||||
if ((useStripe && !stripe) || !elements) {
|
||||
@@ -106,6 +113,33 @@ function InvoiceEnterModalContainer({
|
||||
notification["error"]({ message: t("payments.errors.payment") });
|
||||
}
|
||||
|
||||
if (sendby === "email") {
|
||||
setEmailOptions({
|
||||
messageOptions: {
|
||||
// to: appData.email,
|
||||
replyTo: bodyshop.email,
|
||||
},
|
||||
template: {
|
||||
name: TemplateList.payment_receipt.key,
|
||||
variables: {
|
||||
id: newPayment.data.insert_payments.returning[0].id,
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
displayTemplateInWindow(
|
||||
await RenderTemplate(
|
||||
{
|
||||
name: TemplateList.payment_receipt.key,
|
||||
variables: {
|
||||
id: newPayment.data.insert_payments.returning[0].id,
|
||||
},
|
||||
},
|
||||
bodyshop
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (actions.refetch) actions.refetch();
|
||||
toggleModalVisible();
|
||||
} catch (error) {
|
||||
|
||||
@@ -401,8 +401,10 @@
|
||||
"no": "No",
|
||||
"out": "Out",
|
||||
"password": "Password",
|
||||
"print": "Print",
|
||||
"search": "Search...",
|
||||
"selectdate": "Select date...",
|
||||
"sendby": "Send By",
|
||||
"text": "Text",
|
||||
"unknown": "Unknown",
|
||||
"username": "Username",
|
||||
|
||||
@@ -401,8 +401,10 @@
|
||||
"no": "",
|
||||
"out": "Afuera",
|
||||
"password": "",
|
||||
"print": "",
|
||||
"search": "Buscar...",
|
||||
"selectdate": "",
|
||||
"sendby": "",
|
||||
"text": "",
|
||||
"unknown": "Desconocido",
|
||||
"username": "",
|
||||
|
||||
@@ -401,8 +401,10 @@
|
||||
"no": "",
|
||||
"out": "En dehors",
|
||||
"password": "",
|
||||
"print": "",
|
||||
"search": "Chercher...",
|
||||
"selectdate": "",
|
||||
"sendby": "",
|
||||
"text": "",
|
||||
"unknown": "Inconnu",
|
||||
"username": "",
|
||||
|
||||
@@ -41,4 +41,10 @@ export const TemplateList = {
|
||||
drivingId: "csi Id",
|
||||
key: "csi_invitation",
|
||||
},
|
||||
payment_receipt: {
|
||||
title: "Payment Receipt",
|
||||
description: "Receipt of payment for customer",
|
||||
drivingId: "Payment Id",
|
||||
key: "payment_receipt",
|
||||
},
|
||||
};
|
||||
|
||||
26
client/templates/payment_receipt/payment_receipt.query.gql
Normal file
26
client/templates/payment_receipt/payment_receipt.query.gql
Normal file
@@ -0,0 +1,26 @@
|
||||
query REPORT_PAYMENT_RECEIPT($id: uuid!) {
|
||||
payments_by_pk(id: $id) {
|
||||
job {
|
||||
id
|
||||
vehicle {
|
||||
id
|
||||
v_model_desc
|
||||
v_make_desc
|
||||
v_model_yr
|
||||
v_vin
|
||||
}
|
||||
ro_number
|
||||
est_number
|
||||
clm_no
|
||||
clm_total
|
||||
ded_amt
|
||||
}
|
||||
id
|
||||
amount
|
||||
memo
|
||||
transactionid
|
||||
stripeid
|
||||
payer
|
||||
type
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<div style="font-family: Arial, Helvetica, sans-serif;">
|
||||
<p style="text-align: center;"><strong>RECEIPT OF PAYMENT</strong></p>
|
||||
<p style="text-align: left;"><strong>Amount</strong>: {{payments_by_pk.amount}}</p>
|
||||
<p style="text-align: left;"><strong>Memo</strong>: {{payments_by_pk.memo}}</p>
|
||||
<p style="text-align: left;"><strong>RO Number</strong>: {{payments_by_pk.job.ro_number}} / {{payments_by_pk.job.est_number}}</p>
|
||||
<p style="text-align: left;"><strong>Payer</strong>: {{payments_by_pk.payer}}</p>
|
||||
<p style="text-align: left;"><strong>StripeID</strong>: {{payments_by_pk.stripeid}}</p>
|
||||
<p style="text-align: left;"><strong>Amount</strong>: {{payments_by_pk.amount}}</p>
|
||||
<p style="text-align: left;"> </p>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: payments
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: true
|
||||
columns:
|
||||
- amount
|
||||
- created_at
|
||||
- exportedat
|
||||
- id
|
||||
- jobid
|
||||
- memo
|
||||
- payer
|
||||
- stripeid
|
||||
- transactionid
|
||||
- updated_at
|
||||
computed_fields: []
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
role: user
|
||||
table:
|
||||
name: payments
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -0,0 +1,37 @@
|
||||
- args:
|
||||
role: user
|
||||
table:
|
||||
name: payments
|
||||
schema: public
|
||||
type: drop_select_permission
|
||||
- args:
|
||||
permission:
|
||||
allow_aggregations: true
|
||||
columns:
|
||||
- amount
|
||||
- created_at
|
||||
- exportedat
|
||||
- id
|
||||
- jobid
|
||||
- memo
|
||||
- payer
|
||||
- stripeid
|
||||
- transactionid
|
||||
- type
|
||||
- updated_at
|
||||
computed_fields: []
|
||||
filter:
|
||||
job:
|
||||
bodyshop:
|
||||
associations:
|
||||
_and:
|
||||
- user:
|
||||
authid:
|
||||
_eq: X-Hasura-User-Id
|
||||
- active:
|
||||
_eq: true
|
||||
role: user
|
||||
table:
|
||||
name: payments
|
||||
schema: public
|
||||
type: create_select_permission
|
||||
@@ -3261,6 +3261,7 @@ tables:
|
||||
- payer
|
||||
- stripeid
|
||||
- transactionid
|
||||
- type
|
||||
- updated_at
|
||||
filter:
|
||||
job:
|
||||
|
||||
Reference in New Issue
Block a user