const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")

class SaasinvoiceService extends ServiceBase {
  constructor() {
    super();
  }

  async platforminvoicePage(params){
    var rs = await this.callms("invoice", "platforminvoicePage", params);
    if (rs && rs.data && rs.data.rows) {
      this.transOrderField(rs.data.rows);
    }
    return rs;
  }


  async platforminvoiceapplyPage(params){
    var rs = await this.callms("invoice", "platforminvoiceapplyPage", params);
    if (rs && rs.data && rs.data.rows) {
      this.transOrderField(rs.data.rows);
    }
    return rs;
  }

  async audit(params) {
    var rs = await this.callms("invoice", "invoiceapplyAudit", params);
    return rs;
  }

  async makeout(params) {
    var rs = await this.callms("invoice", "invoiceapplyMakeOut", params);
    return rs;
  }

  async invoiceapplyById(params) {
    var rs = await this.callms("invoice", "invoiceapplyById", params);
    return rs;
  }

  async applyBulkSave(params){
    var rs = await this.callms("invoice", "invoiceapplyBulkSave", params);
    return rs;
  }

  transOrderField(rows) {
    if (!rows || rows.length == 0) {
      return;
    }

    for (let row of rows) {
      row.price = system.f2y(row.price);
    }
  }
}
module.exports = SaasinvoiceService;