-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add split lines on customer delivery (#842)
* RM#88324
- Loading branch information
1 parent
91317fe
commit 2b5d02b
Showing
12 changed files
with
175 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"title": "Customer delivery: add button to split lines", | ||
"type": "feat", | ||
"packages": "stock" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...plates/customerDelivery/CustomerDeliveryLineActionCard/CustomerDeliveryLineActionCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Axelor Business Solutions | ||
* | ||
* Copyright (C) 2024 Axelor (<http://axelor.com>). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React, {useCallback, useMemo} from 'react'; | ||
import {ActionCard} from '@axelor/aos-mobile-ui'; | ||
import { | ||
useDispatch, | ||
useSelector, | ||
useTranslator, | ||
useTypes, | ||
} from '@axelor/aos-mobile-core'; | ||
import {StockMoveLine} from '../../../../types'; | ||
import {splitCustomerDeliveryLine} from '../../../../features/customerDeliveryLineSlice'; | ||
import CustomerDeliveryLineCard from '../CustomerDeliveryLineCard/CustomerDeliveryLineCard'; | ||
|
||
interface CustomerDeliveryLineActionCardProps { | ||
style?: any; | ||
styleCard?: any; | ||
customerDeliveryLine: any; | ||
handleShowLine: (customerDeliveryLine: any) => void; | ||
} | ||
|
||
const CustomerDeliveryLineActionCard = ({ | ||
style, | ||
styleCard, | ||
customerDeliveryLine, | ||
handleShowLine, | ||
}: CustomerDeliveryLineActionCardProps) => { | ||
const I18n = useTranslator(); | ||
const dispatch = useDispatch(); | ||
const {StockMove} = useTypes(); | ||
|
||
const {customerDelivery} = useSelector(state => state.customerDelivery); | ||
|
||
const splitCustomerDeliveryLineAPI = useCallback(() => { | ||
dispatch( | ||
(splitCustomerDeliveryLine as any)({ | ||
id: customerDeliveryLine.id, | ||
version: customerDeliveryLine.version, | ||
customerDeliveryId: customerDelivery?.id, | ||
}), | ||
); | ||
}, [ | ||
dispatch, | ||
customerDeliveryLine.id, | ||
customerDeliveryLine.version, | ||
customerDelivery?.id, | ||
]); | ||
|
||
const pickedQty = useMemo( | ||
() => | ||
StockMoveLine.hideLineQty(customerDeliveryLine, customerDelivery) | ||
? 0 | ||
: Number(customerDeliveryLine.realQty), | ||
[customerDelivery, customerDeliveryLine], | ||
); | ||
|
||
const availability = useMemo( | ||
() => | ||
customerDelivery.statusSelect !== StockMove?.statusSelect.Realized | ||
? customerDeliveryLine.availableStatusSelect | ||
: null, | ||
[ | ||
StockMove?.statusSelect.Realized, | ||
customerDelivery.statusSelect, | ||
customerDeliveryLine.availableStatusSelect, | ||
], | ||
); | ||
|
||
return ( | ||
<ActionCard | ||
style={style} | ||
translator={I18n.t} | ||
actionList={[ | ||
{ | ||
iconName: 'diagram-2-fill', | ||
helper: I18n.t('Stock_Split'), | ||
onPress: splitCustomerDeliveryLineAPI, | ||
hidden: | ||
customerDelivery.statusSelect > StockMove?.statusSelect.Planned || | ||
pickedQty >= customerDeliveryLine.qty || | ||
pickedQty === 0, | ||
}, | ||
]}> | ||
<CustomerDeliveryLineCard | ||
style={styleCard} | ||
productName={customerDeliveryLine.product?.fullName} | ||
stockLocationName={customerDeliveryLine.fromStockLocation?.name} | ||
askedQty={customerDeliveryLine.qty} | ||
pickedQty={pickedQty} | ||
locker={customerDeliveryLine.locker} | ||
availability={availability} | ||
stockMoveLineId={customerDeliveryLine.id} | ||
trackingNumber={customerDeliveryLine.trackingNumber} | ||
onPress={() => handleShowLine(customerDeliveryLine)} | ||
/> | ||
</ActionCard> | ||
); | ||
}; | ||
|
||
export default CustomerDeliveryLineActionCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters