import { Mapper } from './mapper';
import { Injectable } from '@angular/core';
import { RemissionProduct } from '../models/remission-product';
import { ReceiptItemDTO } from '@swagger/remi';

@Injectable()
export class ReceiptItemDtoToRemissionProductMapping implements Mapper<ReceiptItemDTO, RemissionProduct> {
  get sourceName() {
    return 'ReceiptItemDTO';
  }

  get targetName() {
    return 'RemissionProduct';
  }

  map(source: ReceiptItemDTO): RemissionProduct {
    return {
      id: source.id,
      imageId: source.product && source.product.ean,
      contributors: source.product && source.product.contributors,
      name: source.product && source.product.name,
      format: source.product && source.product.format,
      formatDetail: source.product && source.product.formatDetail,
      ean: source.product && source.product.ean,
      price: source.price && source.price.value.value,
      currency: source.price && source.price.value.currency,
      productGroup: source.product && source.product.productGroup,
      productGroupName: '',
      inStock: null,
      remainingQuantity: null,
      remissionQuantity: source.quantity,
      placementType: 'Leistung',
      remissionReason: '',
      edition: source.product && source.product.volume,
      features: [],
    } as RemissionProduct;
  }
}
