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,24 +9,23 @@ export function ReceiptFormFooterLeft() {
{/* --------- Receipt message --------- */}
<ReceiptMsgFormGroup
name={'receipt_message'}
label={<T id={'receipt_message'} />}
label={<T id={'receipt_form.label.receipt_message'} />}
hintText={'Will be displayed on the Receipt'}
>
<FEditableText
name={'receipt_message'}
placeholder={
<T id={'thanks_for_your_business_and_have_a_great_day'} />
}
placeholder={intl.get('receipt_form.receipt_message.placeholder')}
/>
</ReceiptMsgFormGroup>
{/* --------- Statement--------- */}
<StatementFormGroup label={<T id={'statement'} />} name={'statement'}>
<StatementFormGroup
label={<T id={'receipt_form.label.statement'} />}
name={'statement'}
>
<FEditableText
name={'statement'}
placeholder={
'Enter the terms and conditions of your business to be displayed in your transaction'
}
placeholder={intl.get('receipt_form.statement.placeholder')}
/>
</StatementFormGroup>
</React.Fragment>

View File

@@ -21,23 +21,23 @@ export function ReceiptFormFooterRight() {
return (
<ReceiptTotalLines labelColWidth={'180px'} amountColWidth={'180px'}>
<TotalLine
title={<T id={'receipt.details.subtotal'} />}
title={<T id={'receipt_form.label.subtotal'} />}
value={formattedSubtotal}
borderStyle={TotalLineBorderStyle.None}
/>
<TotalLine
title={<T id={'receipt.details.total'} />}
title={<T id={'receipt_form.label.total'} />}
value={formattedTotal}
borderStyle={TotalLineBorderStyle.SingleDark}
textStyle={TotalLineTextStyle.Bold}
/>
<TotalLine
title={<T id={'receipt.details.payment_amount'} />}
title={<T id={'receipt_form.label.payment_amount'} />}
value={formattedPaymentTotal}
borderStyle={TotalLineBorderStyle.None}
/>
<TotalLine
title={<T id={'receipt.details.due_amount'} />}
title={<T id={'receipt_form.label.due_amount'} />}
value={formattedDueTotal}
textStyle={TotalLineTextStyle.Bold}
/>

View File

@@ -90,19 +90,17 @@ function ReceiptFormHeader({
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('currency_code', customer?.currency_code);
}}
popoverFill={true}
allowCreate={true}
/>
</ControlCustomerGroup>
<CustomerSelectField
contacts={customers}
selectedContactId={value}
defaultSelectText={<T id={'select_customer_account'} />}
onContactSelected={(customer) => {
form.setFieldValue('customer_id', customer.id);
form.setFieldValue('currency_code', customer?.currency_code);
}}
popoverFill={true}
allowCreate={true}
/>
{value && (
<CustomerButtonLink customerId={value}>
<T id={'view_customer_details'} />
@@ -245,12 +243,6 @@ export default compose(
})),
)(ReceiptFormHeader);
const ControlCustomerGroup = styled(ControlGroup)`
display: flex;
align-items: center;
transform: none;
`;
const CustomerButtonLink = styled(CustomerDrawerLink)`
font-size: 11px;
margin-top: 6px;

View File

@@ -4,25 +4,18 @@ import { useParams } from 'react-router-dom';
import 'style/pages/SaleReceipt/PageForm.scss';
import ReceiptFrom from './ReceiptForm';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { ReceiptFormProvider } from './ReceiptFormProvider';
import { compose } from 'utils';
/**
* Receipt form page.
*/
function ReceiptFormPage({
// #withCurrentOrganization
organization: { base_currency },
}) {
export default function ReceiptFormPage() {
const { id } = useParams();
const idInt = parseInt(id, 10);
return (
<ReceiptFormProvider receiptId={idInt} baseCurrency={base_currency}>
<ReceiptFormProvider receiptId={idInt}>
<ReceiptFrom />
</ReceiptFormProvider>
);
}
export default compose(withCurrentOrganization())(ReceiptFormPage);

View File

@@ -1,5 +1,5 @@
import React, { createContext, useState } 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/Dashboard/DashboardInsider';
@@ -20,7 +20,7 @@ const ReceiptFormContext = createContext();
/**
* Receipt form provider.
*/
function ReceiptFormProvider({ receiptId, baseCurrency, ...props }) {
function ReceiptFormProvider({ receiptId, ...props }) {
// Features guard.
const { featureCan } = useFeatureCan();
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
@@ -92,17 +92,10 @@ function ReceiptFormProvider({ receiptId, baseCurrency, ...props }) {
const [submitPayload, setSubmitPayload] = useState({});
const [selectCustomer, setSelectCustomer] = React.useState(null);
const isNewMode = !receiptId;
const isFeatureLoading = isWarehouesLoading || isBranchesLoading;
// Determines whether the foreign customer.
const isForeignCustomer =
!isEqual(selectCustomer?.currency_code, baseCurrency) &&
!isUndefined(selectCustomer?.currency_code);
const provider = {
receiptId,
receipt,
@@ -112,9 +105,6 @@ function ReceiptFormProvider({ receiptId, baseCurrency, ...props }) {
branches,
warehouses,
submitPayload,
baseCurrency,
selectCustomer,
setSelectCustomer,
isNewMode,
isReceiptLoading,
@@ -127,7 +117,6 @@ function ReceiptFormProvider({ receiptId, baseCurrency, ...props }) {
isSettingLoading,
isBranchesSuccess,
isWarehousesSuccess,
isForeignCustomer,
createReceiptMutate,
editReceiptMutate,

View File

@@ -104,7 +104,7 @@ function ReceiptFormSelectWarehouse() {
function ReceiptBranchSelectButton({ label }) {
return (
<Button
text={intl.get('invoice.branch_button.label', { label })}
text={intl.get('receipt.branch_button.label', { label })}
minimal={true}
small={true}
icon={<Icon icon={'branch-16'} iconSize={16} />}
@@ -115,7 +115,7 @@ function ReceiptBranchSelectButton({ label }) {
function ReceiptWarehouseSelectButton({ label }) {
return (
<Button
text={intl.get('invoice.warehouse_button.label', { label })}
text={intl.get('receipt.warehouse_button.label', { label })}
minimal={true}
small={true}
icon={<Icon icon={'warehouse-16'} iconSize={16} />}