diff --git a/packages/apps/purchase/src/api/index.ts b/packages/apps/purchase/src/api/index.ts new file mode 100644 index 000000000..e7d036217 --- /dev/null +++ b/packages/apps/purchase/src/api/index.ts @@ -0,0 +1,20 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +export {searchPurchaseRequest as searchPurchaseRequestApi} from './purchase-request-api'; +export {searchSupplier as searchSupplierApi} from './supplier-api'; diff --git a/packages/apps/purchase/src/api/purchase-request-api.js b/packages/apps/purchase/src/api/purchase-request-api.js new file mode 100644 index 000000000..14b05ae0b --- /dev/null +++ b/packages/apps/purchase/src/api/purchase-request-api.js @@ -0,0 +1,68 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import { + createStandardSearch, + getSearchCriterias, +} from '@axelor/aos-mobile-core'; + +const createPurchaseRequestCriteria = ({searchValue, statusList, supplier}) => { + const criterias = [ + getSearchCriterias('purchase_purchaseRequest', searchValue), + ]; + + if (supplier) { + criterias.push({ + fieldName: 'supplierPartner.id', + operator: '=', + value: supplier.id, + }); + } + + if (Array.isArray(statusList) && statusList.length > 0) { + criterias.push({ + operator: 'or', + criteria: statusList.map(status => ({ + fieldName: 'statusSelect', + operator: '=', + value: status.key, + })), + }); + } + + return criterias; +}; + +export async function searchPurchaseRequest({ + page = 0, + searchValue, + statusList, + supplier, +}) { + return createStandardSearch({ + model: 'com.axelor.apps.purchase.db.PurchaseRequest', + criteria: createPurchaseRequestCriteria({ + searchValue, + statusList, + supplier, + }), + fieldKey: 'purchase_purchaseRequest', + sortKey: 'purchase_purchaseRequest', + page, + }); +} diff --git a/packages/apps/purchase/src/api/supplier-api.js b/packages/apps/purchase/src/api/supplier-api.js new file mode 100644 index 000000000..de8b7308f --- /dev/null +++ b/packages/apps/purchase/src/api/supplier-api.js @@ -0,0 +1,50 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import { + createStandardSearch, + getSearchCriterias, +} from '@axelor/aos-mobile-core'; + +const createSupplierCriteria = searchValue => { + const criterias = [ + getSearchCriterias('purchase_supplier', searchValue), + { + fieldName: 'isContact', + operator: '=', + value: false, + }, + { + fieldName: 'isSupplier', + operator: '=', + value: true, + }, + ]; + + return criterias; +}; + +export async function searchSupplier({page = 0, searchValue}) { + return createStandardSearch({ + model: 'com.axelor.apps.base.db.Partner', + criteria: createSupplierCriteria(searchValue), + fieldKey: 'purchase_supplier', + sortKey: 'purchase_supplier', + page, + }); +} diff --git a/packages/apps/purchase/src/components/atoms/RequestCard/RequestCard.tsx b/packages/apps/purchase/src/components/atoms/RequestCard/RequestCard.tsx new file mode 100644 index 000000000..5c0bd9fd5 --- /dev/null +++ b/packages/apps/purchase/src/components/atoms/RequestCard/RequestCard.tsx @@ -0,0 +1,81 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import React, {useMemo} from 'react'; +import {StyleSheet} from 'react-native'; +import {ObjectCard} from '@axelor/aos-mobile-ui'; +import {useTypeHelpers, useTypes} from '@axelor/aos-mobile-core'; + +interface RequestCardProps { + style?: any; + companyName: string; + supplierPartnerName: string; + reference: string; + statusSelect: number; + onPress: () => void; +} + +const RequestCard = ({ + style, + companyName, + supplierPartnerName, + reference, + statusSelect, + onPress, +}: RequestCardProps) => { + const {PurchaseRequest} = useTypes(); + const {getItemColor} = useTypeHelpers(); + + const borderStyle = useMemo(() => { + return getStyles( + getItemColor(PurchaseRequest?.statusSelect, statusSelect)?.background, + )?.border; + }, [PurchaseRequest?.statusSelect, getItemColor, statusSelect]); + + return ( + + ); +}; + +const getStyles = (color: string) => + StyleSheet.create({ + border: {borderLeftWidth: 7, borderLeftColor: color}, + }); + +export default RequestCard; diff --git a/packages/apps/purchase/src/components/atoms/index.ts b/packages/apps/purchase/src/components/atoms/index.ts new file mode 100644 index 000000000..33fdb3deb --- /dev/null +++ b/packages/apps/purchase/src/components/atoms/index.ts @@ -0,0 +1,19 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +export {default as RequestCard} from './RequestCard/RequestCard'; diff --git a/packages/apps/purchase/src/components/index.ts b/packages/apps/purchase/src/components/index.ts new file mode 100644 index 000000000..f0795f640 --- /dev/null +++ b/packages/apps/purchase/src/components/index.ts @@ -0,0 +1,20 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +export * from './atoms'; +export * from './templates'; diff --git a/packages/apps/purchase/src/components/templates/SupplierSearchBar/SupplierSearchBar.tsx b/packages/apps/purchase/src/components/templates/SupplierSearchBar/SupplierSearchBar.tsx new file mode 100644 index 000000000..bfef44019 --- /dev/null +++ b/packages/apps/purchase/src/components/templates/SupplierSearchBar/SupplierSearchBar.tsx @@ -0,0 +1,78 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import React, {useCallback} from 'react'; +import {useDispatch, useSelector, useTranslator} from '@axelor/aos-mobile-core'; +import {AutoCompleteSearch} from '@axelor/aos-mobile-ui'; +import {searchSupplier} from '../../../features/supplierSlice'; + +const displaySimpleFullName = item => item.simpleFullName; + +interface SupplierSearchBarProps { + placeholderKey?: string; + defaultValue: any; + showDetailsPopup?: boolean; + navigate?: boolean; + oneFilter?: boolean; + onChange: (value: any) => void; +} + +const SupplierSearchBar = ({ + placeholderKey = 'Purchase_Supplier', + defaultValue = '', + onChange = () => {}, + showDetailsPopup = true, + navigate = false, + oneFilter = false, +}: SupplierSearchBarProps) => { + const I18n = useTranslator(); + const dispatch = useDispatch(); + + const { + supplierList, + loadingSuppliers, + moreLoadingSupplier, + isListEndSupplier, + } = useSelector(state => state.purchase_supplier); + + const fetchSupplierAPI = useCallback( + ({page = 0, searchValue}) => { + dispatch((searchSupplier as any)({page, searchValue})); + }, + [dispatch], + ); + + return ( + + ); +}; + +export default SupplierSearchBar; diff --git a/packages/apps/purchase/src/components/templates/index.ts b/packages/apps/purchase/src/components/templates/index.ts new file mode 100644 index 000000000..1d691c6da --- /dev/null +++ b/packages/apps/purchase/src/components/templates/index.ts @@ -0,0 +1,19 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +export {default as SupplierSearchBar} from './SupplierSearchBar/SupplierSearchBar'; diff --git a/packages/apps/purchase/src/features/asyncFunctions-index.ts b/packages/apps/purchase/src/features/asyncFunctions-index.ts new file mode 100644 index 000000000..508d3ff2f --- /dev/null +++ b/packages/apps/purchase/src/features/asyncFunctions-index.ts @@ -0,0 +1,20 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +export {searchPurchaseRequest} from './purchaseRequestSlice'; +export {searchSupplier} from './supplierSlice'; diff --git a/packages/apps/purchase/src/features/index.js b/packages/apps/purchase/src/features/index.js new file mode 100644 index 000000000..eddd74760 --- /dev/null +++ b/packages/apps/purchase/src/features/index.js @@ -0,0 +1,20 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +export {purchaseRequestReducer as purchase_purchaseRequest} from './purchaseRequestSlice'; +export {supplierReducer as purchase_supplier} from './supplierSlice'; diff --git a/packages/apps/purchase/src/features/purchaseRequestSlice.js b/packages/apps/purchase/src/features/purchaseRequestSlice.js new file mode 100644 index 000000000..97ef58e7d --- /dev/null +++ b/packages/apps/purchase/src/features/purchaseRequestSlice.js @@ -0,0 +1,59 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import {createAsyncThunk, createSlice} from '@reduxjs/toolkit'; +import { + generateInifiniteScrollCases, + handlerApiCall, +} from '@axelor/aos-mobile-core'; +import {searchPurchaseRequest as _searchPurchaseRequest} from '../api/purchase-request-api'; + +export const searchPurchaseRequest = createAsyncThunk( + 'purchase_purchaseRequest/searchPurchaseRequest', + async function (data, {getState}) { + return handlerApiCall({ + fetchFunction: _searchPurchaseRequest, + data, + action: 'Purchase_SliceAction_SearchPurchaseRequest', + getState, + responseOptions: {isArrayResponse: true}, + }); + }, +); + +const initialState = { + loadingPurchaseRequests: false, + moreLoadingPurchaseRequest: false, + isListEndPurchaseRequest: false, + purchaseRequestList: [], +}; + +const purchaseRequestSlice = createSlice({ + name: 'purchase_purchaseRequest', + initialState, + extraReducers: builder => { + generateInifiniteScrollCases(builder, searchPurchaseRequest, { + loading: 'loadingPurchaseRequests', + moreLoading: 'moreLoadingPurchaseRequest', + isListEnd: 'isListEndPurchaseRequest', + list: 'purchaseRequestList', + }); + }, +}); + +export const purchaseRequestReducer = purchaseRequestSlice.reducer; diff --git a/packages/apps/purchase/src/features/supplierSlice.js b/packages/apps/purchase/src/features/supplierSlice.js new file mode 100644 index 000000000..9ae181697 --- /dev/null +++ b/packages/apps/purchase/src/features/supplierSlice.js @@ -0,0 +1,59 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import {createAsyncThunk, createSlice} from '@reduxjs/toolkit'; +import { + generateInifiniteScrollCases, + handlerApiCall, +} from '@axelor/aos-mobile-core'; +import {searchSupplier as _searchSupplier} from '../api/supplier-api'; + +export const searchSupplier = createAsyncThunk( + 'purchase_supplier/searchSupplier', + async function (data, {getState}) { + return handlerApiCall({ + fetchFunction: _searchSupplier, + data, + action: 'Purchase_SliceAction_SearchSupplier', + getState, + responseOptions: {isArrayResponse: true}, + }); + }, +); + +const initialState = { + loadingSuppliers: false, + moreLoadingSupplier: false, + isListEndSupplier: false, + supplierList: [], +}; + +const supplierSlice = createSlice({ + name: 'purchase_supplier', + initialState, + extraReducers: builder => { + generateInifiniteScrollCases(builder, searchSupplier, { + loading: 'loadingSuppliers', + moreLoading: 'moreLoadingSupplier', + isListEnd: 'isListEndSupplier', + list: 'supplierList', + }); + }, +}); + +export const supplierReducer = supplierSlice.reducer; diff --git a/packages/apps/purchase/src/i18n/en.json b/packages/apps/purchase/src/i18n/en.json index c6c997fe6..61478a6bb 100644 --- a/packages/apps/purchase/src/i18n/en.json +++ b/packages/apps/purchase/src/i18n/en.json @@ -1,3 +1,13 @@ { - "Purchase_Purchase": "Purchase" + "Purchase_Purchase": "Purchase", + "Purchase_InternalRequests": "Internal requests", + "Purchase_Status_Draft": "Draft", + "Purchase_Status_Requested": "Requested", + "Purchase_Status_Accepted": "Accepted", + "Purchase_Status_Purchased": "Purchased", + "Purchase_Status_Refused": "Refused", + "Purchase_Status_Canceled": "Canceled", + "Purchase_Supplier": "Supplier", + "Purchase_SliceAction_SearchPurchaseRequest": "search purchase request", + "Purchase_SliceAction_SearchSupplier": "search supplier" } diff --git a/packages/apps/purchase/src/i18n/fr.json b/packages/apps/purchase/src/i18n/fr.json index e2327c839..befa869d8 100644 --- a/packages/apps/purchase/src/i18n/fr.json +++ b/packages/apps/purchase/src/i18n/fr.json @@ -1,3 +1,13 @@ { - "Purchase_Purchase": "Achats" + "Purchase_Purchase": "Achats", + "Purchase_InternalRequests": "Demandes internes", + "Purchase_Status_Draft": "Brouillon", + "Purchase_Status_Requested": "Demandée", + "Purchase_Status_Accepted": "Acceptée", + "Purchase_Status_Purchased": "Achetée", + "Purchase_Status_Refused": "Refusée", + "Purchase_Status_Canceled": "Annulée", + "Purchase_Supplier": "Fournisseur", + "Purchase_SliceAction_SearchPurchaseRequest": "recherche sur les demandes d'achat", + "Purchase_SliceAction_SearchSupplier": "recherche sur les fournisseurs" } diff --git a/packages/apps/purchase/src/index.ts b/packages/apps/purchase/src/index.ts index 6a38082a6..00b447fd1 100644 --- a/packages/apps/purchase/src/index.ts +++ b/packages/apps/purchase/src/index.ts @@ -17,8 +17,16 @@ */ import {Module} from '@axelor/aos-mobile-core'; +import PurchaseScreens from './screens'; import enTranslations from './i18n/en.json'; import frTranslations from './i18n/fr.json'; +import * as purchaseReducers from './features'; +import { + purchase_modelAPI, + purchase_searchFields, + purchase_sortFields, + purchase_typeObjects, +} from './models'; export const PurchaseModule: Module = { name: 'app-purchase', @@ -29,8 +37,32 @@ export const PurchaseModule: Module = { moduleName: 'axelor-purchase', downToVersion: '8.3.0', }, + menus: { + purchase_menu_internal_request: { + title: 'Purchase_InternalRequests', + icon: 'file-earmark-ruled', + screen: 'RequestListScreen', + }, + }, + screens: { + ...PurchaseScreens, + }, translations: { en: enTranslations, fr: frTranslations, }, + models: { + objectFields: {...purchase_modelAPI}, + sortFields: {...purchase_sortFields}, + searchFields: {...purchase_searchFields}, + typeObjects: purchase_typeObjects, + }, + reducers: { + ...purchaseReducers, + }, }; + +export * from './api'; +export * from './features/asyncFunctions-index'; +export * from './components'; +export * from './screens'; diff --git a/packages/apps/purchase/src/models/index.ts b/packages/apps/purchase/src/models/index.ts new file mode 100644 index 000000000..2a15fdef1 --- /dev/null +++ b/packages/apps/purchase/src/models/index.ts @@ -0,0 +1,22 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +export {purchase_searchFields} from './searchFields'; +export {purchase_sortFields} from './sortFields'; +export {purchase_modelAPI} from './objectFields'; +export {purchase_typeObjects} from './typeObjects'; diff --git a/packages/apps/purchase/src/models/objectFields.ts b/packages/apps/purchase/src/models/objectFields.ts new file mode 100644 index 000000000..664b9d37d --- /dev/null +++ b/packages/apps/purchase/src/models/objectFields.ts @@ -0,0 +1,31 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import {ObjectFields, schemaContructor} from '@axelor/aos-mobile-core'; + +export const purchase_modelAPI: ObjectFields = { + purchase_purchaseRequest: schemaContructor.object({ + purchaseRequestSeq: schemaContructor.string(), + supplierPartner: schemaContructor.subObject('fullName'), + company: schemaContructor.subObject('name'), + statusSelect: schemaContructor.number(), + }), + purchase_supplier: schemaContructor.object({ + simpleFullName: schemaContructor.string(), + }), +}; diff --git a/packages/apps/purchase/src/models/searchFields.ts b/packages/apps/purchase/src/models/searchFields.ts new file mode 100644 index 000000000..321ca825a --- /dev/null +++ b/packages/apps/purchase/src/models/searchFields.ts @@ -0,0 +1,24 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import {SearchFields} from '@axelor/aos-mobile-core'; + +export const purchase_searchFields: SearchFields = { + purchase_purchaseRequest: ['purchaseRequestSeq', 'company.name'], + purchase_supplier: ['simpleFullName'], +}; diff --git a/packages/apps/purchase/src/models/sortFields.ts b/packages/apps/purchase/src/models/sortFields.ts new file mode 100644 index 000000000..1d1256d08 --- /dev/null +++ b/packages/apps/purchase/src/models/sortFields.ts @@ -0,0 +1,23 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import {SortFields} from '@axelor/aos-mobile-core'; + +export const purchase_sortFields: SortFields = { + purchase_purchaseRequest: ['statusSelect', '-purchaseRequestSeq'], +}; diff --git a/packages/apps/purchase/src/models/typeObjects.ts b/packages/apps/purchase/src/models/typeObjects.ts new file mode 100644 index 000000000..01d06fb03 --- /dev/null +++ b/packages/apps/purchase/src/models/typeObjects.ts @@ -0,0 +1,67 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import {ModuleSelections} from '@axelor/aos-mobile-core'; + +export const purchase_typeObjects: ModuleSelections = [ + { + modelName: 'com.axelor.apps.purchase.db.PurchaseRequest', + fields: { + statusSelect: { + content: [ + { + key: 'Draft', + value: 1, + title: 'Purchase_Status_Draft', + color: 'secondaryColor', + }, + { + key: 'Requested', + value: 2, + title: 'Purchase_Status_Requested', + color: 'progressColor', + }, + { + key: 'Accepted', + value: 3, + title: 'Purchase_Status_Accepted', + color: 'plannedColor', + }, + { + key: 'Purchased', + value: 4, + title: 'Purchase_Status_Purchased', + color: 'successColor', + }, + { + key: 'Refused', + value: 5, + title: 'Purchase_Status_Refused', + color: 'errorColor', + }, + { + key: 'Canceled', + value: 6, + title: 'Purchase_Status_Canceled', + color: 'cautionColor', + }, + ], + }, + }, + }, +]; diff --git a/packages/apps/purchase/src/screens/RequestListScreen.tsx b/packages/apps/purchase/src/screens/RequestListScreen.tsx new file mode 100644 index 000000000..8e2bd8065 --- /dev/null +++ b/packages/apps/purchase/src/screens/RequestListScreen.tsx @@ -0,0 +1,96 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import React, {useMemo, useState} from 'react'; +import {ChipSelect, Screen} from '@axelor/aos-mobile-ui'; +import { + SearchListView, + useSelector, + useTranslator, + useTypeHelpers, + useTypes, +} from '@axelor/aos-mobile-core'; +import {RequestCard, SupplierSearchBar} from '../components'; +import {searchPurchaseRequest} from '../features/purchaseRequestSlice'; + +const displayPurchaseRequestSeq = item => item.purchaseRequestSeq; + +const RequestListScreen = ({}) => { + const I18n = useTranslator(); + const {PurchaseRequest} = useTypes(); + const {getSelectionItems} = useTypeHelpers(); + + const { + loadingPurchaseRequests, + moreLoadingPurchaseRequest, + isListEndPurchaseRequest, + purchaseRequestList, + } = useSelector(state => state.purchase_purchaseRequest); + + const [selectedStatus, setSelectedStatus] = useState([]); + const [supplier, setSupplier] = useState(); + + const statusList = useMemo( + () => getSelectionItems(PurchaseRequest?.statusSelect, selectedStatus), + [PurchaseRequest?.statusSelect, getSelectionItems, selectedStatus], + ); + + const sliceFunctionData = useMemo( + () => ({ + statusList: selectedStatus, + supplier: supplier, + }), + [selectedStatus, supplier], + ); + + return ( + + + } + headerChildren={ + + } + renderListItem={({item}) => ( + {}} + statusSelect={item.statusSelect} + reference={item.purchaseRequestSeq} + companyName={item.company?.name} + supplierPartnerName={item.supplierPartner?.fullName} + /> + )} + /> + + ); +}; + +export default RequestListScreen; diff --git a/packages/apps/purchase/src/screens/index.ts b/packages/apps/purchase/src/screens/index.ts new file mode 100644 index 000000000..caa2bede2 --- /dev/null +++ b/packages/apps/purchase/src/screens/index.ts @@ -0,0 +1,32 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * 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 . + */ + +import RequestListScreen from './RequestListScreen'; + +export default { + RequestListScreen: { + title: 'Purchase_InternalRequests', + component: RequestListScreen, + options: { + shadedHeader: false, + }, + isUsableOnShortcut: true, + }, +}; + +export {RequestListScreen};