Skip to content

Commit

Permalink
feat: Added changes (#3135)
Browse files Browse the repository at this point in the history
* Added changes

* Added more fixes

* Added fixes
  • Loading branch information
Julias0 authored Jul 3, 2024
1 parent 6b5eba7 commit 76c884b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
4 changes: 4 additions & 0 deletions src/app/core/models/payment-mode.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface PaymentMode {
name: string;
key: string;
}
19 changes: 0 additions & 19 deletions src/app/core/services/launch-darkly.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,4 @@ describe('LaunchDarklyService', () => {
expect(() => launchDarklyService.shutDownClient()).not.toThrow();
});
});

it('getImmediate: should immediately return a value', () => {
launchDarklyService.initializeUser({
key: '123',
});
spyOn(launchDarklyService.ldClient, 'variation').and.returnValue(of(true));

launchDarklyService.getImmediate('timezone_fix', true);

expect(launchDarklyService.ldClient.variation).toHaveBeenCalledOnceWith('timezone_fix', true);
});

it('getImmediate: should return default value if ldclient is not present', () => {
launchDarklyService.ldClient = null;

const value = launchDarklyService.getImmediate('timezone_fix', true);

expect(value).toBeTrue();
});
});
5 changes: 3 additions & 2 deletions src/app/core/services/transaction.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('TransactionService', () => {
'getThisMonthRange',
'getThisWeekRange',
'getLastMonthRange',
'getUTCMidAfternoonDate',
]);
const orgUserSettingsServiceSpy = jasmine.createSpyObj('OrgUserSettingsService', ['get']);
const timezoneServiceSpy = jasmine.createSpyObj('TimezoneService', [
Expand Down Expand Up @@ -1278,7 +1279,7 @@ describe('TransactionService', () => {
expect(apiService.post).toHaveBeenCalledOnceWith('/transactions', txnDataPayload);
expect(orgUserSettingsService.get).toHaveBeenCalledTimes(1);
expect(timezoneService.convertAllDatesToProperLocale).toHaveBeenCalledOnceWith(txnCustomPropertiesData6, offset);
expect(timezoneService.convertToUtc).toHaveBeenCalledTimes(3);
expect(timezoneService.convertToUtc).toHaveBeenCalledTimes(2);
// @ts-ignore
expect(transactionService.getTxnAccount).toHaveBeenCalledTimes(1);
// @ts-ignore
Expand All @@ -1304,7 +1305,7 @@ describe('TransactionService', () => {
expect(apiService.post).toHaveBeenCalledOnceWith('/transactions', txnDataPayload);
expect(orgUserSettingsService.get).toHaveBeenCalledTimes(1);
expect(timezoneService.convertAllDatesToProperLocale).toHaveBeenCalledOnceWith(txnCustomPropertiesData6, offset);
expect(timezoneService.convertToUtc).toHaveBeenCalledTimes(3);
expect(timezoneService.convertToUtc).toHaveBeenCalledTimes(2);
// @ts-ignore
expect(transactionService.getTxnAccount).toHaveBeenCalledTimes(1);
// @ts-ignore
Expand Down
20 changes: 3 additions & 17 deletions src/app/core/services/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,8 @@ import { ExpenseFilters } from '../models/expense-filters.model';
import { ExpensesService } from './platform/v1/spender/expenses.service';
import { expensesCacheBuster$ } from '../cache-buster/expense-cache-buster';
import { LaunchDarklyService } from './launch-darkly.service';

enum FilterState {
READY_TO_REPORT = 'READY_TO_REPORT',
POLICY_VIOLATED = 'POLICY_VIOLATED',
CANNOT_REPORT = 'CANNOT_REPORT',
DRAFT = 'DRAFT',
}

type PaymentMode = {
name: string;
key: string;
};
import { FilterState } from '../enums/filter-state.enum';
import { PaymentMode } from '../models/payment-mode.model';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -231,11 +221,7 @@ export class TransactionService {
transaction.txn_dt.setSeconds(0);
transaction.txn_dt.setMilliseconds(0);

if (this.ldService.getImmediate('timezone_fix', false)) {
transaction.txn_dt = this.dateService.getUTCMidAfternoonDate(transaction.txn_dt);
} else {
transaction.txn_dt = this.timezoneService.convertToUtc(transaction.txn_dt, offset);
}
transaction.txn_dt = this.dateService.getUTCMidAfternoonDate(transaction.txn_dt);
}

if (transaction.from_dt) {
Expand Down

0 comments on commit 76c884b

Please sign in to comment.