Fix: sales.

This commit is contained in:
elforjani13
2022-03-22 23:58:03 +02:00
parent 50f1979c9f
commit a913b84723
29 changed files with 131 additions and 263 deletions

View File

@@ -1,4 +1,5 @@
import React from 'react';
import intl from 'react-intl-universal';
import styled from 'styled-components';
import { FFormGroup, FEditableText, FormattedMessage as T } from 'components';
@@ -8,14 +9,12 @@ export function PaymentReceiveFormFootetLeft() {
{/* --------- Statement--------- */}
<TermsConditsFormGroup
name={'statement'}
label={<T id={'statement'} />}
label={<T id={'payment_receive_form.label.statement'} />}
hintText={'Will be displayed on the Payment'}
>
<FEditableText
name={'statement'}
placeholder={
<T id={'thanks_for_your_business_and_have_a_great_day'} />
}
placeholder={intl.get('payment_receive_form.statement.placeholder')}
/>
</TermsConditsFormGroup>
</React.Fragment>

View File

@@ -15,14 +15,13 @@ export function PaymentReceiveFormFootetRight() {
return (
<PaymentReceiveTotalLines labelColWidth={'180px'} amountColWidth={'180px'}>
<TotalLine
title={<T id={'estimate.details.subtotal'} />}
title={<T id={'payment_receive_form.label.subtotal'} />}
value={formattedSubtotal}
borderStyle={TotalLineBorderStyle.None}
/>
<TotalLine
title={<T id={'estimate.details.total'} />}
title={<T id={'payment_receive_form.label.total'} />}
value={formattedTotal}
// borderStyle={TotalLineBorderStyle.SingleDark}
textStyle={TotalLineTextStyle.Bold}
/>
</PaymentReceiveTotalLines>

View File

@@ -3,25 +3,17 @@ import { useParams } from 'react-router-dom';
import { PaymentReceiveFormProvider } from './PaymentReceiveFormProvider';
import PaymentReceiveForm from './PaymentReceiveForm';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose } from 'utils';
/**
* Payment receive form page.
*/
function PaymentReceiveFormPage({
// #withCurrentOrganization
organization: { base_currency },
}) {
export default function PaymentReceiveFormPage() {
const { id: paymentReceiveId } = useParams();
const paymentReceiveIdInt = parseInt(paymentReceiveId, 10);
return (
<PaymentReceiveFormProvider
paymentReceiveId={paymentReceiveIdInt}
baseCurrency={base_currency}
>
<PaymentReceiveFormProvider paymentReceiveId={paymentReceiveIdInt}>
<PaymentReceiveForm paymentReceiveId={paymentReceiveIdInt} />
</PaymentReceiveFormProvider>
);
}
export default compose(withCurrentOrganization())(PaymentReceiveFormPage);

View File

@@ -1,5 +1,5 @@
import React, { createContext, useContext } from 'react';
import {isEqual, isUndefined } from 'lodash';
import { isEqual, isUndefined } from 'lodash';
import { Features } from 'common';
import { useFeatureCan } from 'hooks/state';
import { DashboardInsider } from 'components';
@@ -19,17 +19,10 @@ const PaymentReceiveFormContext = createContext();
/**
* Payment receive form provider.
*/
function PaymentReceiveFormProvider({
query,
paymentReceiveId,
baseCurrency,
...props
}) {
function PaymentReceiveFormProvider({ query, paymentReceiveId, ...props }) {
// Form state.
const [submitPayload, setSubmitPayload] = React.useState({});
const [selectCustomer, setSelectCustomer] = React.useState(null);
// Features guard.
const { featureCan } = useFeatureCan();
const isBranchFeatureCan = featureCan(Features.Branches);
@@ -73,11 +66,6 @@ function PaymentReceiveFormProvider({
const { mutateAsync: editPaymentReceiveMutate } = useEditPaymentReceive();
const { mutateAsync: createPaymentReceiveMutate } = useCreatePaymentReceive();
// Determines whether the foreign customer.
const isForeignCustomer =
!isEqual(selectCustomer?.currency_code, baseCurrency) &&
!isUndefined(selectCustomer?.currency_code);
// Provider payload.
const provider = {
paymentReceiveId,
@@ -86,7 +74,6 @@ function PaymentReceiveFormProvider({
accounts,
customers,
branches,
baseCurrency,
isPaymentLoading,
isAccountsLoading,
@@ -94,13 +81,10 @@ function PaymentReceiveFormProvider({
isCustomersLoading,
isFeatureLoading,
isBranchesSuccess,
isForeignCustomer,
isNewMode,
submitPayload,
setSubmitPayload,
selectCustomer,
setSelectCustomer,
editPaymentReceiveMutate,
createPaymentReceiveMutate,

View File

@@ -59,7 +59,7 @@ function PaymentReceiveFormSelectBranch() {
function PaymentReceiveBranchSelectButton({ label }) {
return (
<Button
text={intl.get('invoice.branch_button.label', { label })}
text={intl.get('payment_receive.branch_button.label', { label })}
minimal={true}
small={true}
icon={<Icon icon={'branch-16'} iconSize={16} />}

View File

@@ -138,24 +138,23 @@ function PaymentReceiveHeaderFields({
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'customer_id'} />}
>
<ControlCustomerGroup>
<CustomerSelectField
contacts={customers}
selectedContactId={value}
defaultSelectText={<T id={'select_customer_account'} />}
onContactSelected={(customer) => {
form.setFieldValue('customer_id', customer.id);
form.setFieldValue('full_amount', '');
form.setFieldValue('currency_code', customer?.currency_code);
}}
popoverFill={true}
disabled={!isNewMode}
buttonProps={{
elementRef: (ref) => (customerFieldRef.current = ref),
}}
allowCreate={true}
/>
</ControlCustomerGroup>
<CustomerSelectField
contacts={customers}
selectedContactId={value}
defaultSelectText={<T id={'select_customer_account'} />}
onContactSelected={(customer) => {
form.setFieldValue('customer_id', customer.id);
form.setFieldValue('full_amount', '');
form.setFieldValue('currency_code', customer?.currency_code);
}}
popoverFill={true}
disabled={!isNewMode}
buttonProps={{
elementRef: (ref) => (customerFieldRef.current = ref),
}}
allowCreate={true}
/>
{value && (
<CustomerButtonLink customerId={value}>
<T id={'view_customer_details'} />
@@ -346,12 +345,6 @@ export default compose(
withCurrentOrganization(),
)(PaymentReceiveHeaderFields);
const ControlCustomerGroup = styled(ControlGroup)`
display: flex;
align-items: center;
transform: none;
`;
const CustomerButtonLink = styled(CustomerDrawerLink)`
font-size: 11px;
margin-top: 6px;