-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Optimistically generate transactions in existing IOU flows #17718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 24 commits
c94e8f4
5705e77
962009f
c2ab2fc
8d998d9
b68362d
a6aec7f
ae89202
42ff9e4
d997104
6d8d11d
d85e4a0
c858075
9176a17
f622e5c
4b79c27
619e5cb
cb9ceed
83b0bc7
afda245
0fe4736
3ee3eb8
0a1a59b
d7c84c6
99e89a2
00fbb9b
acbedf8
12a27a9
f745bf6
9511280
bc1cf76
a264814
ff72d4f
f34a677
bf1586f
b9d960f
6bd14d7
c13d018
d2669e6
c81c126
b9defaa
d1dc16d
89a57c2
4f346e2
55d3994
bb22ec2
114482d
2bedfa6
d8db068
adb91e1
0b5f90f
b8181f1
a06911f
e935e01
3cff94b
5de881a
382e802
50105d9
d2d9ce3
6ca0f60
9256a73
422e56d
4e13073
9f14ad3
53791cf
164dd2b
a968d31
296e458
1aba2a3
6dc9879
dd11c8f
89ee785
9900bb0
609797b
80339aa
22c4c65
9e86e64
92cbd4f
75bffd3
37b7aaa
a01c8b9
558c056
af9c824
e22b9db
8a51895
28954e0
c03cb8b
e68b986
7a9fbbc
74bef77
78b59bd
dbf456d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1073,15 +1073,14 @@ function getIOUReportActionMessage(type, total, participants, comment, currency, | |
* @param {String} currency | ||
* @param {String} comment - User comment for the IOU. | ||
* @param {Array} participants - An array with participants details. | ||
* @param {String} iouTransactionID - Only required if the IOUReportAction type is oneOf(cancel, decline). Generates a randomID as default. | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param {String} [paymentType] - Only required if the IOUReportAction type is 'pay'. Can be oneOf(elsewhere, payPal, Expensify). | ||
* @param {String} [iouTransactionID] - Only required if the IOUReportAction type is oneOf(cancel, decline). Generates a randomID as default. | ||
* @param {String} [iouReportID] - Only required if the IOUReportActions type is oneOf(decline, cancel, pay). Generates a randomID as default. | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param {Boolean} [isSettlingUp] - Whether we are settling up an IOU. | ||
* | ||
* @returns {Object} | ||
*/ | ||
function buildOptimisticIOUReportAction(type, amount, currency, comment, participants, paymentType = '', iouTransactionID = '', iouReportID = '', isSettlingUp = false) { | ||
const IOUTransactionID = iouTransactionID || NumberUtils.rand64(); | ||
function buildOptimisticIOUReportAction(type, amount, currency, comment, participants, iouTransactionID, paymentType = '', iouReportID = '', isSettlingUp = false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review note: |
||
const IOUReportID = iouReportID || generateReportID(); | ||
const parser = new ExpensiMark(); | ||
const commentText = getParsedComment(comment); | ||
|
@@ -1091,7 +1090,7 @@ function buildOptimisticIOUReportAction(type, amount, currency, comment, partici | |
amount, | ||
comment: textForNewComment, | ||
currency, | ||
IOUTransactionID, | ||
IOUTransactionID: iouTransactionID, | ||
IOUReportID, | ||
type, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import CONST from '../CONST'; | ||
import DateUtils from './DateUtils'; | ||
import * as NumberUtils from './NumberUtils'; | ||
|
||
/** | ||
* Optimistically generate a transaction. | ||
* | ||
* @param {Number} amount – in cents | ||
* @param {String} currency | ||
* @param {String} comment | ||
* @returns {Object} | ||
*/ | ||
function buildOptimisticTransaction(amount, currency, comment = '') { | ||
// transactionIDs are random, positive, 64-bit numbers. | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Because JS can only handle 53-bit numbers, transactionIDs are strings in the front-end (just like reportActionID) | ||
const transactionID = NumberUtils.rand64(); | ||
return { | ||
transactionID, | ||
amount, | ||
comment, | ||
created: DateUtils.getDBTime(), | ||
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, | ||
}; | ||
} | ||
|
||
export default { | ||
buildOptimisticTransaction, | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.