Skip to content

Commit

Permalink
Merge pull request #2362 from sap-labs-france/master-qa
Browse files Browse the repository at this point in the history
Merge master-qa
  • Loading branch information
LucasBrazi06 authored Apr 15, 2021
2 parents 22cadf3 + 006ded5 commit 2e14334
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ev-dashboard",
"description": "Dashboard for Electric Vehicle charging station",
"homepage": "https://github.com/sap-labs-france/ev-dashboard",
"version": "2.4.60",
"version": "2.4.61",
"engines": {
"npm": "6.x.x."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { TableSyncBillingInvoicesAction } from '../../../shared/table/actions/in
import { TableSyncBillingUsersAction } from '../../../shared/table/actions/users/table-sync-billing-users-action';
import { RestResponse } from '../../../types/GlobalType';
import { HTTPError } from '../../../types/HTTPError';
import { BillingSettings, BillingSettingsType } from '../../../types/Setting';
import { BillingSetting, BillingSettings, BillingSettingsType, StripeBillingSetting } from '../../../types/Setting';
import TenantComponents from '../../../types/TenantComponents';
import { Utils } from '../../../utils/Utils';

Expand Down Expand Up @@ -68,14 +68,21 @@ export class SettingsBillingComponent implements OnInit {
});
}

public save(content: BillingSettings) {
// Stripe
if (content.stripe) {
this.billingSettings.type = BillingSettingsType.STRIPE;
this.billingSettings.stripe = content.stripe;
} else {
return;
public save(newSettings: any) {
if (!newSettings.stripe) {
return ;
}
const { immediateBillingAllowed, periodicBillingAllowed, taxID } = newSettings.stripe; // TODO - ?? newSettings.billing?
const billing: BillingSetting = {
immediateBillingAllowed, periodicBillingAllowed, taxID
};
const { url, publicKey, secretKey } = newSettings.stripe;
const stripe: StripeBillingSetting = {
url, publicKey, secretKey
};
this.billingSettings.type = BillingSettingsType.STRIPE;
this.billingSettings.billing = billing;
this.billingSettings.stripe = stripe;
// Save
this.spinnerService.show();
this.componentService.saveBillingSettings(this.billingSettings).subscribe((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class SettingsStripeComponent implements OnInit, OnChanges {
public publicKey!: AbstractControl;
public immediateBillingAllowed!: AbstractControl;
public periodicBillingAllowed!: AbstractControl;
public lastSynchronizedOn!: AbstractControl;
public taxID!: AbstractControl;
public taxes: BillingTax[] = [];

Expand Down Expand Up @@ -50,7 +49,6 @@ export class SettingsStripeComponent implements OnInit, OnChanges {
),
immediateBillingAllowed: new FormControl(''),
periodicBillingAllowed: new FormControl(''),
lastSynchronizedOn: new FormControl(''),
taxID: new FormControl('',
Validators.compose([
// Validators.required,
Expand All @@ -68,7 +66,6 @@ export class SettingsStripeComponent implements OnInit, OnChanges {
this.publicKey = this.stripe.controls['publicKey'];
this.immediateBillingAllowed = this.stripe.controls['immediateBillingAllowed'];
this.periodicBillingAllowed = this.stripe.controls['periodicBillingAllowed'];
this.lastSynchronizedOn = this.stripe.controls['lastSynchronizedOn'];
this.taxID = this.stripe.controls['taxID'];

// Set data
Expand Down Expand Up @@ -112,17 +109,18 @@ export class SettingsStripeComponent implements OnInit, OnChanges {

private updateFormData() {
if (this.stripe) {
// Set data
this.url.setValue(this.billingSettings.stripe.url ? this.billingSettings.stripe.url : '');
this.secretKey.setValue(this.billingSettings.stripe.secretKey ? this.billingSettings.stripe.secretKey : '');
this.publicKey.setValue(this.billingSettings.stripe.publicKey ? this.billingSettings.stripe.publicKey : '');
this.immediateBillingAllowed.setValue(this.billingSettings.stripe.immediateBillingAllowed
? this.billingSettings.stripe.immediateBillingAllowed : false);
this.periodicBillingAllowed.setValue(this.billingSettings.stripe.periodicBillingAllowed
? this.billingSettings.stripe.periodicBillingAllowed : false);
this.lastSynchronizedOn.setValue(this.billingSettings.stripe.lastSynchronizedOn
? this.billingSettings.stripe.lastSynchronizedOn : '');
this.taxID.setValue(this.billingSettings.stripe.taxID ? this.billingSettings.stripe.taxID : '');
const stripeSetting = this.billingSettings.stripe;
if ( stripeSetting ) {
this.url.setValue(stripeSetting.url);
this.secretKey.setValue(stripeSetting.secretKey);
this.publicKey.setValue(stripeSetting.publicKey);
}
const billingSetting = this.billingSettings.billing;
if ( billingSetting ) {
this.immediateBillingAllowed.setValue(!!billingSetting.immediateBillingAllowed);
this.periodicBillingAllowed.setValue(!!billingSetting.periodicBillingAllowed);
this.taxID.setValue(billingSetting.taxID);
}
}
}
}
14 changes: 14 additions & 0 deletions src/app/release-notes/release-notes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ export class ReleaseNotesComponent {

public buildReleaseNotes() {
this.releaseNotes = [
{
version: '2.4.61',
date: new Date('2021-04-15'),
componentChanges: [
{
name: 'Dashboard',
changes: [
`Add DBT-CEV and EVMeter Charging Station's vendors`,
`Fixed Tag Import Mime type check in Windows`,
`Billing Stripe's settings refactoring`,
],
},
],
},
{
version: '2.4.60',
date: new Date('2021-04-14'),
Expand Down
7 changes: 4 additions & 3 deletions src/app/services/component.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ export class ComponentService {
if (settings.type === BillingSettingsType.STRIPE) {
settingsToSave.sensitiveData = ['content.stripe.secretKey'];
}
// Set some temporary defaults
settingsToSave.content.stripe.noCardAllowed = true;
settingsToSave.content.stripe.advanceBillingAllowed = false;
// Delete IDS
delete settingsToSave.content.id;
delete settingsToSave.content.identifier;
Expand Down Expand Up @@ -282,6 +279,10 @@ export class ComponentService {
// ID
billingSettings.id = settings.id;
billingSettings.sensitiveData = settings.sensitiveData;
// billing common properties
if (config.billing) {
billingSettings.billing = config.billing;
}
// Stripe
if (config.stripe) {
billingSettings.type = BillingSettingsType.STRIPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { SpinnerService } from 'services/spinner.service';
import { TableAction } from 'shared/table/actions/table-action';
import { ChargingStation, ChargingStationButtonAction, Connector } from 'types/ChargingStation';
import { ActionResponse } from 'types/DataResult';
import { ButtonColor, ButtonType, TableActionDef } from 'types/Table';
import { OCPPUnlockStatus } from 'types/ocpp/OCPP';
import { ButtonColor, ButtonType, TableActionDef } from 'types/Table';
import { Utils } from 'utils/Utils';

export interface TableChargingStationsUnlockConnectorActionDef extends TableActionDef {
Expand Down
27 changes: 13 additions & 14 deletions src/app/types/Setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface SettingDBContent {
oicp?: OicpSetting;
simple?: SimplePricingSetting;
convergentCharging?: ConvergentChargingPricingSetting;
billing?: BillingSetting;
stripe?: StripeBillingSetting;
sac?: SacAnalyticsSetting;
links?: SettingLink[];
Expand Down Expand Up @@ -195,30 +196,28 @@ export interface ConcurRefundSetting {
reportName: string;
}

export enum BillingSettingsType {
STRIPE = 'stripe',
}

export interface BillingSettings extends Setting {
export interface BillingSettings extends Setting{
identifier: TenantComponents.BILLING;
type: BillingSettingsType;
stripe: StripeBillingSetting;
billing: BillingSetting;
stripe?: StripeBillingSetting;
}

export interface BillingSetting {
lastSynchronizedOn?: Date;
immediateBillingAllowed: boolean;
periodicBillingAllowed: boolean;
taxID: string;
usersLastSynchronizedOn?: Date;
}

export interface StripeBillingSetting extends BillingSetting {
export interface StripeBillingSetting {
url: string;
secretKey: string;
publicKey: string;
noCardAllowed: boolean;
immediateBillingAllowed: boolean;
periodicBillingAllowed: boolean;
advanceBillingAllowed: boolean;
currency: string;
taxID: string;
}

export enum BillingSettingsType {
STRIPE = 'stripe',
}

export enum AssetSettingsType {
Expand Down
4 changes: 2 additions & 2 deletions src/app/types/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { BillingTransactionData } from './Billing';
import { Car, CarCatalog } from './Car';
import { ChargingStation } from './ChargingStation';
import Consumption, { AbstractCurrentConsumption } from './Consumption';
import { OCPICdr } from './ocpi/OCPICdr';
import { OCPISession } from './ocpi/OCPISession';
import { RefundStatus, RefundType } from './Refund';
import { Data } from './Table';
import { User } from './User';
import { OCPICdr } from './ocpi/OCPICdr';
import { OCPISession } from './ocpi/OCPISession';

export interface Transaction extends Data, AbstractCurrentConsumption {
id: number;
Expand Down
10 changes: 8 additions & 2 deletions src/app/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,12 @@ export class Utils {
chargingStation, chargePoint, connectorId, result.currentAmp);
return result;
}
const chargingStationAmperageLimit = Utils.getChargingStationAmperageLimit(chargingStation, chargePoint, connectorId);
// Use Limit Amps
if (forChargingProfile) {
result.maxAmp = Utils.getChargingStationAmperageLimit(chargingStation, chargePoint, connectorId);
result.maxAmp = chargingStationAmperageLimit;
} else {
result.currentAmp = Utils.getChargingStationAmperageLimit(chargingStation, chargePoint, connectorId);
result.currentAmp = chargingStationAmperageLimit;
result.maxAmp = Utils.getChargingStationAmperage(chargingStation, chargePoint, connectorId);
}
// Default
Expand Down Expand Up @@ -583,6 +584,11 @@ export class Utils {
}
}
}
const amperageMax = Utils.getChargingStationAmperage(chargingStation, chargePoint, connectorId);
// Check and default
if (amperageLimit === 0 || amperageLimit > amperageMax) {
amperageLimit = amperageMax;
}
return amperageLimit;
}

Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"connectors": "Verknüpfungen",
"notifications": "Benachrichtungen",
"app_name": "e-Mobility",
"last_update": "Version 2.4.60",
"last_update": "Version 2.4.61",
"version": "Version",
"about_us": "About Us",
"unexpected_error_backend": "Ein unerwarteter Fehler ist aufgetreten",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"connectors": "Connections",
"notifications": "Notifications",
"app_name": "e-Mobility",
"last_update": "Version 2.4.60",
"last_update": "Version 2.4.61",
"version": "Version",
"about_us": "About Us",
"unexpected_error_backend": "An unexpected error occurred, check the logs",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"connectors": "Conexiones",
"notifications": "Notificaciones",
"app_name": "e-Mobility",
"last_update": "Versión 2.4.60",
"last_update": "Versión 2.4.61",
"version": "Versión",
"about_us": "Sobre nosotros",
"unexpected_error_backend": "Ocurrió un error inesperado",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"connectors": "Connexions",
"notifications": "Notifications",
"app_name": "e-Mobility",
"last_update": "Version 2.4.60",
"last_update": "Version 2.4.61",
"version": "Version",
"about_us": "A Propos",
"unexpected_error_backend": "Une erreur inattendue s'est produite, vérifiez les logs",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"connectors": "Prese",
"notifications": "Notifiche",
"app_name": "e-Mobility",
"last_update": "Versione 2.4.60",
"last_update": "Versione 2.4.61",
"version": "Versione",
"about_us": "A proposito di noi",
"unexpected_error_backend": "Si è verificato un errore imprevisto",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"connectors": "Conexões",
"notifications": "Notificações",
"app_name": "e-Mobility",
"last_update": "Versão 2.4.60",
"last_update": "Versão 2.4.61",
"version": "Versão",
"about_us": "Sobre Nós",
"unexpected_error_backend": "Ocurreu um erro inesperado",
Expand Down

0 comments on commit 2e14334

Please sign in to comment.