"],SELECT:['"]}}var Cp=function(t,e,n){var i,r,a,o,s,u=[];if(null!=t&&""!==t){for(_p&&(r=xp[e.tagName])?(i=bi("DIV"),i.innerHTML=r[0]+t+r[1],i=i.querySelector(".x"),"SELECT"===i.tagName&&(a=i.options[i.selectedIndex])):e.namespaceURI===is.svg?(i=bi("DIV"),i.innerHTML='",i=i.querySelector(".x")):(i=bi(e.tagName),i.innerHTML=t,"SELECT"===i.tagName&&(a=i.options[i.selectedIndex]));o=i.firstChild;)u.push(o),n.appendChild(o);if("SELECT"===e.tagName)for(s=u.length;s--;)u[s]!==a&&(u[s].selected=!1)}return u},Pp=wi,Ep=Ti,Mp=ki,Dp=Ai,Lp=Ci,Op=Pi,Rp=function(t){this.type=Bc,Jf.init(this,t)};Rp.prototype={detach:wp,find:Sp,findAll:Tp,firstNode:kp,getValue:Jf.getValue,rebind:Jf.rebind,render:Ep,resolve:Jf.resolve,setValue:Mp,toString:Dp,unbind:Mf,unrender:Lp,update:Op};var Ip,Vp,Np,Fp,jp=Rp,Gp=function(){this.parentFragment.bubble()},Yp=Ei,Hp=function(t){return this.node?hs(this.node,t)?this.node:this.fragment&&this.fragment.find?this.fragment.find(t):void 0:null},zp=function(t,e){e._test(this,!0)&&e.live&&(this.liveQueries||(this.liveQueries=[])).push(e),this.fragment&&this.fragment.findAll(t,e)},Bp=function(t,e){this.fragment&&this.fragment.findAllComponents(t,e)},Up=function(t){if(this.fragment)return this.fragment.findComponent(t)},Wp=Mi,qp=Di,Xp=Li,$p=/^true|on|yes|1$/i,Qp=/^[0-9]+$/,Zp=function(t,e){var n,i,r;return r=e.a||{},i={},n=r.twoway,void 0!==n&&(i.twoway=0===n||$p.test(n)),n=r.lazy,void 0!==n&&(0!==n&&Qp.test(n)?i.lazy=parseInt(n):i.lazy=0===n||$p.test(n)),i},Kp=Oi;Ip="altGlyph altGlyphDef altGlyphItem animateColor animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject glyphRef linearGradient radialGradient textPath vkern".split(" "),Vp="attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits contentScriptType contentStyleType diffuseConstant edgeMode externalResourcesRequired filterRes filterUnits glyphRef gradientTransform gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan".split(" "),Np=function(t){for(var e={},n=t.length;n--;)e[t[n].toLowerCase()]=t[n];return e},Fp=Np(Ip.concat(Vp));var Jp=function(t){var e=t.toLowerCase();return Fp[e]||e},tg=function(t,e){var n,i;if(-1===(n=e.indexOf(":"))||"xmlns"===(i=e.substr(0,n)))t.name=t.element.namespace!==is.html?Jp(e):e;else if(e=e.substring(n+1),t.name=Jp(e),t.namespace=is[i.toLowerCase()],t.namespacePrefix=i,!t.namespace)throw'Unknown namespace ("'+i+'")'},eg=Ri,ng=Ii,ig=Vi,rg=Ni,ag={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor",class:"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName",for:"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},og=Fi,sg=Gi,ug=Yi,cg=Hi,lg=zi,hg=Bi,dg=Ui,fg=Wi,pg=qi,gg=Xi,mg=$i,vg=Qi,yg=Zi,_g=Ki,xg=Ji,bg=function(t){this.init(t)};bg.prototype={bubble:Kp,init:ng,rebind:ig,render:rg,toString:og,unbind:sg,update:xg};var wg,Sg=bg,Tg=function(t,e){var n,i,r=[];for(n in e)"twoway"!==n&&"lazy"!==n&&e.hasOwnProperty(n)&&(i=new Sg({element:t,name:n,value:e[n],root:t.root}),r[n]=i,"value"!==n&&r.push(i));return(i=r.value)&&r.push(i),r};"undefined"!=typeof document&&(wg=ls("div"));var kg=function(t,e){this.element=t,this.root=t.root,this.parentFragment=t.parentFragment,this.attributes=[],this.fragment=new d_({root:t.root,owner:this,template:[e]})};kg.prototype={bubble:function(){this.node&&this.update(),this.element.bubble()},rebind:function(t,e){this.fragment.rebind(t,e)},render:function(t){this.node=t,this.isSvg=t.namespaceURI===is.svg,this.update()},unbind:function(){this.fragment.unbind()},update:function(){var t,e,n=this;t=this.fragment.toString(),e=tr(t,this.isSvg),this.attributes.filter(function(t){return er(e,t)}).forEach(function(t){n.node.removeAttribute(t.name)}),e.forEach(function(t){n.node.setAttribute(t.name,t.value)}),this.attributes=e},toString:function(){return this.fragment.toString()}};var Ag=kg,Cg=function(t,e){return e?e.map(function(e){return new Ag(t,e)}):[]},Pg=function(t){var e,n,i,r;if(this.element=t,this.root=t.root,this.attribute=t.attributes[this.name||"value"],e=this.attribute.interpolator,e.twowayBinding=this,n=e.keypath){if("}"===n.str.slice(-1))return m("Two-way binding does not work with expressions (`%s` on <%s>)",e.resolver.uniqueString,t.name,{ractive:this.root}),!1;if(n.isSpecial)return m("Two-way binding does not work with %s",e.resolver.ref,{ractive:this.root}),!1}else{g("The %s being used for two-way binding is ambiguous, and may cause unexpected results. Consider initialising your data to eliminate the ambiguity",e.template.r?"'"+e.template.r+"' reference":"expression",{ractive:this.root}),e.resolver.forceResolution(),n=e.keypath}this.attribute.isTwoway=!0,this.keypath=n,i=this.root.viewmodel.get(n),void 0===i&&this.getInitialValue&&void 0!==(i=this.getInitialValue())&&this.root.viewmodel.set(n,i),(r=nr(t))&&(this.resetValue=i,r.formBindings.push(this))};Pg.prototype={handleChange:function(){var t=this;du.start(this.root),this.attribute.locked=!0,this.root.viewmodel.set(this.keypath,this.getValue()),du.scheduleTask(function(){return t.attribute.locked=!1}),du.end()},rebound:function(){var t,e,n;e=this.keypath,n=this.attribute.interpolator.keypath,e!==n&&(V(this.root._twowayBindings[e.str],this),this.keypath=n,t=this.root._twowayBindings[n.str]||(this.root._twowayBindings[n.str]=[]),t.push(this))},unbind:function(){}},Pg.extend=function(t){var e,n=this;return e=function(t){Pg.call(this,t),this.init&&this.init()},e.prototype=_s(n.prototype),i(e.prototype,t),e.extend=Pg.extend,e};var Eg,Mg=Pg,Dg=ir;Eg=Mg.extend({getInitialValue:function(){return""},getValue:function(){return this.element.node.value},render:function(){var t,e=this.element.node,n=!1;this.rendered=!0,t=this.root.lazy,!0===this.element.lazy?t=!0:!1===this.element.lazy?t=!1:u(this.element.lazy)?(t=!1,n=+this.element.lazy):u(t||"")&&(n=+t,t=!1,this.element.lazy=n),this.handler=n?ar:Dg,e.addEventListener("change",Dg,!1),t||(e.addEventListener("input",this.handler,!1),e.attachEvent&&e.addEventListener("keyup",this.handler,!1)),e.addEventListener("blur",rr,!1)},unrender:function(){var t=this.element.node;this.rendered=!1,t.removeEventListener("change",Dg,!1),t.removeEventListener("input",this.handler,!1),t.removeEventListener("keyup",this.handler,!1),t.removeEventListener("blur",rr,!1)}});var Lg=Eg,Og=Lg.extend({getInitialValue:function(){return this.element.fragment?this.element.fragment.toString():""},getValue:function(){return this.element.node.innerHTML}}),Rg=Og,Ig=or,Vg={},Ng=Mg.extend({name:"checked",init:function(){this.siblings=Ig(this.root._guid,"radio",this.element.getAttribute("name")),this.siblings.push(this)},render:function(){var t=this.element.node;t.addEventListener("change",Dg,!1),t.attachEvent&&t.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},handleChange:function(){du.start(this.root),this.siblings.forEach(function(t){t.root.viewmodel.set(t.keypath,t.getValue())}),du.end()},getValue:function(){return this.element.node.checked},unbind:function(){V(this.siblings,this)}}),Fg=Ng,jg=Mg.extend({name:"name",init:function(){this.siblings=Ig(this.root._guid,"radioname",this.keypath.str),this.siblings.push(this),this.radioName=!0},getInitialValue:function(){if(this.element.getAttribute("checked"))return this.element.getAttribute("value")},render:function(){var t=this.element.node;t.name="{{"+this.keypath.str+"}}",t.checked=this.root.viewmodel.get(this.keypath)==this.element.getAttribute("value"),t.addEventListener("change",Dg,!1),t.attachEvent&&t.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},getValue:function(){var t=this.element.node;return t._ractive?t._ractive.value:t.value},handleChange:function(){this.element.node.checked&&Mg.prototype.handleChange.call(this)},rebound:function(t,e){var n;Mg.prototype.rebound.call(this,t,e),(n=this.element.node)&&(n.name="{{"+this.keypath.str+"}}")},unbind:function(){V(this.siblings,this)}}),Gg=jg,Yg=Mg.extend({name:"name",getInitialValue:function(){return this.noInitialValue=!0,[]},init:function(){var t,e;this.checkboxName=!0,this.siblings=Ig(this.root._guid,"checkboxes",this.keypath.str),this.siblings.push(this),this.noInitialValue&&(this.siblings.noInitialValue=!0),this.siblings.noInitialValue&&this.element.getAttribute("checked")&&(t=this.root.viewmodel.get(this.keypath),e=this.element.getAttribute("value"),t.push(e))},unbind:function(){V(this.siblings,this)},render:function(){var t,e,n=this.element.node;t=this.root.viewmodel.get(this.keypath),e=this.element.getAttribute("value"),a(t)?this.isChecked=L(t,e):this.isChecked=t==e,n.name="{{"+this.keypath.str+"}}",n.checked=this.isChecked,n.addEventListener("change",Dg,!1),n.attachEvent&&n.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},changed:function(){var t=!!this.isChecked;return this.isChecked=this.element.node.checked,this.isChecked===t},handleChange:function(){this.isChecked=this.element.node.checked,Mg.prototype.handleChange.call(this)},getValue:function(){return this.siblings.filter(sr).map(ur)}}),Hg=Yg,zg=Mg.extend({name:"checked",render:function(){var t=this.element.node;t.addEventListener("change",Dg,!1),t.attachEvent&&t.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},getValue:function(){return this.element.node.checked}}),Bg=zg,Ug=Mg.extend({getInitialValue:function(){var t,e,n,i,r=this.element.options;if(void 0===this.element.getAttribute("value")&&(e=t=r.length,t)){for(;e--;)if(r[e].getAttribute("selected")){n=r[e].getAttribute("value"),i=!0;break}if(!i)for(;++ethis.end?(this.step&&this.step(1),this.complete&&this.complete(1),!1):(e=t-this.start,n=this.easing(e/this.duration),this.step&&this.step(n),!0))},stop:function(){this.abort&&this.abort(),this.running=!1}};var Dm,Lm,Om,Rm,Im,Vm,Nm,Fm,jm=Mm,Gm=new RegExp("^-(?:"+as.join("|")+")-"),Ym=function(t){return t.replace(Gm,"")},Hm=new RegExp("^(?:"+as.join("|")+")([A-Z])"),zm=function(t){return t?(Hm.test(t)&&(t="-"+t),t.replace(/[A-Z]/g,function(t){return"-"+t.toLowerCase()})):""},Bm={},Um={};Jo?(Lm=ls("div").style,function(){void 0!==Lm.transition?(Om="transition",Rm="transitionend",Im=!0):void 0!==Lm.webkitTransition?(Om="webkitTransition",Rm="webkitTransitionEnd",Im=!0):Im=!1}(),Om&&(Vm=Om+"Duration",Nm=Om+"Property",Fm=Om+"TimingFunction"),Dm=function(t,e,n,i,r){setTimeout(function(){var a,o,s,u,c;u=function(){o&&s&&(t.root.fire(t.name+":end",t.node,t.isIntro),r())},a=(t.node.namespaceURI||"")+t.node.tagName,t.node.style[Nm]=i.map(Cm).map(zm).join(","),t.node.style[Fm]=zm(n.easing||"linear"),t.node.style[Vm]=n.duration/1e3+"s",c=function(e){var n;n=i.indexOf(Tm(Ym(e.propertyName))),-1!==n&&i.splice(n,1),i.length||(t.node.removeEventListener(Rm,c,!1),s=!0,u())},t.node.addEventListener(Rm,c,!1),setTimeout(function(){for(var r,l,h,d,f,p=i.length,m=[];p--;)d=i[p],r=a+d,Im&&!Um[r]&&(t.node.style[Cm(d)]=e[d],Bm[r]||(l=t.getStyle(d),Bm[r]=t.getStyle(d)!=e[d],Um[r]=!Bm[r],Um[r]&&(t.node.style[Cm(d)]=l))),Im&&!Um[r]||(void 0===l&&(l=t.getStyle(d)),h=i.indexOf(d),-1===h?g("Something very strange happened with transitions. Please raise an issue at https://github.com/ractivejs/ractive/issues - thanks!",{node:t.node}):i.splice(h,1),f=/[^\d]*$/.exec(e[d])[0],m.push({name:Cm(d),interpolator:Rs(parseFloat(l),parseFloat(e[d])),suffix:f}));m.length?new jm({root:t.root,duration:n.duration,easing:Tm(n.easing||""),step:function(e){var n,i;for(i=m.length;i--;)n=m[i],t.node.style[n.name]=n.interpolator(e)+n.suffix},complete:function(){o=!0,u()}}):o=!0,i.length||(t.node.removeEventListener(Rm,c,!1),s=!0,u())},0)},n.delay||0)}):Dm=null;var Wm,qm,Xm,$m,Qm,Zm=Dm;if("undefined"!=typeof document){if(Wm="hidden",Qm={},Wm in document)Xm="";else for($m=as.length;$m--;)qm=as[$m],(Wm=qm+"Hidden")in document&&(Xm=qm);void 0!==Xm?(document.addEventListener(Xm+"visibilitychange",Yr),Yr()):("onfocusout"in document?(document.addEventListener("focusout",Hr),document.addEventListener("focusin",zr)):(window.addEventListener("pagehide",Hr),window.addEventListener("blur",Hr),window.addEventListener("pageshow",zr),window.addEventListener("focus",zr)),Qm.hidden=!1)}var Km,Jm,tv,ev=Qm;Jo?(Jm=window.getComputedStyle||null.getComputedStyle,Km=function(t,e,n){var i,r=this;if(4===arguments.length)throw new Error("t.animateStyle() returns a promise - use .then() instead of passing a callback");return ev.hidden?(this.setStyle(t,e),tv||(tv=iu.resolve())):("string"==typeof t?(i={},i[t]=e):(i=t,n=e),n||(m('The "%s" transition does not supply an options object to `t.animateStyle()`. This will break in a future version of Ractive. For more info see https://github.com/RactiveJS/Ractive/issues/340',this.name),n=this),new iu(function(t){var e,a,o,s,u,c;if(!n.duration)return r.setStyle(i),void t();for(e=Object.keys(i),a=[],o=Jm(r.node),{},u=e.length;u--;)c=e[u],s=o[Cm(c)],"0px"===s&&(s=0),s!=i[c]&&(a.push(c),r.node.style[Cm(c)]=s);if(!a.length)return void t();Zm(r,i,n,a,t)}))}):Km=null;var nv=Km,iv=function(t,e){return"number"==typeof t?t={duration:t}:"string"==typeof t?t="slow"===t?{duration:600}:"fast"===t?{duration:200}:{duration:400}:t||(t={}),r({},t,e)},rv=Br,av=function(t,e,n){this.init(t,e,n)};av.prototype={init:Sm,start:rv,getStyle:Pm,setStyle:Em,animateStyle:nv,processParams:iv};var ov,sv,uv=av,cv=Wr;ov=function(){var t=this.node,e=this.fragment.toString(!1);if(window&&window.appearsToBeIELessEqual8&&(t.type="text/css"),t.styleSheet)t.styleSheet.cssText=e;else{for(;t.hasChildNodes();)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}},sv=function(){this.node.type&&"text/javascript"!==this.node.type||g("Script tag was updated. This does not cause the code to be re-evaluated!",{ractive:this.root}),this.node.text=this.fragment.toString(!1)};var lv=function(){var t,e;return this.template.y?"":(t="<"+this.template.e,t+=this.attributes.map(Kr).join("")+this.conditionalAttributes.map(Kr).join(""),"option"===this.name&&Qr(this)&&(t+=" selected"),"input"===this.name&&Zr(this)&&(t+=" checked"),t+=">","textarea"===this.name&&void 0!==this.getAttribute("value")?t+=Ae(this.getAttribute("value")):void 0!==this.getAttribute("contenteditable")&&(t+=this.getAttribute("value")||""),this.fragment&&(e="script"!==this.name&&"style"!==this.name,t+=this.fragment.toString(e)),ph.test(this.template.e)||(t+=""+this.template.e+">"),t)},hv=Jr,dv=ta,fv=function(t){this.init(t)};fv.prototype={bubble:Gp,detach:Yp,find:Hp,findAll:zp,findAllComponents:Bp,findComponent:Up,findNextNode:Wp,firstNode:qp,getAttribute:Xp,init:bm,rebind:wm,render:cv,toString:lv,unbind:hv,unrender:dv};var pv=fv,gv=/^\s*$/,mv=/^\s*/,vv=function(t){var e,n,i,r;return e=t.split("\n"),n=e[0],void 0!==n&&gv.test(n)&&e.shift(),i=I(e),void 0!==i&&gv.test(i)&&e.pop(),r=e.reduce(na,null),r&&(t=e.map(function(t){return t.replace(r,"")}).join("\n")),t},yv=ia,_v=function(t,e){return e?t.split("\n").map(function(t,n){return n?e+t:t}).join("\n"):t},xv=function(t){var e,n;e=this.parentFragment=t.parentFragment,this.root=e.root,this.type=$c,this.index=t.index,this.name=t.template.r,this.rendered=!1,this.fragment=this.fragmentToRender=this.fragmentToUnrender=null,Jf.init(this,t),this.keypath||((n=yv(this.root,this.name,e))?(Mf.call(this),this.isNamed=!0,this.setTemplate(n)):m('Could not find template for partial "%s"',this.name))};xv.prototype={bubble:function(){this.parentFragment.bubble()},detach:function(){return this.fragment.detach()},find:function(t){return this.fragment.find(t)},findAll:function(t,e){return this.fragment.findAll(t,e)},findComponent:function(t){return this.fragment.findComponent(t)},findAllComponents:function(t,e){return this.fragment.findAllComponents(t,e)},firstNode:function(){return this.fragment.firstNode()},findNextNode:function(){return this.parentFragment.findNextNode(this)},getPartialName:function(){return this.isNamed&&this.name?this.name:void 0===this.value?this.name:this.value},getValue:function(){return this.fragment.getValue()},rebind:function(t,e){this.isNamed||Kf.call(this,t,e),this.fragment&&this.fragment.rebind(t,e)},render:function(){return this.docFrag=document.createDocumentFragment(),this.update(),this.rendered=!0,this.docFrag},resolve:Jf.resolve,setValue:function(t){var e;void 0!==t&&t===this.value||(void 0!==t&&(e=yv(this.root,""+t,this.parentFragment)),!e&&this.name&&(e=yv(this.root,this.name,this.parentFragment))&&(Mf.call(this),this.isNamed=!0),e||m('Could not find template for partial "%s"',this.name,{ractive:this.root}),this.value=t,this.setTemplate(e||[]),this.bubble(),this.rendered&&du.addView(this))},setTemplate:function(t){this.fragment&&(this.fragment.unbind(),this.rendered&&(this.fragmentToUnrender=this.fragment)),this.fragment=new d_({template:t,root:this.root,owner:this,pElement:this.parentFragment.pElement}),this.fragmentToRender=this.fragment},toString:function(t){var e,n,i,r;return e=this.fragment.toString(t),(n=this.parentFragment.items[this.index-1])&&1===n.type?(i=n.text.split("\n").pop(),(r=/^\s+$/.exec(i))?_v(e,r[0]):e):e},unbind:function(){this.isNamed||Mf.call(this),this.fragment&&this.fragment.unbind()},unrender:function(t){this.rendered&&(this.fragment&&this.fragment.unrender(t),this.rendered=!1)},update:function(){var t,e;this.fragmentToUnrender&&(this.fragmentToUnrender.unrender(!0),this.fragmentToUnrender=null),this.fragmentToRender&&(this.docFrag.appendChild(this.fragmentToRender.render()),this.fragmentToRender=null),this.rendered&&(t=this.parentFragment.getNode(),e=this.parentFragment.findNextNode(this),t.insertBefore(this.docFrag,e))}};var bv,wv,Sv,Tv=xv,kv=ua,Av=ca,Cv=new Js("detach"),Pv=la,Ev=ha,Mv=da,Dv=fa,Lv=pa,Ov=ga,Rv=function(t,e,n,i){var r=t.root,a=t.keypath;i?r.viewmodel.smartUpdate(a,e,i):r.viewmodel.mark(a)},Iv=[],Vv=["pop","push","reverse","shift","sort","splice","unshift"];Vv.forEach(function(t){xs(Iv,t,{value:function(){for(var e=arguments.length,n=Array(e),i=0;i component has a default `el` property; it has been disregarded",t.name),l=u;l;){if(l.owner.type===el){h=l.owner.container;break}l=l.parent}return n&&Object.keys(n).forEach(function(e){var i,r,o=n[e];if("string"==typeof o)i=_d(o),p[e]=i?i.value:o;else if(0===o)p[e]=!0;else{if(!a(o))throw new Error("erm wut");fo(o)?(m[e]={origin:t.root.viewmodel,keypath:void 0},r=ho(t,o[0],function(t){t.isSpecial?d?s.set(e,t.value):(p[e]=t.value,delete m[e]):d?s.viewmodel.mappings[e].resolve(t):m[e].keypath=t})):r=new Fy(t,o,function(t){d?s.set(e,t):p[e]=t}),v.push(r)}}),s=_s(e.prototype),Ny(s,{el:null,append:!0,data:p,partials:o,magic:c.magic||e.defaults.magic,modifyArrays:c.modifyArrays,adapt:c.adapt},{parent:c,component:t,container:h,mappings:m,inlinePartials:f,cssIds:u.cssIds}),d=!0,t.resolvers=v,s},Gy=po,Yy=function(t){var e,n;for(e=t.root;e;)(n=e._liveComponentQueries["_"+t.name])&&n.push(t.instance),e=e.parent},Hy=mo,zy=vo,By=yo,Uy=_o,Wy=xo,qy=new Js("teardown"),Xy=wo,$y=function(t,e){this.init(t,e)};$y.prototype={detach:Av,find:Pv,findAll:Ev,findAllComponents:Mv,findComponent:Dv,findNextNode:Lv,firstNode:Ov,init:Hy,rebind:zy,render:By,toString:Uy,unbind:Wy,unrender:Xy};var Qy=$y,Zy=function(t){this.type=Qc,this.value=t.template.c};Zy.prototype={detach:Cf,firstNode:function(){return this.node},render:function(){return this.node||(this.node=document.createComment(this.value)),this.node},toString:function(){return"\x3c!--"+this.value+"--\x3e"},unrender:function(t){t&&this.node.parentNode.removeChild(this.node)}};var Ky=Zy,Jy=function(t){var e,n;this.type=el,this.container=e=t.parentFragment.root,this.component=n=e.component,this.container=e,this.containerFragment=t.parentFragment,this.parentFragment=n.parentFragment;var i=this.name=t.template.n||"",r=e._inlinePartials[i];r||(g('Could not find template for partial "'+i+'"',{ractive:t.root}),r=[]),this.fragment=new d_({owner:this,root:e.parent,template:r,pElement:this.containerFragment.pElement}),a(n.yielders[i])?n.yielders[i].push(this):n.yielders[i]=[this],du.scheduleTask(function(){if(n.yielders[i].length>1)throw new Error("A component template can only have one {{yield"+(i?" "+i:"")+"}} declaration at a time")})};Jy.prototype={detach:function(){return this.fragment.detach()},find:function(t){return this.fragment.find(t)},findAll:function(t,e){return this.fragment.findAll(t,e)},findComponent:function(t){return this.fragment.findComponent(t)},findAllComponents:function(t,e){return this.fragment.findAllComponents(t,e)},findNextNode:function(){return this.containerFragment.findNextNode(this)},firstNode:function(){return this.fragment.firstNode()},getValue:function(t){return this.fragment.getValue(t)},render:function(){return this.fragment.render()},unbind:function(){this.fragment.unbind()},unrender:function(t){this.fragment.unrender(t),V(this.component.yielders[this.name],this)},rebind:function(t,e){this.fragment.rebind(t,e)},toString:function(){return this.fragment.toString()}};var t_=Jy,e_=function(t){this.declaration=t.template.a};e_.prototype={init:Ps,render:Ps,unrender:Ps,teardown:Ps,toString:function(){return""}};var n_=e_,i_=So,r_=ko,a_=Ao,o_=Co,s_=Mo,u_=Lo,c_=function(t){this.init(t)};c_.prototype={bubble:gf,detach:mf,find:vf,findAll:yf,findAllComponents:_f,findComponent:xf,findNextNode:bf,firstNode:wf,getArgsList:Tf,getNode:kf,getValue:Af,init:i_,rebind:r_,registerIndexRef:function(t){var e=this.registeredIndexRefs;-1===e.indexOf(t)&&e.push(t)},render:a_,toString:o_,unbind:s_,unregisterIndexRef:function(t){var e=this.registeredIndexRefs;e.splice(e.indexOf(t),1)},unrender:u_};var l_,h_,d_=c_,f_=Oo,p_=["template","partials","components","decorators","events"],g_=new Js("reset"),m_=function(t,e){function n(e,i,r){r&&r.partials[t]||e.forEach(function(e){e.type===$c&&e.getPartialName()===t&&i.push(e),e.fragment&&n(e.fragment.items,i,r),a(e.fragments)?n(e.fragments,i,r):a(e.items)?n(e.items,i,r):e.type===tl&&e.instance&&n(e.instance.fragment.items,i,e.instance),e.type===Xc&&(a(e.attributes)&&n(e.attributes,i,r),a(e.conditionalAttributes)&&n(e.conditionalAttributes,i,r))})}var i,r=[];return n(this.fragment.items,r),this.partials[t]=e,i=du.start(this,!0),r.forEach(function(e){e.value=void 0,e.setValue(t)}),du.end(),i},v_=Ro,y_=pc("reverse"),__=Io,x_=pc("shift"),b_=pc("sort"),w_=pc("splice"),S_=No,T_=Fo,k_=new Js("teardown"),A_=Go,C_=Yo,P_=Ho,E_=new Js("unrender"),M_=pc("unshift"),D_=zo,L_=new Js("update"),O_=Bo,R_={add:qs,animate:yu,detach:xu,find:wu,findAll:Du,findAllComponents:Lu,findComponent:Ou,findContainer:Ru,findParent:Iu,fire:ju,get:Gu,insert:Hu,merge:Bu,observe:ac,observeOnce:oc,off:cc,on:lc,once:hc,pop:gc,push:mc,render:wc,reset:f_,resetPartial:m_,resetTemplate:v_,reverse:y_,set:__,shift:x_,sort:b_,splice:w_,subtract:S_,teardown:T_,toggle:A_,toHTML:C_,toHtml:C_,unrender:P_,unshift:M_,update:D_,updateModel:O_},I_=function(t,e,n){return n||Wo(t,e)?function(){var n,i="_super"in this,r=this._super;return this._super=e,n=t.apply(this,arguments),i&&(this._super=r),n}:t},V_=qo,N_=Zo,F_=function(t){var e,n,i={};return t&&(e=t._ractive)?(i.ractive=e.root,i.keypath=e.keypath.str,i.index={},(n=jf(e.proxy.parentFragment))&&(i.index=jf.resolve(n)),i):i};l_=function(t){if(!(this instanceof l_))return new l_(t);Ny(this,t)},h_={DEBUG:{writable:!0,value:!0},DEBUG_PROMISES:{writable:!0,value:!0},extend:{value:N_},getNodeInfo:{value:F_},parse:{value:zd},Promise:{value:iu},svg:{value:rs},magic:{value:ns},VERSION:{value:"0.7.3"},adaptors:{writable:!0,value:{}},components:{writable:!0,value:{}},decorators:{writable:!0,value:{}},easing:{writable:!0,value:cs},events:{writable:!0,value:{}},interpolators:{writable:!0,value:Vs},partials:{writable:!0,value:{}},transitions:{writable:!0,value:{}}},bs(l_,h_),l_.prototype=i(R_,us),l_.prototype.constructor=l_,l_.defaults=l_.prototype;if("function"!=typeof Date.now||"function"!=typeof String.prototype.trim||"function"!=typeof Object.keys||"function"!=typeof Array.prototype.indexOf||"function"!=typeof Array.prototype.forEach||"function"!=typeof Array.prototype.map||"function"!=typeof Array.prototype.filter||"undefined"!=typeof window&&"function"!=typeof window.addEventListener)throw new Error("It looks like you're attempting to use Ractive.js in an older browser. You'll need to use one of the 'legacy builds' in order to continue - see http://docs.ractivejs.org/latest/legacy-builds for more information.");var j_=l_;return j_})},{}],20:[function(t,e,n){function i(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var i=window.getSelection(),r=document.createRange();r.selectNodeContents(t),i.removeAllRanges(),i.addRange(r),e=i.toString()}return e}e.exports=i},{}],21:[function(t,e,n){function i(){}i.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function i(){r.off(t,i),e.apply(n,arguments)}var r=this;return i._=e,this.on(t,i,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,r=n.length;for(i;i=0&&a0?0:s-1;return arguments.length<3&&(r=n[o?o[u]:u],u+=t),e(n,i,r,o,u,s)}}function i(t){return function(e,n,i){n=w(n,i);for(var r=C(e),a=t>0?0:r-1;a>=0&&a0?o=a>=0?a:Math.max(a+s,o):s=a>=0?Math.min(a+1,s):a+s+1;else if(n&&a&&s)return a=n(i,r),i[a]===r?a:-1;if(r!==r)return a=e(d.call(i,o,s),x.isNaN),a>=0?a+o:-1;for(a=t>0?o:s-1;a>=0&&a=0&&e<=A};x.each=x.forEach=function(t,e,n){e=b(e,n);var i,r;if(P(t))for(i=0,r=t.length;i=0},x.invoke=function(t,e){var n=d.call(arguments,2),i=x.isFunction(e);return x.map(t,function(t){var r=i?e:t[e];return null==r?r:r.apply(t,n)})},x.pluck=function(t,e){return x.map(t,x.property(e))},x.where=function(t,e){return x.filter(t,x.matcher(e))},x.findWhere=function(t,e){return x.find(t,x.matcher(e))},x.max=function(t,e,n){var i,r,a=-1/0,o=-1/0;if(null==e&&null!=t){t=P(t)?t:x.values(t);for(var s=0,u=t.length;sa&&(a=i)}else e=w(e,n),x.each(t,function(t,n,i){((r=e(t,n,i))>o||r===-1/0&&a===-1/0)&&(a=t,o=r)});return a},x.min=function(t,e,n){var i,r,a=1/0,o=1/0;if(null==e&&null!=t){t=P(t)?t:x.values(t);for(var s=0,u=t.length;si||void 0===n)return 1;if(ne?(o&&(clearTimeout(o),o=null),s=c,a=t.apply(i,r),o||(i=r=null)):o||!1===n.trailing||(o=setTimeout(u,l)),a}},x.debounce=function(t,e,n){var i,r,a,o,s,u=function(){var c=x.now()-o;c=0?i=setTimeout(u,e-c):(i=null,n||(s=t.apply(a,r),i||(a=r=null)))};return function(){a=this,r=arguments,o=x.now();var c=n&&!i;return i||(i=setTimeout(u,e)),c&&(s=t.apply(a,r),a=r=null),s}},x.wrap=function(t,e){return x.partial(e,t)},x.negate=function(t){return function(){return!t.apply(this,arguments)}},x.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,i=t[e].apply(this,arguments);n--;)i=t[n].call(this,i);return i}},x.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},x.before=function(t,e){var n;return function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},x.once=x.partial(x.before,2);var L=!{toString:null}.propertyIsEnumerable("toString"),O=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];x.keys=function(t){if(!x.isObject(t))return[];if(m)return m(t);var e=[];for(var n in t)x.has(t,n)&&e.push(n);return L&&a(t,e),e},x.allKeys=function(t){if(!x.isObject(t))return[];var e=[];for(var n in t)e.push(n);return L&&a(t,e),e},x.values=function(t){for(var e=x.keys(t),n=e.length,i=Array(n),r=0;r":">",'"':""","'":"'","`":"`"},V=x.invert(I),N=function(t){var e=function(e){return t[e]},n="(?:"+x.keys(t).join("|")+")",i=RegExp(n),r=RegExp(n,"g");return function(t){return t=null==t?"":""+t,i.test(t)?t.replace(r,e):t}};x.escape=N(I),x.unescape=N(V),x.result=function(t,e,n){var i=null==t?void 0:t[e];return void 0===i&&(i=n),x.isFunction(i)?i.call(t):i};var F=0;x.uniqueId=function(t){var e=++F+"";return t?t+e:e},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var j=/(.)^/,G={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Y=/\\|'|\r|\n|\u2028|\u2029/g,H=function(t){return"\\"+G[t]};x.template=function(t,e,n){!e&&n&&(e=n),e=x.defaults({},e,x.templateSettings);var i=RegExp([(e.escape||j).source,(e.interpolate||j).source,(e.evaluate||j).source].join("|")+"|$","g"),r=0,a="__p+='";t.replace(i,function(e,n,i,o,s){return a+=t.slice(r,s).replace(Y,H),r=s+e.length,n?a+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":i?a+="'+\n((__t=("+i+"))==null?'':__t)+\n'":o&&(a+="';\n"+o+"\n__p+='"),e}),a+="';\n",e.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{var o=new Function(e.variable||"obj","_",a)}catch(t){throw t.source=a,t}var s=function(t){return o.call(this,t,x)};return s.source="function("+(e.variable||"obj")+"){\n"+a+"}",s},x.chain=function(t){var e=x(t);return e._chain=!0,e};var z=function(t,e){return t._chain?x(e).chain():e};x.mixin=function(t){x.each(x.functions(t),function(e){var n=x[e]=t[e];x.prototype[e]=function(){var t=[this._wrapped];return h.apply(t,arguments),z(this,n.apply(x,t))}})},x.mixin(x),x.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=u[t];x.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],z(this,n)}}),x.each(["concat","join","slice"],function(t){var e=u[t];x.prototype[t]=function(){return z(this,e.apply(this._wrapped,arguments))}}),x.prototype.value=function(){return this._wrapped},x.prototype.valueOf=x.prototype.toJSON=x.prototype.value,x.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return x})}).call(this)},{}],23:[function(t,e,n){!function(t,e,n){var i={messages:{required:"The %s field is required.",matches:"The %s field does not match the %s field.",default:"The %s field is still set to default, please change.",valid_email:"The %s field must contain a valid email address.",valid_emails:"The %s field must contain all valid email addresses.",min_length:"The %s field must be at least %s characters in length.",max_length:"The %s field must not exceed %s characters in length.",exact_length:"The %s field must be exactly %s characters in length.",greater_than:"The %s field must contain a number greater than %s.",less_than:"The %s field must contain a number less than %s.",alpha:"The %s field must only contain alphabetical characters.",alpha_numeric:"The %s field must only contain alpha-numeric characters.",alpha_dash:"The %s field must only contain alpha-numeric characters, underscores, and dashes.",numeric:"The %s field must contain only numbers.",integer:"The %s field must contain an integer.",decimal:"The %s field must contain a decimal number.",is_natural:"The %s field must contain only positive numbers.",is_natural_no_zero:"The %s field must contain a number greater than zero.",valid_ip:"The %s field must contain a valid IP.",valid_base64:"The %s field must contain a base64 string.",valid_credit_card:"The %s field must contain a valid credit card number.",is_file_type:"The %s field must contain only %s files.",valid_url:"The %s field must contain a valid URL.",greater_than_date:"The %s field must contain a more recent date than %s.",less_than_date:"The %s field must contain an older date than %s.",greater_than_or_equal_date:"The %s field must contain a date that's at least as recent as %s.",less_than_or_equal_date:"The %s field must contain a date that's %s or older."},callback:function(t){}},r=/^(.+?)\[(.+)\]$/,a=/^[0-9]+$/,o=/^\-?[0-9]+$/,s=/^\-?[0-9]*\.?[0-9]+$/,u=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,c=/^[a-z]+$/i,l=/^[a-z0-9]+$/i,h=/^[a-z0-9_\-]+$/i,d=/^[0-9]+$/i,f=/^[1-9][0-9]*$/i,p=/^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/i,g=/[^a-zA-Z0-9\/\+=]/i,m=/^[\d\-\s]+$/,v=/^((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,y=/\d{4}-\d{1,2}-\d{1,2}/,_=function(t,e,n){this.callback=n||i.callback,this.errors=[],this.fields={},this.form=this._formByNameOrNode(t)||{},this.messages={},this.handlers={},this.conditionals={};for(var r=0,a=e.length;r0)||"radio"!==t[0].type&&"checkbox"!==t[0].type)return t[e];for(n=0,elementLength=t.length;n0?i[0].type:i.type,n.value=x(i,"value"),n.checked=x(i,"checked"),n.depends&&"function"==typeof n.depends?n.depends.call(this,n)&&this._validateField(n):n.depends&&"string"==typeof n.depends&&this.conditionals[n.depends]?this.conditionals[n.depends].call(this,n)&&this._validateField(n):this._validateField(n))}return"function"==typeof this.callback&&this.callback(this.errors,t),this.errors.length>0&&(t&&t.preventDefault?t.preventDefault():event&&(event.returnValue=!1)),!0},_.prototype._validateField=function(t){var e,n,a=t.rules.split("|"),o=t.rules.indexOf("required"),s=!t.value||""===t.value||void 0===t.value;for(e=0,ruleLength=a.length;e=parseInt(e,10)},max_length:function(t,e){return!!a.test(e)&&t.value.length<=parseInt(e,10)},exact_length:function(t,e){return!!a.test(e)&&t.value.length===parseInt(e,10)},greater_than:function(t,e){return!!s.test(t.value)&&parseFloat(t.value)>parseFloat(e)},less_than:function(t,e){return!!s.test(t.value)&&parseFloat(t.value)=0;a--){var o=r.charAt(a);n=parseInt(o,10),i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0},is_file_type:function(t,e){if("file"!==t.type)return!0;var n=t.value.substr(t.value.lastIndexOf(".")+1),i=e.split(","),r=!1,a=0,o=i.length;for(a;ai},less_than_date:function(t,e){var n=this._getValidDate(t.value),i=this._getValidDate(e);return!(!i||!n)&&n=i},less_than_or_equal_date:function(t,e){var n=this._getValidDate(t.value),i=this._getValidDate(e);return!(!i||!n)&&n<=i}},t.FormValidator=_}(window,document),void 0!==e&&e.exports&&(e.exports=FormValidator)},{}],24:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.DiscountPolicyTemplate='\n
"},templateSelection:function(t){return t.title}})}},showNewPolicyForm:function(t){S.set({showAddPolicyForm:v.showForm,"newDiscountPolicy.is_price_based":v.priceBasedDiscount,"newDiscountPolicy.discount_type":v.couponBasedDiscount}),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyChange:function(t){S.set("newDiscountPolicy.is_price_based",parseInt(t.node.value,10)),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyTypeChange:function(t){S.set("newDiscountPolicy.discount_type",t.node.value)},addNewPolicy:function(t){var n=new FormValidator("adding-new-policy-form",S.get("formValidationConfig"),function(t,n){if(n.preventDefault(),S.set("newDiscountPolicy.errormsg",v.empty),t.length>0)S.set("newDiscountPolicy.errormsg."+t[0].name,t[0].message);else{S.set({"newDiscountPolicy.errorMsg":v.empty,"newDiscountPolicy.creatingPolicy":v.showLoader});o({url:h("new",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0}),data:u("#new-policy-form")}).done(function(t){S.set({discountPolicies:[t.result.discount_policy],searchText:S.get("newDiscountPolicy.title"),"newDiscountPolicy.creatingPolicy":v.hideLoader,newDiscountPolicy:v.empty}),S.hideNewPolicyForm()}).fail(function(t){var e=v.empty;if(4===t.readyState)if(500===t.status)e="Internal Server Error";else{var n=t.responseJSON.errors;for(var i in n)e+="
"+n[i]+"
"}else e="Unable to connect. Please try again.";S.set({"newDiscountPolicy.creatingPolicy":v.hideLoader,"newDiscountPolicy.errorMsg":e})})}});n.setMessage("required","Please fill out the this field"),n.setMessage("numeric","Please enter a numberic value")},hideNewPolicyForm:function(t){S.set("showAddPolicyForm",v.hideForm)},showEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.showForm),S.set(e+".errormsg",v.empty),S.addFormFields(S.get(e+".is_price_based"),e)},editPolicy:function(t){var e=t.keypath,n=t.context.id,i="edit-policy-form-"+n,r=new FormValidator(i,S.get("formValidationConfig"),function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{S.set(e+".editingPolicy",v.showLoader);var r="#policy-form-"+n;o({url:h("edit",{resource:"discount_policy",id:n,root:!0}),data:u(r)}).done(function(t){S.set(e+".editingPolicy",v.hideLoader),S.set(e,t.result.discount_policy),S.set(e+".showPolicyForm",v.hideForm),s("#dp-"+n)}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="
"+i[r]+"
"}else n="Unable to connect. Please try again.";S.set(e+".editingPolicy",v.hideLoader),S.set(e+".errorMsg",n)})}});r.setMessage("required","Please fill out the this field"),r.setMessage("numeric","Please enter a numberic value")},hideEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.hideForm)},showCouponForm:function(t){var e=t.keypath;S.set(e+".count",v.usageCount),S.set(e+".showCouponForm",v.showForm)},generateCoupon:function(t){var e=t.keypath,n=t.context.id,i=[{name:"count",rules:"required|numeric"},{name:"usage_limit",rules:"required|numeric"}],r="generate-coupon-form-"+n;new FormValidator(r,i,function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{var r="#new-coupon-"+n;S.set(e+".generatingCoupon",v.showLoader),S.set(e+".generateCouponErrorMsg",v.empty),o({url:h("new",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),data:u(r)}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".generatingCoupon",v.hideLoader),S.set("eventUrl",v.empty),$("#generated-coupons-"+n).modal("show"),new Clipboard(".copy-coupons")}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="
"+i[r]+"
"}else n="Unable to connect. Please try again.";S.set(e+".generatingCoupon",v.hideLoader),S.set(e+".generateCouponErrorMsg",n)})}}).setMessage("required","Please fill out the this field")},hideCouponForm:function(t){var e=t.keypath;S.set(e+".showCouponForm",v.hideForm)},getCouponList:function(t){t.original.preventDefault();var e=t.keypath,n=t.context.id;S.set(e+".loadingCoupons",v.showLoader),S.set(e+".loadingCouponErrorMsg",v.empty),a({url:h("index",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),contentType:"application/json"}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".loadingCoupons",v.hideLoader),$("#list-coupons-"+n).modal("show"),$("#coupons-list-"+n).footable(),new Clipboard(".copy-coupons-list")}).fail(function(t){var n=v.empty;n=4===t.readyState?"Internal Server Error":"Unable to connect. Please try again.",S.set(e+".loadingCoupons",v.hideLoader),S.set(e+".loadingCouponErrorMsg",n)})},oncomplete:function(){var t,e="";S.observe("searchText",function(n,i){n!==e&&(n.length>2?(window.clearTimeout(t),e=n,t=window.setTimeout(function(){S.refresh(n)},1e3)):0===n.length&&S.refresh())}),S.set("pages",_.range(1,S.get("totalPages")+1))}});p.render("discount-policies",{org_name:e,org_title:i}),d("Discount policies",i),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.DiscountPolicyView=g},{"../models/util.js":4,"../templates/admin_discount_policy.html.js":24,"./sidebar.js":40}],33:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.post,s=i.scrollToElement,u=i.urlFor,c=i.setPageTitle,l=t("../templates/admin_order.html.js").OrderTemplate,h=t("./sidebar.js").SideBarView,d={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:u("index",{scope_ns:"ic",scope_id:e,resource:"orders",root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,d=t.ic_title,f=t.orders,p=new Ractive({el:"#main-content-area",template:l,data:{icTitle:d,orders:f,formatDateTime:function(t){return r.formatDateTime(t)},formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}}});h.render("orders",{org_name:n,org_title:i,ic_id:e,ic_title:d}),c("Orders",d),NProgress.done(),$("#orders-table").footable({breakpoints:{phone:600,tablet:768,desktop:1200,largescreen:1900}}),$("#orders-table").on("footable_filtering",function(t){var e=$("#filter-status").find(":selected").val();e&&e.length>0&&(t.filter+=t.filter&&t.filter.length>0?" "+e:e,t.clear=!t.filter)}),$("#filter-status").change(function(t){t.preventDefault(),$("#orders-table").trigger("footable_filter",{filter:$("#filter").val()})}),$("#search-form").on("keypress",function(t){if(13==t.which)return!1}),$("#orders-table").on("keydown",function(t){if(27==t.which)return p.set("orders.*.show_order",!1),!1}),p.on("showOrder",function(t){p.set("orders.*.show_order",!1),p.set(t.keypath+".loading",!0),NProgress.configure({showSpinner:!1}).start();var e=t.context.id;a({url:u("view",{resource:"order",id:e,root:!0})}).done(function(e){p.set(t.keypath+".line_items",e.line_items),p.set(t.keypath+".show_order",!0),NProgress.done(),p.set(t.keypath+".loading",!1);var n="#"+p.el.id;s(n)})}),p.on("hideOrder",function(t){p.set(t.keypath+".show_order",!1)}),p.on("cancelTicket",function(t,e){window.confirm("Are you sure you want to cancel this ticket?")&&(p.set(t.keypath+".cancel_error",""),p.set(t.keypath+".cancelling",!0),o({url:t.context.cancel_ticket_url}).done(function(e){p.set(t.keypath+".cancelled_at",e.result.cancelled_at),p.set(t.keypath+".cancelling",!1)}).fail(function(e){var n=void 0;n=4===e.readyState?500===e.status?"Server Error":JSON.parse(e.responseText).error_description:"Unable to connect. Please try again later.",p.set(t.keypath+".cancel_error",n),p.set(t.keypath+".cancelling",!1)}))}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrderView=d},{"../models/util.js":4,"../templates/admin_order.html.js":25,"./sidebar.js":40}],34:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/admin_org_report.html.js").OrgReportTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;r({url:a("index",{resource:"reports",scope_ns:"o",scope_id:e,root:!0})}).done(function(t){var n=t.org_title;new Ractive({el:"#main-content-area",template:s,data:{orgTitle:n,reportType:"invoices",reportsUrl:function(){var t=this.get("reportType");return a("index",{resource:t,scope_ns:"o",scope_id:e,ext:"csv",root:!0})},reportsFilename:function(){return e+"_"+this.get("reportType")+".csv"}}});u.render("org_reports",{org_name:e,org_title:n}),o("Organization reports",n),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrgReportView=c},{"../models/util.js":4,"../templates/admin_org_report.html.js":26,"./sidebar.js":40}],35:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/admin_report.html.js").ReportTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;r({url:a("index",{resource:"reports",scope_ns:"ic",scope_id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,r=t.ic_name,c=t.ic_title;new Ractive({el:"#main-content-area",template:s,data:{icName:r,icTitle:c,reportType:"tickets",reportsUrl:function(){var t=this.get("reportType");return a("index",{resource:t,scope_ns:"ic",scope_id:e,ext:"csv",root:!0})},reportsFilename:function(){return this.get("icName")+"_"+this.get("reportType")+".csv"}}});u.render("reports",{org_name:n,org_title:i,ic_id:e,ic_title:c}),o("Reports",c),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ReportView=c},{"../models/util.js":4,"../templates/admin_report.html.js":27,"./sidebar.js":40}],36:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=(t("../models/index.js").IndexModel,t("../templates/index.html.js").IndexTemplate),u=t("./sidebar.js").SideBarView,c={render:function(){r({url:a("index",{root:!0})}).then(function(t){var e=t.orgs,n=new Ractive({el:"#main-content-area",template:s,data:{orgs:e}});u.hide(),o("Admin"),NProgress.done(),n.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.IndexView=c},{"../models/index.js":2,"../models/util.js":4,"../templates/index.html.js":28,"./sidebar.js":40}],37:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.urlFor,s=i.setPageTitle,u=t("../templates/item_collection.html.js"),c=u.TableTemplate,l=u.AggChartTemplate,h=u.ItemCollectionTemplate,d=t("./sidebar.js").SideBarView,f=Ractive.extend({isolated:!1,template:c,onItemsSelected:function(t,e){var n=this.parent.get("totalSelected");t.node.checked?this.parent.set("totalSelected",n+t.context[e]):this.parent.set("totalSelected",n-t.context[e])}}),p=Ractive.extend({template:l,format_columns:function(){var t=this.parent.get("date_item_counts"),e=this.parent.get("categories").reduce(function(t,e){return t.concat(e.items)},[]),n=this.parent.get("date_sales"),i=["x"],r={},a=["sales"]
-;for(var o in t)!function(o){i.push(o),a.push(n[o]),e.forEach(function(e){r[e.id]||(r[e.id]=[]),t[o].hasOwnProperty(e.id)?r[e.id].push(t[o][e.id]):r[e.id].push(0)})}(o);var s=[i];return e.forEach(function(t){s.push([t.title].concat(r[t.id]))}),s.push(a),s},oncomplete:function(){var t=this,e=this.format_columns(),n=_.without(_.map(e,_.first),"x","sales");this.chart=c3.generate({data:{x:"x",columns:this.format_columns(),type:"bar",types:{sales:"line"},groups:[n],axes:{sales:"y2"}},bar:{width:{ratio:.5}},axis:{x:{type:"timeseries",tick:{format:"%d-%m"},label:"Date"},y:{label:"No. of tickets"},y2:{show:!0,label:"Sales"}}}),this.parent.on("data_update",function(){t.chart.load({columns:t.format_columns()})})}}),g={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:o("view",{resource:"ic",id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,a=t.ic_title,o=t.categories,u=t.date_item_counts,c=t.date_sales,l=t.today_sales,g=t.net_sales,m=t.sales_delta;new Ractive({el:"#main-content-area",template:h,data:{icTitle:a,categories:o,date_item_counts:u,date_sales:c,net_sales:g,sales_delta:m,today_sales:l,totalSelected:0,formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}},components:{TableComponent:f,AggChartComponent:p}});d.render("dashboard",{org_name:n,org_title:i,ic_id:e,ic_title:a}),s(a),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ItemCollectionView=g},{"../models/util.js":4,"../templates/item_collection.html.js":29,"./sidebar.js":40}],38:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/org.html.js").orgTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;r({url:a("view",{resource:"o",id:e,root:!0})}).then(function(t){var n=(t.id,t.org_title),i=t.item_collections,r=new Ractive({el:"#main-content-area",template:s,data:{orgName:e,orgTitle:n,item_collections:i}});u.render("org",{org_name:e,org_title:n}),o(n),NProgress.done(),r.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.OrgView=c},{"../models/util.js":4,"../templates/org.html.js":30,"./sidebar.js":40}],39:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./index.js").IndexView,r=t("./org.js").OrgView,a=t("./admin_org_report.js").OrgReportView,o=t("./admin_discount_policy.js").DiscountPolicyView,s=t("./item_collection.js").ItemCollectionView,u=t("./admin_order.js").OrderView,c=t("./admin_report.js").ReportView,l=Backbone.Router.extend({url_root:"/admin/",routes:{"":"index","o/:org_name":"org","o/:org_name/reports":"org_report","o/:org_name/discount_policy":"discount_policy","o/:org_name/discount_policy?:params":"discount_policy","ic/:ic_id":"item_collection","ic/:ic_id/orders":"order","ic/:ic_id/reports":"report"},index:function(){i.render()},org:function(t){r.render({org_name:t})},org_report:function(t){a.render({org_name:t})},discount_policy:function(t){var e=void 0===arguments[1]?{}:arguments[1],n=e.search,i=e.page,r=e.size;o.render({org_name:t,search:n,page:i,size:r})},item_collection:function(t){s.render({ic_id:t})},order:function(t){u.render({ic_id:t})},report:function(t){c.render({ic_id:t})},_extractParameters:function(t,e){var n=t.exec(e).slice(1);if(n[n.length-1]){var i=n[n.length-1].split("&"),r={};i.forEach(function(t){if(t){var e=t.split("=");r[e[0]]=e[1]}}),n[n.length-1]=r}return n}});n.Router=l},{"./admin_discount_policy.js":32,"./admin_order.js":33,"./admin_org_report.js":34,"./admin_report.js":35,"./index.js":36,"./item_collection.js":37,"./org.js":38}],40:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/sidebar.js").SideBarModel,r=t("../templates/sidebar.html.js").SideBarTemplate,a={init:function(t,e){this.on=!0,this.ractive=new Ractive({el:"#sidebar",template:r,data:{sidebarMobileOn:!1,sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1},toggle:function(t){t.original.preventDefault(),this.set("sidebarMobileOn",!this.get("sidebarMobileOn"))},navigate:function(t){t.context.view!==this.get("activeItem")&&(NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url))}})},render:function(t,e){this.on?this.ractive.set({sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1,sidebarMobileOn:!1}):this.init(t,e)},hide:function(){this.on&&this.ractive.set("sidebarHide",!0)}};n.SideBarView=a},{"../models/sidebar.js":3,"../templates/sidebar.html.js":31}]},{},[1]);
\ No newline at end of file
+;n.OrderTemplate='\n
"},templateSelection:function(t){return t.title}})}},showNewPolicyForm:function(t){S.set({showAddPolicyForm:v.showForm,"newDiscountPolicy.is_price_based":v.priceBasedDiscount,"newDiscountPolicy.discount_type":v.couponBasedDiscount}),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyChange:function(t){S.set("newDiscountPolicy.is_price_based",parseInt(t.node.value,10)),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyTypeChange:function(t){S.set("newDiscountPolicy.discount_type",t.node.value)},addNewPolicy:function(t){var n=new FormValidator("adding-new-policy-form",S.get("formValidationConfig"),function(t,n){if(n.preventDefault(),S.set("newDiscountPolicy.errormsg",v.empty),t.length>0)S.set("newDiscountPolicy.errormsg."+t[0].name,t[0].message);else{S.set({"newDiscountPolicy.errorMsg":v.empty,"newDiscountPolicy.creatingPolicy":v.showLoader});o({url:h("new",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0}),data:u("#new-policy-form")}).done(function(t){S.set({discountPolicies:[t.result.discount_policy],searchText:S.get("newDiscountPolicy.title"),"newDiscountPolicy.creatingPolicy":v.hideLoader,newDiscountPolicy:v.empty}),S.hideNewPolicyForm()}).fail(function(t){var e=v.empty;if(4===t.readyState)if(500===t.status)e="Internal Server Error";else{var n=t.responseJSON.errors;for(var i in n)e+="
"+n[i]+"
"}else e="Unable to connect. Please try again.";S.set({"newDiscountPolicy.creatingPolicy":v.hideLoader,"newDiscountPolicy.errorMsg":e})})}});n.setMessage("required","Please fill out the this field"),n.setMessage("numeric","Please enter a numberic value")},hideNewPolicyForm:function(t){S.set("showAddPolicyForm",v.hideForm)},showEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.showForm),S.set(e+".errormsg",v.empty),S.addFormFields(S.get(e+".is_price_based"),e)},editPolicy:function(t){var e=t.keypath,n=t.context.id,i="edit-policy-form-"+n,r=new FormValidator(i,S.get("formValidationConfig"),function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{S.set(e+".editingPolicy",v.showLoader);var r="#policy-form-"+n;o({url:h("edit",{resource:"discount_policy",id:n,root:!0}),data:u(r)}).done(function(t){S.set(e+".editingPolicy",v.hideLoader),S.set(e,t.result.discount_policy),S.set(e+".showPolicyForm",v.hideForm),s("#dp-"+n)}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="
"+i[r]+"
"}else n="Unable to connect. Please try again.";S.set(e+".editingPolicy",v.hideLoader),S.set(e+".errorMsg",n)})}});r.setMessage("required","Please fill out the this field"),r.setMessage("numeric","Please enter a numberic value")},hideEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.hideForm)},showCouponForm:function(t){var e=t.keypath;S.set(e+".count",v.usageCount),S.set(e+".showCouponForm",v.showForm)},generateCoupon:function(t){var e=t.keypath,n=t.context.id,i=[{name:"count",rules:"required|numeric"},{name:"usage_limit",rules:"required|numeric"}],r="generate-coupon-form-"+n;new FormValidator(r,i,function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{var r="#new-coupon-"+n;S.set(e+".generatingCoupon",v.showLoader),S.set(e+".generateCouponErrorMsg",v.empty),o({url:h("new",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),data:u(r)}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".generatingCoupon",v.hideLoader),S.set("eventUrl",v.empty),$("#generated-coupons-"+n).modal("show"),new Clipboard(".copy-coupons")}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="
"+i[r]+"
"}else n="Unable to connect. Please try again.";S.set(e+".generatingCoupon",v.hideLoader),S.set(e+".generateCouponErrorMsg",n)})}}).setMessage("required","Please fill out the this field")},hideCouponForm:function(t){var e=t.keypath;S.set(e+".showCouponForm",v.hideForm)},getCouponList:function(t){t.original.preventDefault();var e=t.keypath,n=t.context.id;S.set(e+".loadingCoupons",v.showLoader),S.set(e+".loadingCouponErrorMsg",v.empty),a({url:h("index",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),contentType:"application/json"}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".loadingCoupons",v.hideLoader),$("#list-coupons-"+n).modal("show"),$("#coupons-list-"+n).footable(),new Clipboard(".copy-coupons-list")}).fail(function(t){var n=v.empty;n=4===t.readyState?"Internal Server Error":"Unable to connect. Please try again.",S.set(e+".loadingCoupons",v.hideLoader),S.set(e+".loadingCouponErrorMsg",n)})},oncomplete:function(){var t,e="";S.observe("searchText",function(n,i){n!==e&&(n.length>2?(window.clearTimeout(t),e=n,t=window.setTimeout(function(){S.refresh(n)},1e3)):0===n.length&&S.refresh())}),S.set("pages",_.range(1,S.get("totalPages")+1))}});p.render("discount-policies",{org_name:e,org_title:i}),d("Discount policies",i),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.DiscountPolicyView=g},{"../models/util.js":4,"../templates/admin_discount_policy.html.js":24,"./sidebar.js":40}],33:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.post,s=i.scrollToElement,u=i.urlFor,c=i.setPageTitle,l=t("../templates/admin_order.html.js").OrderTemplate,h=t("./sidebar.js").SideBarView,d={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:u("index",{scope_ns:"ic",scope_id:e,resource:"orders",root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,d=t.ic_title,f=t.orders,p=new Ractive({el:"#main-content-area",template:l,data:{icTitle:d,orders:f,formatDateTime:function(t){return r.formatDateTime(t)},formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}}});h.render("orders",{org_name:n,org_title:i,ic_id:e,ic_title:d}),c("Orders",d),NProgress.done(),$("#orders-table").footable({breakpoints:{phone:600,tablet:768,desktop:1200,largescreen:1900}}),$("#orders-table").on("footable_filtering",function(t){var e=$("#filter-status").find(":selected").val();e&&e.length>0&&(t.filter+=t.filter&&t.filter.length>0?" "+e:e,t.clear=!t.filter)}),$("#filter-status").change(function(t){t.preventDefault(),$("#orders-table").trigger("footable_filter",{filter:$("#filter").val()})}),$("#search-form").on("keypress",function(t){if(13==t.which)return!1}),$("#orders-table").on("keydown",function(t){if(27==t.which)return p.set("orders.*.show_order",!1),!1}),p.on("showOrder",function(t){p.set("orders.*.show_order",!1),p.set(t.keypath+".loading",!0),NProgress.configure({showSpinner:!1}).start();var e=t.context.id;a({url:u("view",{resource:"order",id:e,root:!0})}).done(function(e){p.set(t.keypath+".line_items",e.line_items),p.set(t.keypath+".show_order",!0),NProgress.done(),p.set(t.keypath+".loading",!1);var n="#"+p.el.id;s(n)})}),p.on("hideOrder",function(t){p.set(t.keypath+".show_order",!1)}),p.on("cancelTicket",function(t,e){window.confirm("Are you sure you want to cancel this ticket?")&&(p.set(t.keypath+".cancel_error",""),p.set(t.keypath+".cancelling",!0),o({url:t.context.cancel_ticket_url}).done(function(e){p.set(t.keypath+".cancelled_at",e.result.cancelled_at),p.set(t.keypath+".cancelling",!1)}).fail(function(e){var n=void 0;n=4===e.readyState?500===e.status?"Server Error":JSON.parse(e.responseText).error_description:"Unable to connect. Please try again later.",p.set(t.keypath+".cancel_error",n),p.set(t.keypath+".cancelling",!1)}))}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrderView=d},{"../models/util.js":4,"../templates/admin_order.html.js":25,"./sidebar.js":40}],34:[function(t,e,n){"use strict";var i=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t)){for(var n,i=[],r=t[Symbol.iterator]();!(n=r.next()).done&&(i.push(n.value),!e||i.length!==e););return i}throw new TypeError("Invalid attempt to destructure non-iterable instance")};Object.defineProperty(n,"__esModule",{value:!0});var r=t("../models/util.js"),a=r.fetch,o=r.urlFor,s=r.setPageTitle,u=t("../templates/admin_org_report.html.js").OrgReportTemplate,c=t("./sidebar.js").SideBarView,l={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;a({url:o("index",{resource:"reports",scope_ns:"o",scope_id:e,root:!0})}).done(function(t){var n=t.org_title,r=t.siteadmin,a=new Date,l=a.getFullYear(),h=a.getMonth()+1;console.log(r);new Ractive({el:"#main-content-area",template:u,data:{orgTitle:n,reportType:"invoices",monthYear:l+"-"+h,siteadmin:r,reportsUrl:function(){var t=this.get("reportType"),n=o("index",{resource:t,scope_ns:"o",scope_id:e,ext:"csv",root:!0});if("settlements"===t){var r=void 0,a=void 0,s=this.get("monthYear").split("-"),u=i(s,2);return r=u[0],a=u[1],n+"?year="+r+"&month="+a}return n},reportsFilename:function(){return"settlements"===this.get("reportType")?e+"_"+this.get("reportType")+"_"+this.get("monthYear")+".csv":e+"_"+this.get("reportType")+".csv"}}});c.render("org_reports",{org_name:e,org_title:n}),s("Organization reports",n),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrgReportView=l},{"../models/util.js":4,"../templates/admin_org_report.html.js":26,"./sidebar.js":40}],35:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/admin_report.html.js").ReportTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;r({url:a("index",{resource:"reports",scope_ns:"ic",scope_id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,r=t.ic_name,c=t.ic_title;new Ractive({el:"#main-content-area",template:s,data:{icName:r,icTitle:c,reportType:"tickets",reportsUrl:function(){var t=this.get("reportType");return a("index",{resource:t,scope_ns:"ic",scope_id:e,ext:"csv",root:!0})},reportsFilename:function(){return this.get("icName")+"_"+this.get("reportType")+".csv"}}});u.render("reports",{org_name:n,org_title:i,ic_id:e,ic_title:c}),o("Reports",c),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ReportView=c},{"../models/util.js":4,"../templates/admin_report.html.js":27,"./sidebar.js":40}],36:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=(t("../models/index.js").IndexModel,t("../templates/index.html.js").IndexTemplate),u=t("./sidebar.js").SideBarView,c={render:function(){r({url:a("index",{root:!0})}).then(function(t){var e=t.orgs,n=new Ractive({el:"#main-content-area",template:s,data:{orgs:e}});u.hide(),o("Admin"),NProgress.done(),n.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}),
+window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.IndexView=c},{"../models/index.js":2,"../models/util.js":4,"../templates/index.html.js":28,"./sidebar.js":40}],37:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.urlFor,s=i.setPageTitle,u=t("../templates/item_collection.html.js"),c=u.TableTemplate,l=u.AggChartTemplate,h=u.ItemCollectionTemplate,d=t("./sidebar.js").SideBarView,f=Ractive.extend({isolated:!1,template:c,onItemsSelected:function(t,e){var n=this.parent.get("totalSelected");t.node.checked?this.parent.set("totalSelected",n+t.context[e]):this.parent.set("totalSelected",n-t.context[e])}}),p=Ractive.extend({template:l,format_columns:function(){var t=this.parent.get("date_item_counts"),e=this.parent.get("categories").reduce(function(t,e){return t.concat(e.items)},[]),n=this.parent.get("date_sales"),i=["x"],r={},a=["sales"];for(var o in t)!function(o){i.push(o),a.push(n[o]),e.forEach(function(e){r[e.id]||(r[e.id]=[]),t[o].hasOwnProperty(e.id)?r[e.id].push(t[o][e.id]):r[e.id].push(0)})}(o);var s=[i];return e.forEach(function(t){s.push([t.title].concat(r[t.id]))}),s.push(a),s},oncomplete:function(){var t=this,e=this.format_columns(),n=_.without(_.map(e,_.first),"x","sales");this.chart=c3.generate({data:{x:"x",columns:this.format_columns(),type:"bar",types:{sales:"line"},groups:[n],axes:{sales:"y2"}},bar:{width:{ratio:.5}},axis:{x:{type:"timeseries",tick:{format:"%d-%m"},label:"Date"},y:{label:"No. of tickets"},y2:{show:!0,label:"Sales"}}}),this.parent.on("data_update",function(){t.chart.load({columns:t.format_columns()})})}}),g={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:o("view",{resource:"ic",id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,a=t.ic_title,o=t.categories,u=t.date_item_counts,c=t.date_sales,l=t.today_sales,g=t.net_sales,m=t.sales_delta;new Ractive({el:"#main-content-area",template:h,data:{icTitle:a,categories:o,date_item_counts:u,date_sales:c,net_sales:g,sales_delta:m,today_sales:l,totalSelected:0,formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}},components:{TableComponent:f,AggChartComponent:p}});d.render("dashboard",{org_name:n,org_title:i,ic_id:e,ic_title:a}),s(a),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ItemCollectionView=g},{"../models/util.js":4,"../templates/item_collection.html.js":29,"./sidebar.js":40}],38:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/org.html.js").orgTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;r({url:a("view",{resource:"o",id:e,root:!0})}).then(function(t){var n=(t.id,t.org_title),i=t.item_collections,r=new Ractive({el:"#main-content-area",template:s,data:{orgName:e,orgTitle:n,item_collections:i}});u.render("org",{org_name:e,org_title:n}),o(n),NProgress.done(),r.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.OrgView=c},{"../models/util.js":4,"../templates/org.html.js":30,"./sidebar.js":40}],39:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./index.js").IndexView,r=t("./org.js").OrgView,a=t("./admin_org_report.js").OrgReportView,o=t("./admin_discount_policy.js").DiscountPolicyView,s=t("./item_collection.js").ItemCollectionView,u=t("./admin_order.js").OrderView,c=t("./admin_report.js").ReportView,l=Backbone.Router.extend({url_root:"/admin/",routes:{"":"index","o/:org_name":"org","o/:org_name/reports":"org_report","o/:org_name/discount_policy":"discount_policy","o/:org_name/discount_policy?:params":"discount_policy","ic/:ic_id":"item_collection","ic/:ic_id/orders":"order","ic/:ic_id/reports":"report"},index:function(){i.render()},org:function(t){r.render({org_name:t})},org_report:function(t){a.render({org_name:t})},discount_policy:function(t){var e=void 0===arguments[1]?{}:arguments[1],n=e.search,i=e.page,r=e.size;o.render({org_name:t,search:n,page:i,size:r})},item_collection:function(t){s.render({ic_id:t})},order:function(t){u.render({ic_id:t})},report:function(t){c.render({ic_id:t})},_extractParameters:function(t,e){var n=t.exec(e).slice(1);if(n[n.length-1]){var i=n[n.length-1].split("&"),r={};i.forEach(function(t){if(t){var e=t.split("=");r[e[0]]=e[1]}}),n[n.length-1]=r}return n}});n.Router=l},{"./admin_discount_policy.js":32,"./admin_order.js":33,"./admin_org_report.js":34,"./admin_report.js":35,"./index.js":36,"./item_collection.js":37,"./org.js":38}],40:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/sidebar.js").SideBarModel,r=t("../templates/sidebar.html.js").SideBarTemplate,a={init:function(t,e){this.on=!0,this.ractive=new Ractive({el:"#sidebar",template:r,data:{sidebarMobileOn:!1,sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1},toggle:function(t){t.original.preventDefault(),this.set("sidebarMobileOn",!this.get("sidebarMobileOn"))},navigate:function(t){t.context.view!==this.get("activeItem")&&(NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url))}})},render:function(t,e){this.on?this.ractive.set({sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1,sidebarMobileOn:!1}):this.init(t,e)},hide:function(){this.on&&this.ractive.set("sidebarHide",!0)}};n.SideBarView=a},{"../models/sidebar.js":3,"../templates/sidebar.html.js":31}]},{},[1]);
\ No newline at end of file
diff --git a/boxoffice/static/js/templates/admin_org_report.html.js b/boxoffice/static/js/templates/admin_org_report.html.js
index 3a6400c6..320510e4 100644
--- a/boxoffice/static/js/templates/admin_org_report.html.js
+++ b/boxoffice/static/js/templates/admin_org_report.html.js
@@ -12,7 +12,15 @@ export const OrgReportTemplate = `
Report type
+ {{#if reportType == "settlements"}}
+
+
+
+ {{/if}}
Download
diff --git a/boxoffice/static/js/views/admin_org_report.js b/boxoffice/static/js/views/admin_org_report.js
index 311d800c..de152036 100644
--- a/boxoffice/static/js/views/admin_org_report.js
+++ b/boxoffice/static/js/views/admin_org_report.js
@@ -7,26 +7,43 @@ export const OrgReportView = {
render: function({org_name}={}) {
fetch({
url: urlFor('index', {resource: 'reports', scope_ns: 'o', scope_id: org_name, root: true})
- }).done(({org_title}) => {
+ }).done(({org_title, siteadmin}) => {
// Initial render
+ let currentDate = new Date();
+ let currentYear = currentDate.getFullYear();
+ // month starts from 0
+ let currentMonth = currentDate.getMonth() + 1;
let reportComponent = new Ractive({
el: '#main-content-area',
template: OrgReportTemplate,
data: {
orgTitle: org_title,
reportType: "invoices",
+ monthYear: `${currentYear}-${currentMonth}`,
+ siteadmin: siteadmin,
reportsUrl: function() {
let reportType = this.get('reportType');
- return urlFor('index', {
+ let url = urlFor('index', {
resource: reportType,
scope_ns: 'o',
scope_id: org_name,
ext: 'csv',
root: true
});
+ if (reportType === 'settlements') {
+ let year, month;
+ [year, month] = this.get('monthYear').split('-');
+ return `${url}?year=${year}&month=${month}`;
+ } else {
+ return url;
+ }
},
reportsFilename: function() {
- return org_name + '_' + this.get('reportType') + '.csv';
+ if (this.get('reportType') === 'settlements'){
+ return `${org_name}_${this.get('reportType')}_${this.get('monthYear')}.csv`;
+ } else {
+ return `${org_name}_${this.get('reportType')}.csv`;
+ }
}
}
});
diff --git a/boxoffice/static/sass/_layout.sass b/boxoffice/static/sass/_layout.sass
index 1e33de05..a6bcc902 100644
--- a/boxoffice/static/sass/_layout.sass
+++ b/boxoffice/static/sass/_layout.sass
@@ -567,3 +567,6 @@ input.icon-placeholder
border-bottom: 2px solid
padding-bottom: 5px
display: inline
+
+p.settlements-month-widget
+ margin-top: 10px
diff --git a/boxoffice/views/admin_report.py b/boxoffice/views/admin_report.py
index abe30d7c..cad2f5d3 100644
--- a/boxoffice/views/admin_report.py
+++ b/boxoffice/views/admin_report.py
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
-from flask import jsonify
+from flask import jsonify, request, g, abort
from .. import app, lastuser
from coaster.views import load_models, render_with
from baseframe import localize_timezone, get_locale
from boxoffice.models import Organization, ItemCollection, LineItem, INVOICE_STATUS
-from boxoffice.views.utils import check_api_access, csv_response
+from boxoffice.views.utils import check_api_access, csv_response, api_error
from babel.dates import format_datetime
-from datetime import datetime
+from datetime import datetime, date
+from ..extapi.razorpay import get_settled_transactions
def jsonify_report(data_dict):
@@ -28,7 +29,7 @@ def admin_report(item_collection):
def jsonify_org_report(data_dict):
- return jsonify(org_title=data_dict['organization'].title)
+ return jsonify(org_title=data_dict['organization'].title, siteadmin=data_dict['siteadmin'])
@app.route('/admin/o//reports')
@@ -38,7 +39,7 @@ def jsonify_org_report(data_dict):
(Organization, {'name': 'org_name'}, 'organization'),
permission='org_admin')
def admin_org_report(organization):
- return dict(organization=organization)
+ return dict(organization=organization, siteadmin=lastuser.has_permission('siteadmin'))
@app.route('/admin/ic//tickets.csv')
@@ -169,3 +170,20 @@ def row_handler(row):
return dict_row
return csv_response(headers, rows, row_type='dict', row_handler=row_handler)
+
+
+@app.route('/admin/o//settlements.csv')
+@lastuser.requires_permission('siteadmin')
+@load_models(
+ (Organization, {'name': 'org_name'}, 'organization'))
+def settled_transactions(organization):
+ year = int(request.args.get('year'))
+ month = int(request.args.get('month'))
+ try:
+ date(year, month, 1)
+ except (ValueError, TypeError):
+ return api_error(message='Invalid year/month',
+ status_code=403,
+ errors=['invalid_date'])
+ headers, rows = get_settled_transactions({'year': year, 'month': month}, g.user.timezone)
+ return csv_response(headers, rows, row_type='dict')
diff --git a/boxoffice/views/order.py b/boxoffice/views/order.py
index b8785ba2..f4eb5788 100644
--- a/boxoffice/views/order.py
+++ b/boxoffice/views/order.py
@@ -445,7 +445,7 @@ def regenerate_line_item(order, original_line_item, updated_line_item_tup, line_
else:
coupon = None
- return LineItem(order=order, item=item, discount_policy=policy,
+ return LineItem(order=order, item=item, discount_policy=policy, previous=original_line_item,
status=LINE_ITEM_STATUS.CONFIRMED,
line_item_seq=line_item_seq,
discount_coupon=coupon,
@@ -507,8 +507,9 @@ def process_line_item_cancellation(line_item):
payment = OnlinePayment.query.filter_by(order=line_item.order, pg_payment_status=RAZORPAY_PAYMENT_STATUS.CAPTURED).one()
rp_resp = razorpay.refund_payment(payment.pg_paymentid, refund_amount)
if rp_resp.status_code == 200:
+ rp_refund = rp_resp.json()
db.session.add(PaymentTransaction(order=order, transaction_type=TRANSACTION_TYPE.REFUND,
- online_payment=payment, amount=refund_amount, currency=CURRENCY.INR, refunded_at=func.utcnow(),
+ pg_refundid=rp_refund['id'], online_payment=payment, amount=refund_amount, currency=CURRENCY.INR, refunded_at=func.utcnow(),
refund_description='Refund: {line_item_title}'.format(line_item_title=line_item.item.title)))
else:
raise PaymentGatewayError("Cancellation failed for order - {order} with the following details - {msg}".format(order=order.id,
@@ -557,8 +558,9 @@ def process_partial_refund_for_order(order, form_dict):
pg_payment_status=RAZORPAY_PAYMENT_STATUS.CAPTURED).one()
rp_resp = razorpay.refund_payment(payment.pg_paymentid, requested_refund_amount)
if rp_resp.status_code == 200:
+ rp_refund = rp_resp.json()
transaction = PaymentTransaction(order=order, transaction_type=TRANSACTION_TYPE.REFUND,
- online_payment=payment, currency=CURRENCY.INR,
+ online_payment=payment, currency=CURRENCY.INR, pg_refundid=rp_refund['id'],
refunded_at=func.utcnow())
form.populate_obj(transaction)
db.session.add(transaction)
diff --git a/migrations/versions/171fcb171759_add_previous_to_line_item.py b/migrations/versions/171fcb171759_add_previous_to_line_item.py
new file mode 100644
index 00000000..8b035871
--- /dev/null
+++ b/migrations/versions/171fcb171759_add_previous_to_line_item.py
@@ -0,0 +1,27 @@
+"""add_previous_to_line_item
+
+Revision ID: 171fcb171759
+Revises: 81f30d00706f
+Create Date: 2017-10-24 18:40:39.183620
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '171fcb171759'
+down_revision = '81f30d00706f'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+import sqlalchemy_utils
+
+def upgrade():
+ op.add_column('line_item', sa.Column('previous_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=True))
+ op.create_index(op.f('ix_line_item_previous_id'), 'line_item', ['previous_id'], unique=True)
+ op.create_foreign_key('line_item_id_fkey', 'line_item', 'line_item', ['previous_id'], ['id'])
+
+
+def downgrade():
+ op.drop_constraint('line_item_id_fkey', 'line_item', type_='foreignkey')
+ op.drop_index(op.f('ix_line_item_previous_id'), table_name='line_item')
+ op.drop_column('line_item', 'previous_id')
diff --git a/migrations/versions/66b67130c901_retroactively_migrate_previous_id_for_.py b/migrations/versions/66b67130c901_retroactively_migrate_previous_id_for_.py
new file mode 100644
index 00000000..d2ea7a7b
--- /dev/null
+++ b/migrations/versions/66b67130c901_retroactively_migrate_previous_id_for_.py
@@ -0,0 +1,107 @@
+"""retroactively_migrate_previous_id_for_line_item
+
+Revision ID: 66b67130c901
+Revises: 171fcb171759
+Create Date: 2017-10-26 14:50:18.859247
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '66b67130c901'
+down_revision = '171fcb171759'
+
+from collections import OrderedDict
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+from sqlalchemy.sql import table, column
+import sqlalchemy_utils
+from boxoffice.models.order import ORDER_STATUS
+from boxoffice.models.line_item import LINE_ITEM_STATUS
+
+
+
+def find_nearest_timestamp(lst, timestamp):
+ if not lst:
+ return None
+ nearest_ts = min(lst, key=lambda ts: abs(ts-timestamp).total_seconds())
+ if abs(nearest_ts - timestamp).total_seconds() < 1:
+ return nearest_ts
+
+def set_previous_keys_for_line_items(line_items):
+ timestamped_line_items = OrderedDict()
+
+ # Assemble the `timestamped_line_items` dictionary with the timestamp at which the line items were created
+ # as the key, and the line items that were created at that time as the value (as a list)
+ # Some line items may have been created a few milliseconds later, so the nearest timestamp
+ # with a tolerance level of one second is searched for
+ for line_item in line_items:
+ ts_key = find_nearest_timestamp(timestamped_line_items.keys(), line_item.created_at) or line_item.created_at
+ if not timestamped_line_items.get(ts_key):
+ timestamped_line_items[ts_key] = []
+ timestamped_line_items[ts_key].append({
+ 'id': line_item.id,
+ 'status': line_item.status,
+ 'item_id': line_item.item_id,
+ 'previous_id': None
+ })
+
+ # The previous line item for a line item, is a line item that has an earlier timestamp with a void status
+ # with the same item_id. Find it and set it
+ used_line_item_ids = set()
+ for idx, (timestamp, line_item_dicts) in enumerate(timestamped_line_items.items()[1:]):
+ # 0th timestamps are root line items, so they're skipped since
+ # they don't need their `previous_id` to be updated
+ for li_dict in timestamped_line_items[timestamp]:
+ # timestamped_line_items.keys()[idx] and not timestamped_line_items.keys()[idx-1]
+ # because the timestamped_line_items.items() list is enumerated from index 1
+ previous_li_dict = [previous_li_dict
+ for previous_li_dict in timestamped_line_items[timestamped_line_items.keys()[idx]]
+ if previous_li_dict['item_id'] == li_dict['item_id']
+ and previous_li_dict['id'] not in used_line_item_ids
+ and previous_li_dict['status'] == LINE_ITEM_STATUS.VOID
+ ][0]
+ li_dict['previous_id'] = previous_li_dict['id']
+ used_line_item_ids.add(previous_li_dict['id'])
+
+ return [li_dict for li_dicts in timestamped_line_items.values() for li_dict in li_dicts]
+
+order_table = table('customer_order',
+ column('id', sqlalchemy_utils.types.uuid.UUIDType()),
+ column('status', sa.Integer()))
+
+line_item_table = table('line_item',
+ column('id', sqlalchemy_utils.types.uuid.UUIDType()),
+ column('customer_order_id', sqlalchemy_utils.types.uuid.UUIDType()),
+ column('item_id', sqlalchemy_utils.types.uuid.UUIDType()),
+ column('previous_id', sqlalchemy_utils.types.uuid.UUIDType()),
+ column('status', sa.Integer()),
+ column('created_at', sa.Boolean()))
+
+def upgrade():
+ conn = op.get_bind()
+ orders = conn.execute(sa.select([order_table.c.id]).where(order_table.c.status.in_(ORDER_STATUS.TRANSACTION)).select_from(order_table))
+ for order_id in [order.id for order in orders]:
+ line_items = conn.execute(sa.select([line_item_table.c.id,
+ line_item_table.c.item_id,
+ line_item_table.c.status,
+ line_item_table.c.created_at
+ ]).where(line_item_table.c.customer_order_id == order_id).order_by("created_at").select_from(line_item_table))
+ updated_line_item_dicts = set_previous_keys_for_line_items(line_items)
+ for updated_line_item_dict in updated_line_item_dicts:
+ if updated_line_item_dict['previous_id']:
+ conn.execute(sa.update(line_item_table).where(
+ line_item_table.c.id == updated_line_item_dict['id']
+ ).values(previous_id=updated_line_item_dict['previous_id']))
+
+
+def downgrade():
+ conn = op.get_bind()
+ orders = conn.execute(sa.select([order_table.c.id]).where(order_table.c.status.in_(ORDER_STATUS.TRANSACTION)).select_from(order_table))
+ for order_id in [order.id for order in orders]:
+ line_items = conn.execute(sa.select([line_item_table.c.id]).where(
+ line_item_table.c.customer_order_id == order_id).order_by("created_at").select_from(line_item_table))
+ for line_item in line_items:
+ conn.execute(sa.update(line_item_table).where(
+ line_item_table.c.id == line_item.id
+ ).values(previous_id=None))
diff --git a/migrations/versions/81f30d00706f_add_pg_refundid_to_transaction.py b/migrations/versions/81f30d00706f_add_pg_refundid_to_transaction.py
new file mode 100644
index 00000000..03bd8140
--- /dev/null
+++ b/migrations/versions/81f30d00706f_add_pg_refundid_to_transaction.py
@@ -0,0 +1,26 @@
+"""add_pg_refundid_to_transaction
+
+Revision ID: 81f30d00706f
+Revises: 1a22f5035244
+Create Date: 2017-10-19 03:39:48.608087
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '81f30d00706f'
+down_revision = '1a22f5035244'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+def upgrade():
+ op.add_column('payment_transaction', sa.Column('pg_refundid', sa.Unicode(length=80), nullable=True))
+ op.create_index(op.f('ix_online_payment_pg_paymentid'), 'online_payment', ['pg_paymentid'], unique=True)
+ op.create_index(op.f('ix_payment_transaction_pg_refundid'), 'payment_transaction', ['pg_refundid'], unique=True)
+
+
+def downgrade():
+ op.drop_index(op.f('ix_payment_transaction_pg_refundid'), table_name='payment_transaction')
+ op.drop_index(op.f('ix_online_payment_pg_paymentid'), table_name='online_payment')
+ op.drop_column('payment_transaction', 'pg_refundid')