This commit is contained in:
Ahmed Bouhuolia
2025-12-29 22:06:49 +02:00
parent 30d8fdb4c0
commit 00aad6e35c
3 changed files with 46 additions and 59 deletions

View File

@@ -26,7 +26,7 @@ export class TransactionsLockingService {
constructor( constructor(
private readonly transactionsLockingRepo: TransactionsLockingRepository, private readonly transactionsLockingRepo: TransactionsLockingRepository,
private readonly eventPublisher: EventEmitter2, private readonly eventPublisher: EventEmitter2,
) {} ) { }
/** /**
* Enable/disable all transacations locking. * Enable/disable all transacations locking.

View File

@@ -10,7 +10,7 @@ import {
InputGroup, InputGroup,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import classNames from 'classnames'; import classNames from 'classnames';
import { FormattedMessage as T, If, FFormGroup, FSelect } from '@/components'; import { FormattedMessage as T, If, FFormGroup, FSelect, FRadioGroup, FInputGroup } from '@/components';
import { handleStringChange } from '@/utils'; import { handleStringChange } from '@/utils';
import { FieldRequiredHint } from '@/components'; import { FieldRequiredHint } from '@/components';
import { CLASSES } from '@/constants/classes'; import { CLASSES } from '@/constants/classes';
@@ -31,7 +31,7 @@ export default function AllocateLandedCostFormFields() {
const { costTransactionEntries, landedCostTransactions } = const { costTransactionEntries, landedCostTransactions } =
useAllocateLandedConstDialogContext(); useAllocateLandedConstDialogContext();
const { values, setFieldValue } = useFormikContext(); const { values, setFieldValue, form } = useFormikContext();
// Handle transaction type select change. // Handle transaction type select change.
const handleTransactionTypeChange = (type) => { const handleTransactionTypeChange = (type) => {
@@ -137,62 +137,51 @@ export default function AllocateLandedCostFormFields() {
</If> </If>
{/*------------ Amount -----------*/} {/*------------ Amount -----------*/}
<FastField name={'amount'}> <FFormGroup
{({ form, field, meta: { error, touched } }) => ( name={'amount'}
<FormGroup
label={<T id={'amount'} />} label={<T id={'amount'} />}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="amount" />}
className={'form-group--amount'}
inline={true} inline={true}
fastField
> >
<InputGroup <FInputGroup
{...field} name={'amount'}
onBlur={(e) => { onBlur={(e) => {
const amount = e.target.value; const amount = e.target.value;
const { allocation_method, items } = form.values; const { allocation_method, items } = values;
form.setFieldValue( setFieldValue(
'items', 'items',
allocateCostToEntries(amount, allocation_method, items), allocateCostToEntries(amount, allocation_method, items),
); );
}} }}
/> />
</FormGroup> </FFormGroup>
)}
</FastField>
{/*------------ Allocation method -----------*/} {/*------------ Allocation method -----------*/}
<Field name={'allocation_method'}> <FFormGroup
{({ form, field: { value }, meta: { touched, error } }) => ( name={'allocation_method'}
<FormGroup
medium={true}
label={<T id={'allocation_method'} />} label={<T id={'allocation_method'} />}
labelInfo={<FieldRequiredHint />} medium
className={'form-group--allocation_method'} inline
intent={inputIntent({ error, touched })} fastField
helperText={<ErrorMessage name="allocation_method" />}
inline={true}
> >
<RadioGroup <FRadioGroup
name={'allocation_method'}
onChange={handleStringChange((_value) => { onChange={handleStringChange((_value) => {
const { amount, items } = form.values; const { amount, items } = values;
form.setFieldValue('allocation_method', _value); setFieldValue('allocation_method', _value);
form.setFieldValue( setFieldValue(
'items', 'items',
allocateCostToEntries(amount, _value, items), allocateCostToEntries(amount, _value, items),
); );
})} })}
selectedValue={value}
inline={true} inline={true}
> >
<Radio label={<T id={'quantity'} />} value="quantity" /> <Radio label={<T id={'quantity'} />} value="quantity" />
<Radio label={<T id={'valuation'} />} value="value" /> <Radio label={<T id={'valuation'} />} value="value" />
</RadioGroup> </FRadioGroup>
</FormGroup> </FFormGroup>
)}
</Field>
{/*------------ Allocate Landed cost Table -----------*/} {/*------------ Allocate Landed cost Table -----------*/}
<AllocateLandedCostFormBody /> <AllocateLandedCostFormBody />

View File

@@ -21,7 +21,6 @@ import {
FeatureCan, FeatureCan,
BranchSelect, BranchSelect,
WarehouseSelect, WarehouseSelect,
BranchSelectButton,
FAccountsSuggestField, FAccountsSuggestField,
} from '@/components'; } from '@/components';
import { momentFormatter, toSafeNumber } from '@/utils'; import { momentFormatter, toSafeNumber } from '@/utils';
@@ -78,12 +77,11 @@ export default function InventoryAdjustmentFormDialogFields() {
<Col xs={5}> <Col xs={5}>
<FormGroup <FormGroup
label={<T id={'branch'} />} label={<T id={'branch'} />}
className={classNames('form-group--select-list', Classes.FILL)} fill
> >
<BranchSelect <BranchSelect
name={'branch_id'} name={'branch_id'}
branches={branches} branches={branches}
input={BranchSelectButton}
popoverProps={{ minimal: true }} popoverProps={{ minimal: true }}
/> />
</FormGroup> </FormGroup>
@@ -93,7 +91,7 @@ export default function InventoryAdjustmentFormDialogFields() {
<Col xs={5}> <Col xs={5}>
<FormGroup <FormGroup
label={<T id={'warehouse'} />} label={<T id={'warehouse'} />}
className={classNames('form-group--select-list', Classes.FILL)} fill
> >
<WarehouseSelect <WarehouseSelect
name={'warehouse_id'} name={'warehouse_id'}