From a0cf731c531159475e9f197fab30a411bd60564d Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Mon, 11 Sep 2023 18:30:08 +0200 Subject: [PATCH 01/12] added swtich, styles --- src/components/MoneyRequestConfirmationList.js | 14 ++++++++++++++ src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/actions/IOU.js | 1 + src/pages/iou/steps/MoneyRequestConfirmPage.js | 5 ++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index a7695c939907..01b1e7bf90c4 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -5,6 +5,7 @@ import {format} from 'date-fns'; import _ from 'underscore'; import {View} from 'react-native'; import lodashGet from 'lodash/get'; +import Text from './Text'; import styles from '../styles/styles'; import * as ReportUtils from '../libs/ReportUtils'; import * as OptionsListUtils from '../libs/OptionsListUtils'; @@ -29,6 +30,7 @@ import Image from './Image'; import useLocalize from '../hooks/useLocalize'; import * as ReceiptUtils from '../libs/ReceiptUtils'; import categoryPropTypes from './categoryPropTypes'; +import Switch from './Switch'; import ConfirmedRoute from './ConfirmedRoute'; import transactionPropTypes from './transactionPropTypes'; import DistanceRequestUtils from '../libs/DistanceRequestUtils'; @@ -494,6 +496,18 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} + + + {translate('common.billable')} + { + props.onToggleBillable(val); + }} + /> + + )} diff --git a/src/languages/en.ts b/src/languages/en.ts index f52848589663..4bdcbbbed23b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -233,6 +233,7 @@ export default { showMore: 'Show more', merchant: 'Merchant', category: 'Category', + billable: 'Billable', receipt: 'Receipt', replace: 'Replace', distance: 'Distance', diff --git a/src/languages/es.ts b/src/languages/es.ts index 8610f41308e1..08f5fb6afca6 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -232,6 +232,7 @@ export default { showMore: 'Mostrar más', merchant: 'Comerciante', category: 'Categoría', + billable: 'Facturable', receipt: 'Recibo', replace: 'Sustituir', distance: 'Distancia', diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index bc7adf47bd8c..c45a3c5db318 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -87,6 +87,7 @@ function resetMoneyRequestInfo(id = '') { receiptPath: '', receiptSource: '', transactionID: '', + isBillable: false, }); } diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 178179f31745..1c3c1bc77735 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -1,4 +1,4 @@ -import React, {useCallback, useEffect, useMemo, useRef} from 'react'; +import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {ScrollView, View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; @@ -59,6 +59,7 @@ const defaultProps = { }; function MoneyRequestConfirmPage(props) { + const [isBillable, setIsBillable] = useState(true); const {windowHeight} = useWindowDimensions(); const prevMoneyRequestId = useRef(props.iou.id); const iouType = useRef(lodashGet(props.route, 'params.iouType', '')); @@ -272,6 +273,8 @@ function MoneyRequestConfirmPage(props) { iouAmount={props.iou.amount} iouComment={props.iou.comment} iouCurrencyCode={props.iou.currency} + iouIsBillable={isBillable} + onToggleBillable={(newValue) => setIsBillable(newValue)} onConfirm={createTransaction} onSendMoney={sendMoney} onSelectParticipant={(option) => { From df03d5826d9bf99d78bde4ec6ea65039f920049d Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Tue, 12 Sep 2023 22:26:44 +0200 Subject: [PATCH 02/12] added onyx, added to IOU --- src/components/MoneyRequestConfirmationList.js | 7 +++++-- src/libs/TransactionUtils.js | 3 +++ src/libs/actions/IOU.js | 18 ++++++++++++++++-- src/pages/iou/steps/MoneyRequestConfirmPage.js | 14 ++++++++++++-- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 85dcea4e9cbe..feb872870887 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -501,7 +501,7 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - + {props.policy?.disabledFields?.defaultBillable === false && ( {translate('common.billable')} - + )} )} @@ -541,5 +541,8 @@ export default compose( transaction: { key: ({transactionID}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, }, + policy: { + key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + }, }), )(MoneyRequestConfirmationList); diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index ee833911ccd4..28f3f476d8b6 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -34,6 +34,7 @@ Onyx.connect({ * @param {String} [filename] * @param {String} [existingTransactionID] When creating a distance request, an empty transaction has already been created with a transactionID. In that case, the transaction here needs to have it's transactionID match what was already generated. * @param {String} [category] + * @param {Boolean} [defaultBillable] * @returns {Object} */ function buildOptimisticTransaction( @@ -49,6 +50,7 @@ function buildOptimisticTransaction( filename = '', existingTransactionID = null, category = '', + defaultBillable = false, ) { // transactionIDs are random, positive, 64-bit numeric strings. // Because JS can only handle 53-bit numbers, transactionIDs are strings in the front-end (just like reportActionID) @@ -77,6 +79,7 @@ function buildOptimisticTransaction( receipt, filename, category, + defaultBillable, }; } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 8a9543c186bc..3fa45d14dc71 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -95,7 +95,7 @@ function resetMoneyRequestInfo(id = '') { receiptPath: '', receiptSource: '', transactionID: '', - isBillable: false, + defaultBillable: false, }); } @@ -339,6 +339,7 @@ function buildOnyxDataForMoneyRequest( * @param {Object} [receipt] * @param {String} [existingTransactionID] * @param {String} [category] + * @param {Boolean} defaultBillable * @returns {Object} data * @returns {String} data.payerEmail * @returns {Object} data.iouReport @@ -366,6 +367,7 @@ function getMoneyRequestInformation( receipt = undefined, existingTransactionID = undefined, category = undefined, + defaultBillable = false, ) { const payerEmail = OptionsListUtils.addSMSDomainIfPhoneNumber(participant.login); const payerAccountID = Number(participant.accountID); @@ -431,6 +433,7 @@ function getMoneyRequestInformation( filename, existingTransactionID, category, + defaultBillable, ); const uniquePolicyRecentlyUsedCategories = allRecentlyUsedCategories @@ -598,8 +601,9 @@ function createDistanceRequest(report, participant, comment, created, transactio * @param {String} comment * @param {Object} [receipt] * @param {String} [category] + * * @param {Boolean} defaultBillable */ -function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined, category = undefined) { +function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined, category = undefined, defaultBillable = false) { const {payerEmail, iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = getMoneyRequestInformation( report, participant, @@ -613,6 +617,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p receipt, undefined, category, + defaultBillable, ); API.write( @@ -633,6 +638,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p reportPreviewReportActionID: reportPreviewAction.reportActionID, receipt, category, + defaultBillable, }, onyxData, ); @@ -1884,6 +1890,13 @@ function resetMoneyRequestCategory() { Onyx.merge(ONYXKEYS.IOU, {category: ''}); } +/** + * @param {Boolean} defaultBillable + */ +function setMoneyRequestDefaultBillable(defaultBillable) { + Onyx.merge(ONYXKEYS.IOU, {defaultBillable: defaultBillable}); +} + /** * @param {Object[]} participants */ @@ -1964,6 +1977,7 @@ export { setMoneyRequestMerchant, setMoneyRequestCategory, resetMoneyRequestCategory, + setMoneyRequestDefaultBillable, setMoneyRequestParticipants, setMoneyRequestReceipt, createEmptyTransaction, diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 47c6af85b200..96f9815d54c8 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -59,7 +59,7 @@ const defaultProps = { }; function MoneyRequestConfirmPage(props) { - const [isBillable, setIsBillable] = useState(true); + const [isBillable, setIsBillable] = useState(props.policy?.defaultBillable); const {windowHeight} = useWindowDimensions(); const prevMoneyRequestId = useRef(props.iou.id); const iouType = useRef(lodashGet(props.route, 'params.iouType', '')); @@ -136,6 +136,7 @@ function MoneyRequestConfirmPage(props) { trimmedComment, receipt, props.iou.category, + props.iou.defaultBillable, ); }, [ @@ -147,6 +148,7 @@ function MoneyRequestConfirmPage(props) { props.currentUserPersonalDetails.login, props.currentUserPersonalDetails.accountID, props.iou.category, + props.iou.defaultBillable, ], ); @@ -285,7 +287,10 @@ function MoneyRequestConfirmPage(props) { iouComment={props.iou.comment} iouCurrencyCode={props.iou.currency} iouIsBillable={isBillable} - onToggleBillable={(newValue) => setIsBillable(newValue)} + onToggleBillable={(value) => { + setIsBillable(value); + IOU.setMoneyRequestDefaultBillable(value); + }} iouCategory={props.iou.category} onConfirm={createTransaction} onSendMoney={sendMoney} @@ -354,4 +359,9 @@ export default compose( key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`, }, }), + withOnyx({ + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, + }, + }), )(MoneyRequestConfirmPage); From f1ace028620941b4841b6795e9adc51e9c72925e Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 13 Sep 2023 13:11:46 +0200 Subject: [PATCH 03/12] adj --- src/components/MoneyRequestConfirmationList.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index feb872870887..42e96d98746e 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -507,9 +507,7 @@ function MoneyRequestConfirmationList(props) { { - props.onToggleBillable(val); - }} + onToggle={props.onToggleBillable} /> )} From a084124473f77fdace14ae851f3c42c0602201a3 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 13 Sep 2023 13:41:26 +0200 Subject: [PATCH 04/12] adjustments, lint fixes --- src/components/MoneyRequestConfirmationList.js | 2 +- src/libs/actions/IOU.js | 4 ++-- src/pages/iou/steps/MoneyRequestConfirmPage.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 42e96d98746e..98b4485f155d 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -501,7 +501,7 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {props.policy?.disabledFields?.defaultBillable === false && ( + {!lodashGet(props.policy, 'disabledFields.defaultBillable', true) && ( {translate('common.billable')} Date: Wed, 13 Sep 2023 18:45:20 +0200 Subject: [PATCH 05/12] position fix --- .../MoneyRequestConfirmationList.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 57c609a54b1a..01423b572873 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -522,16 +522,6 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {!lodashGet(props.policy, 'disabledFields.defaultBillable', true) && ( - - {translate('common.billable')} - - - )} {canUseTags && !!tagList && ( )} + {!lodashGet(props.policy, 'disabledFields.defaultBillable', true) && ( + + {translate('common.billable')} + + + )} )} From f91c45d802da2ce37e20f83189f3aca9dccd90f7 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Thu, 14 Sep 2023 12:40:09 +0200 Subject: [PATCH 06/12] tags beta --- src/components/MoneyRequestConfirmationList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 01423b572873..da64c5b7f168 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -532,7 +532,7 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {!lodashGet(props.policy, 'disabledFields.defaultBillable', true) && ( + {canUseTags && !lodashGet(props.policy, 'disabledFields.defaultBillable', true) && ( {translate('common.billable')} Date: Thu, 14 Sep 2023 14:01:15 +0200 Subject: [PATCH 07/12] change defaultBillable to billable for an API --- src/libs/actions/IOU.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index f29cf29f4708..8837226d7522 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -641,7 +641,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p reportPreviewReportActionID: reportPreviewAction.reportActionID, receipt, category, - defaultBillable, + billable: defaultBillable, }, onyxData, ); From 99f286a39f1640ca006e6b2d11c2008ecee7e145 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Thu, 14 Sep 2023 21:44:01 +0200 Subject: [PATCH 08/12] removed state --- src/libs/actions/IOU.js | 6 +++--- src/pages/iou/steps/MoneyRequestConfirmPage.js | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 1462993804e4..a90c1319c3de 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -95,7 +95,7 @@ function resetMoneyRequestInfo(id = '') { receiptPath: '', receiptSource: '', transactionID: '', - defaultBillable: false, + defaultBillable: '', }); } @@ -367,7 +367,7 @@ function getMoneyRequestInformation( receipt = undefined, existingTransactionID = undefined, category = undefined, - defaultBillable = false, + defaultBillable = undefined, ) { const payerEmail = OptionsListUtils.addSMSDomainIfPhoneNumber(participant.login); const payerAccountID = Number(participant.accountID); @@ -603,7 +603,7 @@ function createDistanceRequest(report, participant, comment, created, transactio * @param {String} [category] * @param {Boolean} [defaultBillable] */ -function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined, category = undefined, defaultBillable = false) { +function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined, category = undefined, defaultBillable = undefined) { // If the report is iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 257ae5d2fb0b..5a0af5e1968b 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -1,4 +1,4 @@ -import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; +import React, {useCallback, useEffect, useMemo, useRef} from 'react'; import {ScrollView, View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; @@ -59,7 +59,6 @@ const defaultProps = { }; function MoneyRequestConfirmPage(props) { - const [isBillable, setIsBillable] = useState(lodashGet(props.policy, 'defaultBillable', false)); const {windowHeight} = useWindowDimensions(); const prevMoneyRequestId = useRef(props.iou.id); const iouType = useRef(lodashGet(props.route, 'params.iouType', '')); @@ -78,6 +77,7 @@ function MoneyRequestConfirmPage(props) { if (policyExpenseChat) { Policy.openDraftWorkspaceRequest(policyExpenseChat.policyID); } + if (typeof props.iou.defaultBillable !== 'boolean') IOU.setMoneyRequestDefaultBillable(lodashGet(props.policy, 'defaultBillable', false)); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -286,11 +286,8 @@ function MoneyRequestConfirmPage(props) { iouAmount={props.iou.amount} iouComment={props.iou.comment} iouCurrencyCode={props.iou.currency} - iouIsBillable={isBillable} - onToggleBillable={(value) => { - setIsBillable(value); - IOU.setMoneyRequestDefaultBillable(value); - }} + iouIsBillable={props.iou.defaultBillable} + onToggleBillable={IOU.setMoneyRequestDefaultBillable} iouCategory={props.iou.category} iouTag={props.iou.tag} onConfirm={createTransaction} From 1f3f062eb834f8535d4726ca41363cca1ac24d8a Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Fri, 15 Sep 2023 18:31:38 +0200 Subject: [PATCH 09/12] change defaultBillable to null --- src/libs/actions/IOU.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index a90c1319c3de..f9ae9bc3eded 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -95,7 +95,7 @@ function resetMoneyRequestInfo(id = '') { receiptPath: '', receiptSource: '', transactionID: '', - defaultBillable: '', + defaultBillable: null, }); } From fdaa194ecd43ed5b088dde55382e47481bc2f646 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Mon, 18 Sep 2023 13:20:53 +0200 Subject: [PATCH 10/12] defaultBillable name to billable --- src/libs/TransactionUtils.js | 6 ++--- src/libs/actions/IOU.js | 24 +++++++++---------- .../iou/steps/MoneyRequestConfirmPage.js | 13 ++++++---- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index e8d02c6d4a71..e426148dac30 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -34,7 +34,7 @@ Onyx.connect({ * @param {String} [filename] * @param {String} [existingTransactionID] When creating a distance request, an empty transaction has already been created with a transactionID. In that case, the transaction here needs to have it's transactionID match what was already generated. * @param {String} [category] - * @param {Boolean} [defaultBillable] + * @param {Boolean} [billable] * @returns {Object} */ function buildOptimisticTransaction( @@ -50,7 +50,7 @@ function buildOptimisticTransaction( filename = '', existingTransactionID = null, category = '', - defaultBillable = false, + billable = false, ) { // transactionIDs are random, positive, 64-bit numeric strings. // Because JS can only handle 53-bit numbers, transactionIDs are strings in the front-end (just like reportActionID) @@ -79,7 +79,7 @@ function buildOptimisticTransaction( receipt, filename, category, - defaultBillable, + billable, }; } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index f9ae9bc3eded..31764a9fd148 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -95,7 +95,7 @@ function resetMoneyRequestInfo(id = '') { receiptPath: '', receiptSource: '', transactionID: '', - defaultBillable: null, + billable: null, }); } @@ -339,7 +339,7 @@ function buildOnyxDataForMoneyRequest( * @param {Object} [receipt] * @param {String} [existingTransactionID] * @param {String} [category] - * @param {Boolean} defaultBillable + * @param {Boolean} billable * @returns {Object} data * @returns {String} data.payerEmail * @returns {Object} data.iouReport @@ -367,7 +367,7 @@ function getMoneyRequestInformation( receipt = undefined, existingTransactionID = undefined, category = undefined, - defaultBillable = undefined, + billable = undefined, ) { const payerEmail = OptionsListUtils.addSMSDomainIfPhoneNumber(participant.login); const payerAccountID = Number(participant.accountID); @@ -433,7 +433,7 @@ function getMoneyRequestInformation( filename, existingTransactionID, category, - defaultBillable, + billable, ); const uniquePolicyRecentlyUsedCategories = allRecentlyUsedCategories @@ -601,9 +601,9 @@ function createDistanceRequest(report, participant, comment, created, transactio * @param {String} comment * @param {Object} [receipt] * @param {String} [category] - * @param {Boolean} [defaultBillable] + * @param {Boolean} [billable] */ -function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined, category = undefined, defaultBillable = undefined) { +function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined, category = undefined, billable = undefined) { // If the report is iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; @@ -620,7 +620,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p receipt, undefined, category, - defaultBillable, + billable, ); API.write( @@ -641,7 +641,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p reportPreviewReportActionID: reportPreviewAction.reportActionID, receipt, category, - billable: defaultBillable, + billable: billable, }, onyxData, ); @@ -1953,10 +1953,10 @@ function resetMoneyRequestCategory() { } /** - * @param {Boolean} defaultBillable + * @param {Boolean} billable */ -function setMoneyRequestDefaultBillable(defaultBillable) { - Onyx.merge(ONYXKEYS.IOU, {defaultBillable}); +function setMoneyRequestBillable(billable) { + Onyx.merge(ONYXKEYS.IOU, {billable}); } /** @@ -2041,7 +2041,7 @@ export { setMoneyRequestMerchant, setMoneyRequestCategory, resetMoneyRequestCategory, - setMoneyRequestDefaultBillable, + setMoneyRequestBillable, setMoneyRequestParticipants, setMoneyRequestReceipt, createEmptyTransaction, diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 5a0af5e1968b..e3ceae70fc53 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -77,7 +77,10 @@ function MoneyRequestConfirmPage(props) { if (policyExpenseChat) { Policy.openDraftWorkspaceRequest(policyExpenseChat.policyID); } - if (typeof props.iou.defaultBillable !== 'boolean') IOU.setMoneyRequestDefaultBillable(lodashGet(props.policy, 'defaultBillable', false)); + // Verification to reset billable with a default value, when value in IOU was changed + if (typeof props.iou.billable !== 'boolean') { + IOU.setMoneyRequestBillable(lodashGet(props.policy, 'defaultBillable', false)); + } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -136,7 +139,7 @@ function MoneyRequestConfirmPage(props) { trimmedComment, receipt, props.iou.category, - props.iou.defaultBillable, + props.iou.billable, ); }, [ @@ -148,7 +151,7 @@ function MoneyRequestConfirmPage(props) { props.currentUserPersonalDetails.login, props.currentUserPersonalDetails.accountID, props.iou.category, - props.iou.defaultBillable, + props.iou.billable, ], ); @@ -286,8 +289,8 @@ function MoneyRequestConfirmPage(props) { iouAmount={props.iou.amount} iouComment={props.iou.comment} iouCurrencyCode={props.iou.currency} - iouIsBillable={props.iou.defaultBillable} - onToggleBillable={IOU.setMoneyRequestDefaultBillable} + iouIsBillable={props.iou.billable} + onToggleBillable={IOU.setMoneyRequestBillable} iouCategory={props.iou.category} iouTag={props.iou.tag} onConfirm={createTransaction} From 7b3a137c9fba8e26f3cebfeeaa2d25769461ec44 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Mon, 18 Sep 2023 13:39:44 +0200 Subject: [PATCH 11/12] lint fix --- src/libs/actions/IOU.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 31764a9fd148..ffc7aadaa840 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -641,7 +641,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p reportPreviewReportActionID: reportPreviewAction.reportActionID, receipt, category, - billable: billable, + billable, }, onyxData, ); From caf0cf6d1c5ac32e2689dd2e9cef511c7ac116d4 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Mon, 18 Sep 2023 15:06:14 +0200 Subject: [PATCH 12/12] billable to [billable] --- src/libs/actions/IOU.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index ffc7aadaa840..490f78442df2 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -339,7 +339,7 @@ function buildOnyxDataForMoneyRequest( * @param {Object} [receipt] * @param {String} [existingTransactionID] * @param {String} [category] - * @param {Boolean} billable + * @param {Boolean} [billable] * @returns {Object} data * @returns {String} data.payerEmail * @returns {Object} data.iouReport