Skip to content

Commit

Permalink
Merge pull request #780 from stasgm/gd-movement-fix
Browse files Browse the repository at this point in the history
chore: good settings
  • Loading branch information
Kostyanaya authored Dec 18, 2024
2 parents d864037 + 269f4ed commit f35f0db
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 35 deletions.
8 changes: 5 additions & 3 deletions apps/app-fp-movement/src/screens/Cells/CellsViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { FlashList } from '@shopify/flash-list';
import { barcodeSettings, ICell, ICellRef, IMoveDocument, IMoveLine } from '../../store/types';
import { CellsStackParamList } from '../../navigation/Root/types';

import { getBarcode, getCellList, getCellListRef } from '../../utils/helpers';
import { getBarcode, getCellList, getCellListRef, getCodeForCheck } from '../../utils/helpers';
import { ICellRefList, ICodeEntity, IGood } from '../../store/app/types';

import { Group } from '../../components/Group';
Expand Down Expand Up @@ -150,7 +150,7 @@ export const CellsViewScreen = () => {
id: i.name,
barcode: i.barcode,
name: i.name,
good: goods.find((g) => `0000${g.shcode}`.slice(-4) === shcode),
good: goods.find((g) => getCodeForCheck(g.shcode, goodBarcodeSettings?.countCode || 4) === shcode),
workDate,
weight,
numReceived,
Expand Down Expand Up @@ -235,7 +235,9 @@ export const CellsViewScreen = () => {
(brc: string, cell: string) => {
const barc = getBarcode(brc, goodBarcodeSettings);

const good = goods.find((item) => `0000${item.shcode}`.slice(-4) === barc.shcode);
const good = goods.find(
(item) => getCodeForCheck(item.shcode, goodBarcodeSettings?.countCode || 4) === barc.shcode,
);

const newLine: IMoveLine = {
good: { id: good?.id || '', name: good?.name || '', shcode: good?.shcode || '' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
alertWithSound,
alertWithSoundMulti,
getBarcode,
getCodeForCheck,
getDocToSend,
getLineGood,
getNextDocNumber,
Expand Down Expand Up @@ -175,7 +176,11 @@ export const FreeShipmentViewScreen = () => {

const good =
remainsUse && goodRemains.length
? goodRemains.find((item) => `0000${item.good.shcode}`.slice(-4) === `0000${line.good.shcode}`.slice(-4))
? goodRemains.find(
(item) =>
getCodeForCheck(item.good.shcode, goodBarcodeSettings?.countCode || 4) ===
getCodeForCheck(line.good.shcode, goodBarcodeSettings?.countCode || 4),
)
: undefined;

if (remainsUse && goodRemains.length) {
Expand All @@ -191,6 +196,7 @@ export const FreeShipmentViewScreen = () => {
}

const newLine: IFreeShipmentLine = getUpdatedLine(
goodBarcodeSettings,
remainsUse,
lineBarcode,
line,
Expand All @@ -200,7 +206,7 @@ export const FreeShipmentViewScreen = () => {

dispatch(documentActions.updateDocumentLine({ docId: id, line: newLine }));
},
[dispatch, goodBarcodeSettings?.boxWeight, goodRemains, id, lines, remainsUse],
[dispatch, goodBarcodeSettings, goodRemains, id, lines, remainsUse],
);

const handleEditQuantPack = useCallback(() => {
Expand Down Expand Up @@ -552,7 +558,14 @@ export const FreeShipmentViewScreen = () => {

const barc = getBarcode(brc, goodBarcodeSettings);

const lineGood = getLineGood(barc.shcode, barc.weight, goods, goodRemains, remainsUse);
const lineGood = getLineGood(
barc.shcode,
barc.weight,
goods,
goodRemains,
remainsUse,
goodBarcodeSettings?.countCode || 4,
);

if (!lineGood.good) {
setVisibleRequestDialog(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
alertWithSound,
alertWithSoundMulti,
getBarcode,
getCodeForCheck,
getDocToSend,
getNextDocNumber,
getUpdatedLine,
Expand Down Expand Up @@ -155,6 +156,7 @@ export const InventoryViewScreen = () => {
: round(line?.weight * quantity, 3);

const newLine: IInventoryLine = getUpdatedLine(
goodBarcodeSettings,
false,
lineBarcode,
line,
Expand All @@ -165,7 +167,7 @@ export const InventoryViewScreen = () => {
dispatch(documentActions.updateDocumentLine({ docId: id, line: newLine }));
}
},
[dispatch, goodBarcodeSettings?.boxWeight, id, isAddressedDoc, lines],
[dispatch, goodBarcodeSettings, id, isAddressedDoc, lines],
);

const handleEditQuantPack = useCallback(() => {
Expand Down Expand Up @@ -485,7 +487,9 @@ export const InventoryViewScreen = () => {

const barc = getBarcode(brc, goodBarcodeSettings);

const good = goods.find((item) => `0000${item.shcode}`.slice(-4) === barc.shcode);
const good = goods.find(
(item) => getCodeForCheck(item.shcode, goodBarcodeSettings?.countCode || 4) === barc.shcode,
);

if (!good) {
handleErrorMessage(visibleDialog, 'Товар не найден!');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
alertWithSound,
alertWithSoundMulti,
getBarcode,
getCodeForCheck,
getDocToSend,
getLineGood,
getNextDocNumber,
Expand Down Expand Up @@ -149,7 +150,9 @@ export const LaboratoryViewScreen = () => {

if (remainsUse && goodRemains.length) {
const good = goodRemains.find(
(item) => `0000${item.good.shcode}`.slice(-4) === `0000${line.good.shcode}`.slice(-4),
(item) =>
getCodeForCheck(item.good.shcode, goodBarcodeSettings?.countCode || 4) ===
getCodeForCheck(line.good.shcode, goodBarcodeSettings?.countCode || 4),
);

if (good) {
Expand Down Expand Up @@ -186,7 +189,7 @@ export const LaboratoryViewScreen = () => {
}
}
},
[dispatch, goodRemains, id, lines, remainsUse],
[dispatch, goodBarcodeSettings?.countCode, goodRemains, id, lines, remainsUse],
);

const handleEditWeight = () => {
Expand Down Expand Up @@ -507,7 +510,14 @@ export const LaboratoryViewScreen = () => {

const barc = getBarcode(brc, goodBarcodeSettings);

const lineGood = getLineGood(barc.shcode, barc.weight, goods, goodRemains, remainsUse);
const lineGood = getLineGood(
barc.shcode,
barc.weight,
goods,
goodRemains,
remainsUse,
goodBarcodeSettings?.countCode || 4,
);

if (!lineGood.good) {
handleErrorMessage(visibleDialog, 'Товар не найден!');
Expand Down
20 changes: 16 additions & 4 deletions apps/app-fp-movement/src/screens/MovementTo/MoveToViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
alertWithSound,
alertWithSoundMulti,
getBarcode,
getCodeForCheck,
getDocToSend,
getLineGood,
getNextDocNumber,
Expand Down Expand Up @@ -230,7 +231,11 @@ export const MoveToViewScreen = () => {

const good =
remainsUse && goodRemains.length
? goodRemains.find((item) => `0000${item.good.shcode}`.slice(-4) === `0000${line.good.shcode}`.slice(-4))
? goodRemains.find(
(item) =>
getCodeForCheck(item.good.shcode, goodBarcodeSettings?.countCode || 4) ===
getCodeForCheck(line.good.shcode, goodBarcodeSettings?.countCode || 4),
)
: undefined;

if (remainsUse && goodRemains.length) {
Expand All @@ -245,13 +250,13 @@ export const MoveToViewScreen = () => {
}
}

const newLine: IMoveLine = getUpdatedLine(remainsUse, lineBarcode, line, quantity, weight);
const newLine: IMoveLine = getUpdatedLine(goodBarcodeSettings, remainsUse, lineBarcode, line, quantity, weight);

navigation.navigate('SelectCell', { docId: id, item: newLine, mode: 0 });

// dispatch(documentActions.updateDocumentLine({ docId: id, line: newLine }));
},
[goodRemains, id, navigation, newwLine, remainsUse],
[goodBarcodeSettings, goodRemains, id, navigation, newwLine, remainsUse],
);

const handleEditQuantPack = useCallback(() => {
Expand Down Expand Up @@ -583,7 +588,14 @@ export const MoveToViewScreen = () => {

const barc = getBarcode(brc, goodBarcodeSettings);

const lineGood = getLineGood(barc.shcode, barc.weight, goods, goodRemains, remainsUse);
const lineGood = getLineGood(
barc.shcode,
barc.weight,
goods,
goodRemains,
remainsUse,
goodBarcodeSettings?.countCode || 4,
);

if (!lineGood.good) {
handleErrorMessage(visibleDialog, 'Товар не найден!');
Expand Down
19 changes: 16 additions & 3 deletions apps/app-fp-movement/src/screens/Movements/MoveViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
alertWithSound,
alertWithSoundMulti,
getBarcode,
getCodeForCheck,
getDocToSend,
getLineGood,
getNextDocNumber,
Expand Down Expand Up @@ -202,7 +203,11 @@ export const MoveViewScreen = () => {

const good =
remainsUse && goodRemains.length
? goodRemains.find((item) => `0000${item.good.shcode}`.slice(-4) === `0000${line.good.shcode}`.slice(-4))
? goodRemains.find(
(item) =>
getCodeForCheck(item.good.shcode, goodBarcodeSettings?.countCode || 4) ===
getCodeForCheck(line.good.shcode, goodBarcodeSettings?.countCode || 4),
)
: undefined;

if (remainsUse && goodRemains.length) {
Expand All @@ -217,6 +222,7 @@ export const MoveViewScreen = () => {
}
}
const newLine: IMoveLine = getUpdatedLine(
goodBarcodeSettings,
remainsUse,
lineBarcode,
line,
Expand All @@ -227,7 +233,7 @@ export const MoveViewScreen = () => {
dispatch(documentActions.updateDocumentLine({ docId: id, line: newLine }));
}
},
[dispatch, goodBarcodeSettings?.boxWeight, goodRemains, id, isAddressedDoc, lines, remainsUse],
[dispatch, goodBarcodeSettings, goodRemains, id, isAddressedDoc, lines, remainsUse],
);

const handleEditQuantPack = useCallback(() => {
Expand Down Expand Up @@ -580,7 +586,14 @@ export const MoveViewScreen = () => {

const barc = getBarcode(brc, goodBarcodeSettings);

const lineGood = getLineGood(barc.shcode, barc.weight, goods, goodRemains, remainsUse);
const lineGood = getLineGood(
barc.shcode,
barc.weight,
goods,
goodRemains,
remainsUse,
goodBarcodeSettings?.countCode || 4,
);

if (!lineGood.good) {
handleErrorMessage(visibleDialog, 'Товар не найден!');
Expand Down
19 changes: 16 additions & 3 deletions apps/app-fp-movement/src/screens/Receipt/ReceiptViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
alertWithSound,
alertWithSoundMulti,
getBarcode,
getCodeForCheck,
getDocToSend,
getLineGood,
getNextDocNumber,
Expand Down Expand Up @@ -180,7 +181,11 @@ export const ReceiptViewScreen = () => {

const good =
remainsUse && goodRemains.length
? goodRemains.find((item) => `0000${item.good.shcode}`.slice(-4) === `0000${line.good.shcode}`.slice(-4))
? goodRemains.find(
(item) =>
getCodeForCheck(item.good.shcode, goodBarcodeSettings?.countCode || 4) ===
getCodeForCheck(line.good.shcode, goodBarcodeSettings?.countCode || 4),
)
: undefined;

if (remainsUse && goodRemains.length) {
Expand All @@ -195,6 +200,7 @@ export const ReceiptViewScreen = () => {
}
}
const newLine: IReceiptLine = getUpdatedLine(
goodBarcodeSettings,
remainsUse,
lineBarcode,
line,
Expand All @@ -204,7 +210,7 @@ export const ReceiptViewScreen = () => {

dispatch(documentActions.updateDocumentLine({ docId: id, line: newLine }));
},
[dispatch, goodBarcodeSettings?.boxWeight, goodRemains, id, lines, remainsUse],
[dispatch, goodBarcodeSettings, goodRemains, id, lines, remainsUse],
);

const handleEditQuantPack = useCallback(() => {
Expand Down Expand Up @@ -524,7 +530,14 @@ export const ReceiptViewScreen = () => {

const barc = getBarcode(brc, goodBarcodeSettings);

const lineGood = getLineGood(barc.shcode, barc.weight, goods, goodRemains, remainsUse);
const lineGood = getLineGood(
barc.shcode,
barc.weight,
goods,
goodRemains,
remainsUse,
goodBarcodeSettings?.countCode || 4,
);

if (!lineGood.good) {
handleErrorMessage(visibleDialog, 'Товар не найден!');
Expand Down
8 changes: 6 additions & 2 deletions apps/app-fp-movement/src/screens/Return/ReturnViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
alertWithSound,
alertWithSoundMulti,
getBarcode,
getCodeForCheck,
getDocToSend,
getNextDocNumber,
getUpdatedLine,
Expand Down Expand Up @@ -146,6 +147,7 @@ export const ReturnViewScreen = () => {
: round(line?.weight * quantity, 3);

const newLine: IReturnLine = getUpdatedLine(
goodBarcodeSettings,
false,
lineBarcode,
line,
Expand All @@ -155,7 +157,7 @@ export const ReturnViewScreen = () => {

dispatch(documentActions.updateDocumentLine({ docId: id, line: newLine }));
},
[dispatch, goodBarcodeSettings?.boxWeight, id, lines],
[dispatch, goodBarcodeSettings, id, lines],
);

const handleEditQuantPack = useCallback(() => {
Expand Down Expand Up @@ -483,7 +485,9 @@ export const ReturnViewScreen = () => {

const barc = getBarcode(brc, goodBarcodeSettings);

const good = goods.find((item) => `0000${item.shcode}`.slice(-4) === barc.shcode);
const good = goods.find(
(item) => getCodeForCheck(item.shcode, goodBarcodeSettings?.countCode || 4) === barc.shcode,
);

if (!good) {
handleErrorMessage(visibleDialog, 'Товар не найден!');
Expand Down
Loading

0 comments on commit f35f0db

Please sign in to comment.