import { Component, OnInit, Inject } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { ApiService } from 'app/api.service';
import { DecimalPipe } from '@angular/common';

@Component({
  selector: 'app-customers-prescription',
  templateUrl: './customers-prescription.component.html',
  styleUrls: ['./customers-prescription.component.scss']
})
export class CustomersPrescriptionComponent implements OnInit {
  public header: any = [];
  public details: any = [];
  constructor(private title: Title, public num: DecimalPipe, public apiService: ApiService, public dialogRef: MatDialogRef<CustomersPrescriptionComponent>, @Inject(MAT_DIALOG_DATA) public data: any) {
    this.apiService.getCustomerPrescriptions(this.data.id).subscribe((data:any)=> {
      this.header = data.header;
      this.details = data.account;
    });
  }

  ngOnInit() {
  }
  cargo(n:string) {
    let x = parseFloat(n) || 0;
    if (x >= 0) {
      return '';
    } else {
      return this.num.transform(n);
    }
  }
  abono(n:string) {
    let x = parseFloat(n) || 0;
    if (x <= 0) {
      return '';
    } else {
      return this.num.transform(n);
    }
  }

}
