-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: retain receipt when editing, remove code for advance wallet id, set unspecified category id #3245
fix: retain receipt when editing, remove code for advance wallet id, set unspecified category id #3245
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -436,6 +436,8 @@ | |
|
||
pendingTransactionAllowedToReportAndSplit = true; | ||
|
||
allCategories$: Observable<OrgCategory[]>; | ||
|
||
activeCategories$: Observable<OrgCategory[]>; | ||
|
||
selectedCategory$: Observable<OrgCategory>; | ||
|
@@ -1236,12 +1238,6 @@ | |
); | ||
} | ||
|
||
getActiveCategories(): Observable<OrgCategory[]> { | ||
const allCategories$ = this.categoriesService.getAll(); | ||
|
||
return allCategories$.pipe(map((catogories) => this.categoriesService.filterRequired(catogories))); | ||
} | ||
|
||
getInstaFyleImageData(): Observable<Partial<InstaFyleImageData>> { | ||
if (this.activatedRoute.snapshot.params.dataUrl && this.activatedRoute.snapshot.params.canExtractData !== 'false') { | ||
const dataUrl = this.activatedRoute.snapshot.params.dataUrl as string; | ||
|
@@ -2977,7 +2973,10 @@ | |
} | ||
|
||
ionViewWillEnter(): void { | ||
this.activeCategories$ = this.getActiveCategories().pipe(shareReplay(1)); | ||
this.allCategories$ = this.categoriesService.getAll().pipe(shareReplay(1)); | ||
this.activeCategories$ = this.allCategories$ | ||
.pipe(map((catogories) => this.categoriesService.filterRequired(catogories))) | ||
.pipe(shareReplay(1)); | ||
|
||
this.initClassObservables(); | ||
|
||
|
@@ -3497,6 +3496,7 @@ | |
customProperties: standardisedCustomProperties$, | ||
attachments: attachements$, | ||
orgSettings: this.orgSettingsService.get(), | ||
allCategories: this.allCategories$, | ||
}).pipe( | ||
map((res) => { | ||
const etxn: Partial<UnflattenedTransaction> = res.etxn; | ||
|
@@ -3509,6 +3509,9 @@ | |
} | ||
return customProperty; | ||
}); | ||
const unspecifiedCategory = res.allCategories.find( | ||
(category) => category.fyle_category?.toLowerCase() === 'unspecified' | ||
); | ||
|
||
const formValues = this.getFormValues(); | ||
|
||
|
@@ -3545,7 +3548,8 @@ | |
amount = etxn.tx.user_amount; | ||
} | ||
|
||
//TODO: Add depenedent fields to custom_properties array once APIs are available | ||
const category_id = this.getOrgCategoryID() || unspecifiedCategory.id; | ||
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. setting unspecified category as the default category. |
||
//TODO: Add dependent fields to custom_properties array once APIs are available | ||
return { | ||
tx: { | ||
...etxn.tx, | ||
|
@@ -3562,7 +3566,7 @@ | |
project_id: this.getProjectID(), | ||
tax_amount: this.getTaxAmount(), | ||
tax_group_id: this.getTaxGroupID(), | ||
org_category_id: this.getOrgCategoryID(), | ||
org_category_id: category_id, | ||
fyle_category: this.getFyleCategory(), | ||
policy_amount: null, | ||
vendor: this.getDisplayName(), | ||
|
@@ -4036,10 +4040,7 @@ | |
report: Report; | ||
}; | ||
|
||
// NOTE: This double call is done as certain fields will not be present in return of upsert call. policy_amount in this case. | ||
return this.transactionService.upsert(etxn.tx as Transaction).pipe( | ||
switchMap((txn) => this.expensesService.getExpenseById(txn.id)), | ||
map((expense) => this.transactionService.transformExpense(expense).tx), | ||
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. we are not using the result of this double call for checking |
||
switchMap((tx) => { | ||
const selectedReportId = reportControl.report?.id; | ||
const criticalPolicyViolated = this.getIsPolicyExpense(etxn as unknown as Expense); | ||
|
@@ -4082,17 +4083,6 @@ | |
} else { | ||
return of(txn); | ||
} | ||
}), | ||
switchMap((txn) => { | ||
if (txn.id && txn.advance_wallet_id !== etxn.tx.advance_wallet_id) { | ||
const expense = { | ||
id: txn.id, | ||
advance_wallet_id: etxn.tx.advance_wallet_id, | ||
}; | ||
return this.expensesService.post(expense).pipe(map(() => txn)); | ||
} else { | ||
return of(txn); | ||
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.
|
||
} | ||
}) | ||
); | ||
}) | ||
|
@@ -4561,7 +4551,7 @@ | |
return this.vendorOptions?.find((option) => option.toLowerCase() === vendor.toLowerCase()) || null; | ||
} | ||
|
||
attachReceipts(data: { type: string; dataUrl: string | ArrayBuffer; actionSource?: string }): void { | ||
if (data) { | ||
const fileInfo = { | ||
type: data.type, | ||
|
@@ -4669,7 +4659,7 @@ | |
} | ||
} | ||
|
||
async uploadFileCallback(file: File): Promise<void> { | ||
let fileData: { type: string; dataUrl: string | ArrayBuffer; actionSource: string }; | ||
if (file) { | ||
if (file.size < MAX_FILE_SIZE) { | ||
|
@@ -4687,12 +4677,12 @@ | |
} | ||
} | ||
|
||
async onChangeCallback(nativeElement: HTMLInputElement): Promise<void> { | ||
const file = nativeElement.files[0]; | ||
this.uploadFileCallback(file); | ||
} | ||
|
||
async addAttachments(event: Event): Promise<void> { | ||
event.stopPropagation(); | ||
|
||
if (this.platform.is('ios')) { | ||
|
@@ -4762,7 +4752,7 @@ | |
} | ||
} | ||
|
||
getReceiptExtension(name: string): string | null { | ||
let res: string = null; | ||
|
||
if (name) { | ||
|
@@ -4777,7 +4767,7 @@ | |
return res; | ||
} | ||
|
||
getReceiptDetails(file: FileObject): { type: string; thumbnail: string } { | ||
const ext = this.getReceiptExtension(file.name); | ||
const res = { | ||
type: 'unknown', | ||
|
@@ -4795,7 +4785,7 @@ | |
return res; | ||
} | ||
|
||
viewAttachments(): void { | ||
const attachements$ = this.getExpenseAttachments(this.mode); | ||
|
||
from(this.loaderService.showLoader()) | ||
|
@@ -4851,7 +4841,7 @@ | |
}); | ||
} | ||
|
||
getDeleteReportParams( | ||
config: { header: string; body: string; ctaText: string; ctaLoadingText: string }, | ||
removeExpenseFromReport: boolean = false, | ||
reportId?: string | ||
|
@@ -4886,7 +4876,7 @@ | |
}; | ||
} | ||
|
||
async deleteExpense(reportId?: string): Promise<void> { | ||
const removeExpenseFromReport = reportId && this.isRedirectedFromReport; | ||
const header = removeExpenseFromReport ? 'Remove Expense' : 'Delete Expense'; | ||
const body = removeExpenseFromReport | ||
|
@@ -4930,7 +4920,7 @@ | |
} | ||
} | ||
|
||
async openCommentsModal(): Promise<void> { | ||
const etxn = await this.etxn$.toPromise(); | ||
|
||
const modal = await this.modalController.create({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only during
createTxnWithFiles
do we have to set thefile_ids
in the add/edit flow. In other scenarios of the add/edit, the file_ids will be already present.