addUnitInfo.js 4.7 KB
// pages/main/finalpay/addUnitInfo/addUnitInfo.js

var app = getApp();
var baseUrl = app.globalData.baseUrl;
Page({


  data: {
    year: "2019",
    unit_id:"",
  },


  onLoad: function(options) {
    this.setData({
      unit_id:options.unit_id
    })
  },


  onReady: function() {

  },


  onShow: function() {

  },

  formSubmit: function(e) { //提交
    console.log("formSubmit", e);
    var formdata = e.detail.value
    if (formdata.total_salary || formdata.total_salary || formdata.remuneration_labor || formdata.author_payment || formdata.special_manage_cost || formdata.other_free_income || formdata.personal_endowment || formdata.personal_medical || formdata.personal_unemployment || formdata.personal_house_fund || formdata.childrens_education || formdata.continuing_education || formdata.housing_loan_interest || formdata.housing_rent || formdata.caring_old_people || formdata.serious_illness_medical || formdata.annuity || formdata.commercial_insurance || formdata.tax_extension || formdata.other_fee || formdata.donation_deducted || formdata.years_bouns || formdata.tax_savings || formdata.accumulated_withholding_tax){
      this.submitRequest(formdata)
    }else{
      this.showToast("请输入内容")
      return
    }
  },

  submitRequest: function(request_data) {
    var that = this
    this.Authorization = getApp().globalData.Authorization;
    wx.request({
      url: baseUrl + "payroll/v1/settlement-tax/record",
      header: {
        'Authorization': this.Authorization
      },
      method: "POST",
      data: {
        "declaring_unit_id":that.data.unit_id,
        "item": {
          "total_salary": that.parseToFloat(request_data.total_salary),  //工资薪金,
          "remuneration_labor": that.parseToFloat(request_data.setData),  //劳务报酬,
          "author_payment": that.parseToFloat(request_data.remuneration_labor),  //稿酬,
          "special_manage_cost": that.parseToFloat(request_data.special_manage_cost),  //特许经营权使用费,
          "other_free_income": that.parseToFloat(request_data.other_free_income),  //其他免税收入,

          "personal_endowment": that.parseToFloat(request_data.personal_endowment),  //基本养老保险,
          "personal_medical": that.parseToFloat(request_data.personal_medical),  //基本医疗保险,
          "personal_unemployment": that.parseToFloat(request_data.personal_unemployment),  //失业险,
          "personal_house_fund": that.parseToFloat(request_data.personal_house_fund),  //住房公积金,
          "childrens_education": that.parseToFloat(request_data.childrens_education),  //子女教育支出,
          "caring_old_people": that.parseToFloat(request_data.caring_old_people),  //赡养老人
          "housing_loan_interest": that.parseToFloat(request_data.housing_loan_interest),  //住房贷款利息支出
          "housing_rent": that.parseToFloat(request_data.housing_rent),   //住房租金支出
          "serious_illness_medical": that.parseToFloat(request_data.serious_illness_medical),//大病医疗支出
          "continuing_education": that.parseToFloat(request_data.continuing_education),  //继续教育支出

          "annuity": that.parseToFloat(request_data.annuity),  //年金
          "commercial_insurance": that.parseToFloat(request_data.commercial_insurance),  //商业健康保险
          "tax_extension": that.parseToFloat(request_data.tax_extension),   //税延养老保险
          "other_fee": that.parseToFloat(request_data.other_fee),//其他税前扣除额
          "donation_deducted": that.parseToFloat(request_data.donation_deducted),  //准予扣除的捐赠
          "years_bouns": that.parseToFloat(request_data.years_bouns),  //全年一次性奖金

          "tax_savings": that.parseToFloat(request_data.tax_savings),  //减免税额
          "accumulated_withholding_tax": that.parseToFloat(request_data.accumulated_withholding_tax),  //应扣缴税额
        },
        "years": that.data.year
      },
      success: function(result) {
        console.log("refund", result)
        if (result.statusCode == 200) {
            that.showToast("提交成功!")
            wx.navigateBack({
              delta:1
            })
        }else{
          that.showToast(result.data.message)
        }
      },
    })
  },

  parseToFloat(s){
    if(s&&s.length>0){
      var num = parseFloat(s)
      return Math.round(num*100)/100
    }else{
      return 0
    }
    
  },

  showToast: function(data) {
    if (data && data.length > 0) {
      wx.showToast({
        title: data,
        icon: "none",
        duration: 2000
      })
    }
  },

  onHide: function() {

  },


  onUnload: function() {

  },


  onPullDownRefresh: function() {

  },


  onReachBottom: function() {

  },


  onShareAppMessage: function() {

  }
})