billing/pricing - currency moved out from item
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -885,7 +885,7 @@ export default class StripeBillingIntegration extends BillingIntegration {
// Do not bill that dimension
return null;
}
- const currency = effectivePricing.currency.toLowerCase();
+ const currency = billingInvoiceItem.currency.toLowerCase();
// Tax rates
const tax_rates = effectivePricing[pricingDimension].taxes || [];
// Build stripe parameters for the parking time
@@ -1024,10 +1024,11 @@ export default class StripeBillingIntegration extends BillingIntegration {
private shrinkInvoiceItem(fatInvoiceItem: BillingInvoiceItem): BillingInvoiceItem {
// The initial invoice item includes redundant transaction data
- const { transactionID, effectivePricing } = fatInvoiceItem;
+ const { transactionID, currency, effectivePricing } = fatInvoiceItem;
// Let's return only essential information
const lightInvoiceItem: BillingInvoiceItem = {
transactionID,
+ currency,
effectivePricing
};
return lightInvoiceItem;
@@ -1052,8 +1053,8 @@ export default class StripeBillingIntegration extends BillingIntegration {
// Build a billing invoice item based on the transaction
const billingInvoiceItem: BillingInvoiceItem = {
transactionID,
- effectivePricing: {
currency,
+ effectivePricing: {
energy: {
itemDescription,
amount,

MODIFY
src/types/Billing.ts
src/types/Billing.ts
@@ -82,9 +82,8 @@ export interface BillingInvoice {
}
export interface BillingInvoiceItem {
- // description: string;
transactionID: number;
- // pricingData: BillingPricingData;
+ currency: string;
effectivePricing: EffectivePricing
metadata?: {
// Just a flat list of key/value pairs!

MODIFY
src/types/Pricing.ts
src/types/Pricing.ts
@@ -7,8 +7,6 @@ export interface PricingModel {
}
export interface Pricing {
- comment?: string,
- // components: PricingComponent[];
flatFee?: PricingComponent,
energy?: PricingComponent,
parkingTime?: PricingComponent,
@@ -54,8 +52,6 @@ export enum DayOfWeek {
// }
export interface EffectivePricing {
- currency: string,
- // pricingSource: EffectivePricingData;
flatFee?: EffectivePricingData,
energy?: EffectivePricingData,
parkingTime?: EffectivePricingData,

MODIFY
test/api/BillingStripeTestData.ts
test/api/BillingStripeTestData.ts
@@ -279,7 +279,6 @@ export default class StripeIntegrationTestData {
const taxes = (consumptionTestData.taxId) ? [ consumptionTestData.taxId ] : [];
// Princing/Consumption Data
const effectivePricing: EffectivePricing = {
- currency: 'EUR',
energy: {
itemDescription: `Energy consumption - ${consumptionTestData.energyConsumptionkWh} kWh * ${consumptionTestData.energyAmount / consumptionTestData.energyConsumptionkWh} Eur`,
amount: consumptionTestData.energyAmount, // total amount to bill - not yet in cents
@@ -295,6 +294,7 @@ export default class StripeIntegrationTestData {
};
// Invoice Item
const invoiceItem:BillingInvoiceItem = {
+ currency: 'EUR',
transactionID: Utils.getRandomIntSafe(),
effectivePricing
};

billing/pricing - currency moved out from item