Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 从角度为7的数组中减去三行_Angular_Typescript - Fatal编程技术网

Angular 从角度为7的数组中减去三行

Angular 从角度为7的数组中减去三行,angular,typescript,Angular,Typescript,我想减去表的前3行 TVA Collectée-TVA免赔额TVA免赔额/immo 如果两者之间的差值为正值,我想将计算结果放入框TVA支付方中,如果差值为负值,则放入框Crédit de TVA 这是我的html代码: <div class="table-responsive"> <table class="styled-table" border="1" cellpadding="1&qu

我想减去表的前3行

TVA Collectée-TVA免赔额TVA免赔额/immo

如果两者之间的差值为正值,我想将计算结果放入框
TVA支付方
中,如果差值为负值,则放入框
Crédit de TVA

这是我的html代码:



  <div class="table-responsive">
    <table class="styled-table" border="1" cellpadding="1" cellspacing="1">
      <thead>
        <tr height="50">
          <th align="center" width="150">&nbsp;</th>
          <td align="center" width="150" *ngFor="let item of listdate">{{item}}</td>
        </tr>
      </thead>

      <tbody>
        <tr>

          <th>TVA Collectée</th>
          <ng-container *ngFor="let item of date">
            <td>
              <ng-container *ngFor="let c of listTvaVente">
                <label *ngIf="item === c.date">{{c.tvaCollectee | number : '0.3-3'}}</label>
              </ng-container>
            </td>
          </ng-container>

        </tr>
        <tr>
          <th>TVA Déductible</th>
          <ng-container *ngFor="let item of date">
            <td>
              <ng-container *ngFor="let c  of listTvaAchat ">
                <label *ngIf="item === c.date ">{{c.tvaDeductible| number : '0.3-3'}}</label>
              </ng-container>
            </td>
          </ng-container>
        </tr>

        <tr>
          <th>TVA Déductible/immo</th>
          <ng-container *ngFor="let item of date">
            <td>
              <ng-container *ngFor="let c  of listTvaInv ">
                <label *ngIf="item=== c.date ">{{c.tvaDeductible| number : '0.3-3'}}</label>
              </ng-container>
            </td>
          </ng-container>
        </tr>
        <tr>
          <th>TVA à Reporter</th>
        </tr>
        <tr>
          <th>TVA à Payer</th>
        </tr>
        <tr>
          <th>Crédit de TVA</th>
        </tr>

      </tbody>

    </table>
  </div>

下面是我想做的一个例子


提前感谢。

以下是您需要添加到代码中以获得所需内容的内容:

Typescript:

    listApayer = [
    {
      date: '2020-01',
      year: 2020,
      month: 'JANUARY',
      tvaPayer: 0
    },
    {
      date: '2020-02',
      year: 2020,
      month: 'FEBRUARY',
      tvaPayer: 0
    },
    {
      date: '2020-03',
      year: 2020,
      month: 'MARCH',
      tvaPayer: 0
    }
  ];

  creditTva = [
    {
      date: '2020-01',
      year: 2020,
      month: 'JANUARY',
      tvaCredit: 0
    },
    {
      date: '2020-02',
      year: 2020,
      month: 'FEBRUARY',
      tvaCredit: 0
    },
    {
      date: '2020-03',
      year: 2020,
      month: 'MARCH',
      tvaCredit: 0
    }
  ];

  constructor() {}

  ngOnInit() {
    const length = this.listdate.length;
    for (let i = 0; i < length; i++) {
      const subValue =
        this.listTvaVente[i].tvaCollectee -
        this.listTvaAchat[i].tvaDeductible -
        this.listTvaInv[i].tvaDeductible;

      if (subValue >= 0) {
        this.listApayer[i].tvaPayer = subValue;
      } else {
        this.creditTva[i].tvaCredit = subValue * -1;
      }
    }
  }
Typescript:
listApayer=[
{
日期:“2020-01”,
年份:2020年,
月份:'一月',
tvaPayer:0
},
{
日期:2020-02,
年份:2020年,
月份:'二月',
tvaPayer:0
},
{
日期:2020-03,
年份:2020年,
月份:'三月',
tvaPayer:0
}
];
creditTva=[
{
日期:“2020-01”,
年份:2020年,
月份:'一月',
tvaCredit:0
},
{
日期:2020-02,
年份:2020年,
月份:'二月',
tvaCredit:0
},
{
日期:2020-03,
年份:2020年,
月份:'三月',
tvaCredit:0
}
];
构造函数(){}
恩戈尼尼特(){
const length=this.listdate.length;
for(设i=0;i=0){
this.listApayer[i].tvaPayer=子值;
}否则{
this.creditTva[i].tvaCredit=subValue*-1;
}
}
}
对于.HTML:

     <tr>
    <th>TVA à Payer</th>
    <ng-container *ngFor="let item of date">
      <td>
        <ng-container *ngFor="let c  of listApayer ">
          <label *ngIf="item=== c.date ">{{c.tvaPayer| number : '0.3-3'}}</label>
        </ng-container>
      </td>
    </ng-container>
  </tr>
  <tr>
    <th>Crédit de TVA</th>
    <ng-container *ngFor="let item of date">
      <td>
        <ng-container *ngFor="let c  of creditTva ">
          <label *ngIf="item=== c.date ">{{c.tvaCredit| number : '0.3-3'}}</label>
        </ng-container>
      </td>
    </ng-container>
  </tr>

支付人
{c.tvaPayer |编号:'0.3-3'}
特瓦酒店
{c.tvaCredit |编号:'0.3-3'}

举个活生生的例子,请参考此链接:

当子值为负时,您应该使用我该怎么做我想将此值放入框
TVAáreporter
中,下个月的子值将以“TVA Collectée-TVA-relible TVA-relible TVA-relible/immo”的方式计算,如我在本节中提到的示例所示我已经更新了上面的例子。请查收。您在同一个月有TVA reporter和Crédit de TVA的案例如何?我想他们的总数应该加到下个月的TVA报告中,对吗?“对于下个月的计算,子值是这样计算的,TVA Collectée-TVA Equired TVA Equired/immo-Credit de TVA”=>这部分不清楚。你是说“信用卡”哪个月的?如果在当前月份,例如
1月
中,子值为负值,则在
credit de tva
框中添加该值,该月的
credit de tva
值将作为报告的信用移至
creditáreporté
,并将其包含在当月的计算中公式为:2月份的TVA Collectée-TVA可抵扣TVA可抵扣/immo-TVA reporter@ab.dev
     <tr>
    <th>TVA à Payer</th>
    <ng-container *ngFor="let item of date">
      <td>
        <ng-container *ngFor="let c  of listApayer ">
          <label *ngIf="item=== c.date ">{{c.tvaPayer| number : '0.3-3'}}</label>
        </ng-container>
      </td>
    </ng-container>
  </tr>
  <tr>
    <th>Crédit de TVA</th>
    <ng-container *ngFor="let item of date">
      <td>
        <ng-container *ngFor="let c  of creditTva ">
          <label *ngIf="item=== c.date ">{{c.tvaCredit| number : '0.3-3'}}</label>
        </ng-container>
      </td>
    </ng-container>
  </tr>