Skip to content

lib-finHtmlReporting 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793717769/FIN+5.3.1+lib-finHtmlReporting 中文整理基于 FIN 5.3.1

导读: HTML 报告扩展

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • funcs
  • def
  • addReport(templateId, headerId, dataStr, addFile, fileUri, addEmail, address, topic, format, localeStrs: null)
  • finCsvHisReorderForm(title, filter, dateSpan, emails, jobDate, reorder, rollupSettings, precision)
    • src
  • finEmail(toPerson, p_subject, content)
  • finFormAddTenantsToEquip(id)
  • finFormEditPropertyManagerForm(id)
  • finFormEditTenant(id)
  • finFormEditUtilityBill()
  • finFormSelectTenantsForReport()
  • finHtmlReportingMainMenu()
  • finHtmlTemplate(noteTemplate, data, renderEmail: false, projCtx: null)
  • finSaveAs(path, content)
  • reportData()

概述(中译) ​

HTML 报告扩展


API 正文(英文) ​

funcs ​

addReport
finCsvHisReorderFormPart of CSV History Report
finEmailsupportive function to send email
finFormAddTenantsToEquipAxon function
finFormEditPropertyManagerFormForm to allow currently selected user to be changed to a property manager or edit a current property manager
finFormEditTenantForm to edit existing user into a tenant
finFormEditUtilityBillAxon function
finFormSelectTenantsForReportForm for setting up tenant reports
finHtmlReportingMainMenuAxon function
finHtmlTemplategenerate string from a handlebars template using handlebars.java engine @noteTemplate
finSaveAssupportive function to save text content to a file at path(uri)
reportDataAxon function


def ​

func:addReport ​

addReport(templateId, headerId, dataStr, addFile, fileUri, addEmail, address, topic, format, localeStrs: null) ​


meta ​

deffunc:addReport
isfunc
liblib:finHtmlReporting
nameaddReport

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finCsvHisReorderForm ​

finCsvHisReorderForm(title, filter, dateSpan, emails, jobDate, reorder, rollupSettings, precision) ​

Part of CSV History Report. If the user wants to choose the order of the columns that appear in the history report then this form appears.


meta ​

deffunc:finCsvHisReorderForm
distoLocale("finHtmlReporting::reorderHisCols")
isfunc
liblib:finHtmlReporting
namefinCsvHisReorderForm
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(title, filter, dateSpan, emails, jobDate, reorder, rollupSettings, precision) => do

  if(reorder == true) do
    newOrder: "["
    pointList: readAll(parseFilter(filter + " and point and his"))

    //create list
    body: [
      { name: "instructLabel", editorType: "label", text: toLocale("finHtmlReporting::changePointPosition") },

      { name: "cancelButton",  editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
      { name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true }
    ]

    each(pointList) (point, i) => do
      body = body.add({name:i + "pointOrder", editorType: "textinput", prompt: point.dis, defVal: i + 1})
      newOrder = newOrder + "{pos: \$"+ i + "pointOrder.parseInt, id:" + point->id.toAxonCode + "},"
    end

    newOrder = newOrder[0..-2] + "]"

    { "dis": toLocale("finHtmlReporting::reorderHisCols"),
    "name": "csvOrganizeOrder",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finCsvHisReportCreateJob(" + title.toAxonCode + ", " + filter.toAxonCode + ", " + dateSpan.toAxonCode + ", " + emails.toAxonCode + ", " + jobDate.toAxonCode + ", " + rollupSettings.toAxonCode + ", " + precision.toAxonCode + ", " + newOrder + ")",
    "helpDoc": "/wiki/display/FINStack/History+Report",
    "finForm": marker()
    }.toGrid.addMeta({formExecute: marker()})

  end
  else
    finCsvHisReportCreateJob(title, filter, dateSpan, emails, jobDate, rollupSettings, precision)

end


def ​

func:finEmail ​

finEmail(toPerson, p_subject, content) ​

supportive function to send email


meta ​

deffunc:finEmail
isfunc
liblib:finHtmlReporting
namefinEmail

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finFormAddTenantsToEquip ​

finFormAddTenantsToEquip(id) ​

Axon function


meta ​

appFormOnbuilder
deffunc:finFormAddTenantsToEquip
distoLocale("finHtmlReporting::trAssignTenantTitle")
folderPathtoLocale("finHtmlReporting::reports")
formOnequip
isfunc
liblib:finHtmlReporting
namefinFormAddTenantsToEquip
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  curEquip: readById(id)
  canChargeByUsage: readCount(point and occupancyIndicator and kind == "Number" and equipRef == curEquip->id) > 0

  if(not readAll(zoneMaster and tenantRef).isEmpty) finNormalizeTenantRefs()

  defPercent: curEquip.has("isPercentage") and curEquip->isPercentage
  hourlyRadio: { name: "chargeType", editorType: "radio", group: "typeOfCharge", label: "Charge Hourly", selectedValue: false }
  percentRadio: { name: "chargeType", editorType: "radio", group: "typeOfCharge", label: "Charge by Usage", selectedValue: true }

  body:[
    {
      name:"tenantList",
      editorType: "list",
      listType: "checkbox",
      prompt: toLocale("finHtmlReporting::trAssignTenantPrompt").replace("{0}", curEquip.dis),
      dataProvider: "finCreateTenantList("+id.toAxonCode+")",
      labelField: "dis",
      selectedValueTags: "id",
      defValTagName: "selected"
    },

    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
    { name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true }
  ]

  commitStr: ""

  if (canChargeByUsage)
  do
    if (defPercent) percentRadio = percentRadio.set("defVal", true)
    else hourlyRadio = hourlyRadio.set("defVal", true)

    body = body.addAll([hourlyRadio, percentRadio])
    commitStr = "if((isStr(\$chargeType) and parseBool(\$chargeType)) or (isBool(\$chargeType) and \$chargeType)) finFormTenantUsageSettings("+id.toAxonCode+", {zoneMaster, tenantRefs: \"@\"+(\$tenantList).concat(\",@\"), isPercentage: true}) else readById("+id.toAxonCode+").diff({zoneMaster, tenantRefs: \"@\"+(\$tenantList).concat(\",@\"), isPercentage: false}).commit"
  end
  else
  do
    hourlyRadio = hourlyRadio.set("defVal", true)
    body = body.addAll([hourlyRadio])
    commitStr = "readById("+id.toAxonCode+").diff({zoneMaster, tenantRefs: \"@\"+(\$tenantList).concat(\",@\"), isPercentage: false}).commit"
  end

  { "dis": toLocale("finHtmlReporting::trAssignTenantTitle"),
    "name": "finFormAddTenantsToEquip",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": commitStr,
    "finForm": marker()
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormEditPropertyManagerForm ​

finFormEditPropertyManagerForm(id) ​

Form to allow currently selected user to be changed to a property manager or edit a current property manager.


meta ​

deffunc:finFormEditPropertyManagerForm
distoLocale("finHtmlReporting::createEditManager")
folderPathtoLocale("finHtmlReporting::tenantReporting")
formOnuser
isfunc
liblib:finHtmlReporting
namefinFormEditPropertyManagerForm
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do
  addressInstruction: toLocale("finHtmlReporting::trCompanyAddressTip")
  companyNameInstruction: toLocale("finHtmlReporting::trCompanyNameTip")

  curUser: userReadById(id)
  address: ""
  company: ""
  isPropM: false

  groups: readAll(zoneMaster and isPercentage and group)

  if(curUser.has("propertyManager")) do
    if(curUser.has("address")) address = curUser->address
    if(curUser.has("companyName")) company = curUser->companyName
    isPropM = true
  end

  body: [
    {
      name: "companyNameText",
      editorType: "textinput",
      prompt: toLocale("finHtmlReporting::trCompanyNamePrompt") + ":",
      defVal: company,
      toolTip: companyNameInstruction
    },

    {
      name: "billAddress",
      editorType: "textinput",
      prompt: toLocale("finHtmlReporting::trCompanyAddressPrompt") + ":",
      defVal: address,
      toolTip: addressInstruction
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true}
  ]

  { "dis": if(isPropM) toLocale("finHtmlReporting::trEditPropertyManagerTitle").replace("{0}", curUser.dis) else toLocale("finHtmlReporting::trCreatePropertyManagerTitle").replace("{0}", curUser.dis),
    "name": "finFormEditPropertyManagerForm",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finEditManagerCommit(" + id.toAxonCode + ",\$billAddress, \$companyNameText)",
    "finForm": marker(),
    "helpDoc":"/wiki/display/FINStack/Create-Edit+Property+Manager"
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormEditTenant ​

finFormEditTenant(id) ​

Form to edit existing user into a tenant.

Allows user to select values for property tags required for tenant reporting and applies them to the currently selected user. Also add "tenant" tag to user.


meta ​

deffunc:finFormEditTenant
distoLocale("finHtmlReporting::createEditTenant")
folderPathtoLocale("finHtmlReporting::tenantReporting")
formOnuser
isfunc
liblib:finHtmlReporting
namefinFormEditTenant
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(id) => do

  billableInstuction: toLocale("finHtmlReporting::trTenantBillableTip")
  costInstuction: toLocale("finHtmlReporting::trTenantCostTip")
  tiggerInstuction: toLocale("finHtmlReporting::trTenantTriggerTip")
  roundInstruction: toLocale("finHtmlReporting::trTenantRoundTip")
  addressInstruction: toLocale("finHtmlReporting::trTenantAddressTip")
  billZoneInstruction: toLocale("finHtmlReporting::trTenantZoneTip")
  flatTip: "Will only charge the rate regardless of how many units are running."

  curUser: userReadById(id)
  minTime: "30min"
  cost: "1.00"
  currencies: unitdb().findAll(row => row->quantity == "currency").map(row => {val: row["symbol"]}).sort("val").toRecList
  currency: try userReadAll(tenantCostPerHour).colToList("tenantCostPerHour", false).first.unit catch "\$"
  rounded: false
  trigger: ""
  address: ""
  billZone:""
  flatRate: false
  custDate: false
  otherFees: false

  if(curUser.has("tenant")) do
    if(curUser.has("tenantBillableMinTime")) minTime = curUser->tenantBillableMinTime.toStr
    if(curUser.has("tenantCostPerHour")) do
      tenantCostPerHour: curUser->tenantCostPerHour
      currency = tenantCostPerHour.unit
      cost = tenantCostPerHour.finTenantRemoveUnits
    end
    if(curUser.has("roundUp")) rounded = curUser->roundUp
    if(curUser.has("tenantTriggerValue")) trigger = curUser->tenantTriggerValue
    if(curUser.has("address")) address = curUser->address
    if(curUser.has("billZone")) billZone = curUser->billZone
    if(curUser.has("flatRate")) flatRate = curUser->flatRate
    if(curUser.has("dateFormat")) custDate = curUser->dateFormat
    if((curUser.has("rentFee") and curUser->rentFee != 0) or (curUser.has("parkingFee") and curUser->parkingFee != 0) or (curUser.has("billingFee") and curUser->billingFee != 0) or (curUser.has("otherFee") and curUser->otherFee != 0) or (curUser.has("credit") and curUser->credit != 0))
      otherFees = true
  end

  body: [
    {
      name: "billAddress",
      editorType: "textinput",
      prompt: toLocale("finHtmlReporting::mailingAddress"),
      defVal: address,
      toolTip: addressInstruction
    },

    {
      name: "billZone",
      editorType: "textinput",
      prompt: toLocale("finHtmlReporting::billingArea"),
      defVal: billZone,
      toolTip: billZoneInstruction
    },

    {
      name: "tenantBillableText",
      editorType: "textinput",
      defVal: minTime,
      prompt: toLocale("finHtmlReporting::minBillTime"),
      toolTip:billableInstuction
    },

    {
      name: "tenantCostPerHourText",
      editorType: "textinput",
      defVal:cost,
      prompt: toLocale("finHtmlReporting::rate"),
      toolTip:costInstuction
    },

    {
      name: "currencies",
      editorType: "combobox",
      prompt: toLocale("finHtmlReporting::currency"),
      defIndex: currencies.map(r => r->val).index(currency),
      dataProvider: currencies.toAxonCode(),
      labelField: "val",
      selectedValueTags: "val"
    },

    {
      name: "filterForTrig",
      editorType:"filter",
      prompt: toLocale("finHtmlReporting::triggerPoint"),
      defVal: trigger,
      toolTip: tiggerInstuction
    },

    {
      name: "optionsGroup",
      editorType: "group",
      horizontal,
      children:[
        {name: "roundUpCheckbox", editorType: "checkbox", label:toLocale("finHtmlReporting::roundHours"), defVal: rounded, toolTip:roundInstruction},
        {name: "flatRateCheckbox", editorType: "checkbox", label: toLocale("finHtmlReporting::flateRate"), defVal: flatRate, toolTip: flatTip},
        {name: "otherFees", editorType: "checkbox", label: toLocale("finHtmlReporting::otherFees"), defVal: otherFees}
        //{name: "dateFormat", editorType: "checkbox", label: "Set date format", defVal: custDate}
      ]
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::ok"), controlBar: true}
  ]

  { "dis": toLocale("finHtmlReporting::createEditTenant").replace("{name}", curUser.dis),
    "name": "finFormEditTenant",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finFormTriggerType(" + id.toAxonCode + ", \$tenantBillableText,\$tenantCostPerHourText,\$currencies,\$filterForTrig,\$roundUpCheckbox, \$billAddress, \$billZone, \$flatRateCheckbox, \$otherFees)", //\$flatRateCheckbox
    "finForm": marker(),
    "helpDoc":"/wiki/display/FINStack/Create-Edit+Tenant"
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormEditUtilityBill ​

finFormEditUtilityBill() ​

Axon function


meta ​

appFormOnbuilder
deffunc:finFormEditUtilityBill
distoLocale("finHtmlReporting::setBillAmount")
folderPathtoLocale("finHtmlReporting::reports")
formOnequip
isfunc
liblib:finHtmlReporting
namefinFormEditUtilityBill
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  groupRecs: readAll(zoneMaster and isPercentage and group)
  commitStr: ""

  body:[
    { name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true },
    { name: "applyButton", editorType: "button", label: toLocale("finStackExt::coreApply"), controlBar: true }
  ]

  if(groupRecs.size > 0) do
    groups: groupRecs.colToList("group").unique
    validGroups: readAll(utilityGroup)
    commitStr = []

    groups.each x => do
      billAmount: try validGroups.find(v => v->groupName == x)->amount catch 0
      body = body.add({
        name: x.toTagName+"Group",
        editorType: "numericstepper",
        prompt: toLocale("finHtmlReporting::billAmountFor").replace("{groupName}", x),
        minVal: 0,
        step: "0.01",
        defVal: billAmount
      })
      commitStr = commitStr.add("{group: "+x.toAxonCode+", amount: \$"+x.toTagName+"Group}")
    end

    commitStr = "[" + commitStr.concat(",") + "]"
  end else
    body = body.add({name: "noGroups", editorType: "label", text: toLocale("finHtmlReporting::noZonesSetForPercentBill") })

  { "dis": toLocale("finHtmlReporting::setBillAmount"),
    "name": "finFormEditUtilityBill",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": if(groupRecs.size > 0) "readAll(utilityGroup).each(x => try x.diff({amount: "+commitStr+".find(v => v->group == x->groupName)->amount}).commit catch \"\")" else "",
    "finForm": marker(),
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finFormSelectTenantsForReport ​

finFormSelectTenantsForReport() ​

Form for setting up tenant reports


meta ​

appFormOnusers
deffunc:finFormSelectTenantsForReport
distoLocale("finHtmlReporting::tenantReporting")
folderPathtoLocale("finHtmlReporting::tenantReporting")
isfunc
liblib:finHtmlReporting
namefinFormSelectTenantsForReport
private✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  body: [
    {
      name: "pickuser",
      editorType: "list",
      dataProvider: "userReadAll(tenant)",
      listType:"checkbox",
      labelField: "dis",
      selectedValueTags: "id"
    },

    {name: "cancelButton", editorType: "button", label: toLocale("finStackExt::cancel"), controlBar: true},
    {name: "applyButton", editorType: "button", label: toLocale("finStackExt::next"), controlBar: true}
  ]

  { "dis": toLocale("finHtmlReporting::selectTenantsForReportsTitle"),
    "name": "finFormSelectTenantsForReport",
    "body": body.toJSON,
    "cancelButton": "\$cancelButton",
    "commitButton": "\$applyButton",
    "commitAction": "finFormTenantReportJob(\$pickuser)",
    "finForm": marker(),
    "helpDoc":"/wiki/display/FINStack/Tenant+Reporting"
  }.toGrid.addMeta({formExecute: marker()})
end


def ​

func:finHtmlReportingMainMenu ​

finHtmlReportingMainMenu() ​

Axon function


meta ​

deffunc:finHtmlReportingMainMenu
finStackMobileMenu✓
isfunc
liblib:finHtmlReporting
namefinHtmlReportingMainMenu

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

() => do
  nextMenuSettings: {
    header: toLocale("finHtmlReporting::finReports"),
    funcCall: "finHtmlReportingMenu()",
    display: "dis",
    keepOpen: true,
  }

  [{
    displayName: toLocale("finHtmlReporting::finReports"),
    appId: "finHtmlReports",
    icon: "icon-clipboard",
    iconType: "class",
    action: "window.app.ObtainMenu(null, '{{targetRef}}', 'finHtmlReports', "+nextMenuSettings.toAxonCode+")",
    level: 0,
    order: 106,
    ui: "html",
    keepOpen: true
   }]
end


def ​

func:finHtmlTemplate ​

finHtmlTemplate(noteTemplate, data, renderEmail: false, projCtx: null) ​

generate string from a handlebars template using handlebars.java engine

@noteTemplate : a tag that has property "tpl" hold the template or a bin ID or a string that represent template

@data : a dict or grid or a string,... that will be passed to handlebar for string generation

@renderEmail : true to return MultiPart email body. default is false to return string


meta ​

deffunc:finHtmlTemplate
isfunc
liblib:finHtmlReporting
namefinHtmlTemplate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:finSaveAs ​

finSaveAs(path, content) ​

supportive function to save text content to a file at path(uri)


meta ​

deffunc:finSaveAs
isfunc
liblib:finHtmlReporting
namefinSaveAs

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:reportData ​

reportData() ​

Axon function


meta ​

deffunc:reportData
disdata for report "site"
isfunc
liblib:finHtmlReporting
namereportData

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

()=> do
return finNavChildren("equip").finNavRollup().keepCols(["numManual","id","numAlarms","numUnackAlarms","dis","imageRef"])
  .addCol("points")(item=>"readAll(point and siteRef==@"+item->id.toStr+" and (write8 or write1)).map(row => row.set(\"who\",row.pointWriteArray()[row->writeLevel-1][\"who\"]))")
end