import{a2 as i}from"./index-DOFLUERq.js";const b=window;function S(e){const t=b.jingrow?.boot;if(!t?.user)return"";const s=t.user.defaults||{},f=t.user.user_permissions||{},m=e.toLowerCase().replace(/ /g,"_"),_=e.indexOf(":")===-1&&e!==m;let r=s[e];if(!r&&_){r=s[m];const a=f[e];if(a){for(let l=0;l<a.length;l++)s[e]===a[l].pg&&(r=a[l].pg);for(let l=0;l<a.length;l++)if(a[l].is_default){r=a[l].pg;break}}}Array.isArray(r)&&(r=r[0]);const c=f[_?e:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())];if(c?.length){let a=!1;for(let l=0;l<c.length;l++)if(c[l].pg===r){a=!0;break}if(!a)return""}return r||""}async function C(e,t){return(await(await fetch("/api/action/"+e,{method:"POST",headers:{"Content-Type":"application/json","X-Jingrow-CSRF-Token":b.jingrow.csrf_token,Accept:"application/json"},body:JSON.stringify(t)})).json()).message}async function o(){const e={};e.company=S("Company");try{const t=await C("jerp.accounts.utils.get_fiscal_year",{date:new Date().toISOString().split("T")[0]});t&&(e.fiscal_year=t)}catch{}return e}async function p(){const e={};e.company=S("Company");try{const t=await C("jerp.accounts.utils.get_fiscal_year",{date:new Date().toISOString().split("T")[0]});t&&(e.from_fiscal_year=t,e.to_fiscal_year=t)}catch{}return e}const d=[{fieldname:"period",label:"Period",fieldtype:"Select",options:`Monthly
Quarterly
Half-Yearly
Yearly`,default:"Monthly"},{fieldname:"based_on",label:"Based On",fieldtype:"Select",options:`Item
Item Group
Customer
Customer Group
Territory
Project`,default:"Item"},{fieldname:"group_by",label:"Group By",fieldtype:"Select",options:`
Item
Customer`,default:""},{fieldname:"fiscal_year",label:"Fiscal Year",fieldtype:"Link",options:"Fiscal Year"},{fieldname:"company",label:"Company",fieldtype:"Link",options:"Company"}],u=[{fieldname:"company",label:"Company",fieldtype:"Link",options:"Company",reqd:1},{fieldname:"period",label:"Period",fieldtype:"Select",options:`Monthly
Quarterly
Half-Yearly
Yearly`,default:"Monthly"},{fieldname:"fiscal_year",label:"Fiscal Year",fieldtype:"Link",options:"Fiscal Year"},{fieldname:"period_based_on",label:"Period based On",fieldtype:"Select",options:`posting_date
bill_date`,default:"posting_date"},{fieldname:"based_on",label:"Based On",fieldtype:"Select",options:`Item
Item Group
Supplier
Supplier Group
Project`,default:"Item"},{fieldname:"group_by",label:"Group By",fieldtype:"Select",options:`
Item
Supplier`,default:""}];function n(e){return JSON.parse(JSON.stringify(e))}i("Sales Order Trends",{filters:[...n(d),{fieldname:"include_closed_orders",label:"Include Closed Orders",fieldtype:"Check",default:0}],resolveDefaults:o});i("Sales Invoice Trends",{filters:n(d),resolveDefaults:o});i("Delivery Note Trends",{filters:n(d),resolveDefaults:o});i("Quotation Trends",{filters:n(d),resolveDefaults:o});i("Purchase Order Trends",{filters:[...n(u),{fieldname:"include_closed_orders",label:"Include Closed Orders",fieldtype:"Check",default:0}],resolveDefaults:o});i("Purchase Invoice Trends",{filters:n(u),resolveDefaults:o});i("Purchase Receipt Trends",{filters:n(u),resolveDefaults:o});const y=[{fieldname:"company",label:"Company",fieldtype:"Link",options:"Company",reqd:1},{fieldname:"finance_book",label:"Finance Book",fieldtype:"Link",options:"Finance Book"},{fieldname:"filter_based_on",label:"Filter Based On",fieldtype:"Select",options:`Fiscal Year
Date Range`,default:"Fiscal Year",reqd:1},{fieldname:"period_start_date",label:"Start Date",fieldtype:"Date"},{fieldname:"period_end_date",label:"End Date",fieldtype:"Date"},{fieldname:"from_fiscal_year",label:"Start Year",fieldtype:"Link",options:"Fiscal Year",reqd:1},{fieldname:"to_fiscal_year",label:"End Year",fieldtype:"Link",options:"Fiscal Year",reqd:1},{fieldname:"periodicity",label:"Periodicity",fieldtype:"Select",options:`Monthly
Quarterly
Half-Yearly
Yearly`,default:"Yearly",reqd:1},{fieldname:"presentation_currency",label:"Currency",fieldtype:"Select"},{fieldname:"cost_center",label:"Cost Center",fieldtype:"Link",options:"Cost Center"},{fieldname:"project",label:"Project",fieldtype:"Link",options:"Project"}],g=[{fieldname:"selected_view",label:"Select View",fieldtype:"Select",options:`Report
Growth
Margin`,default:"Report",reqd:1},{fieldname:"accumulated_values",label:"Accumulated Values",fieldtype:"Check",default:1},{fieldname:"include_default_book_entries",label:"Include Default FB Entries",fieldtype:"Check",default:1}];i("Profit and Loss Statement",{filters:[...n(y),...n(g)],resolveDefaults:p});i("Balance Sheet",{filters:[...n(y),{fieldname:"selected_view",label:"Select View",fieldtype:"Select",options:`Report
Growth`,default:"Report",reqd:1},{fieldname:"accumulated_values",label:"Accumulated Values",fieldtype:"Check",default:1},{fieldname:"include_default_book_entries",label:"Include Default FB Entries",fieldtype:"Check",default:1}],resolveDefaults:p});i("Cash Flow",{filters:[...n(y),{fieldname:"include_default_book_entries",label:"Include Default FB Entries",fieldtype:"Check",default:1}],resolveDefaults:p});
