##= require_self
##= require ./Payment
class Skr.Screens.Invoice extends Skr.Screens.Base
syncOptions:
with: [ 'with_details' ]
include: [ 'sales_order', 'billing_address', 'shipping_address', 'lines' ]
dataObjects:
invoice: ->
@loadOrCreateModel({
syncOptions: @syncOptions, klass: Skr.Models.Invoice,
prop: 'invoice', attribute: 'visible_id'
})
getInitialState: ->
commands: new Skr.Screens.Commands(this, modelName: 'invoice', print: true)
setSalesOrder: (so) -> @invoice.setFromSalesOrder(so)
onPayment: -> @invoice.save()
getPayment: ->
@context.viewport.displayModal
title: "Accept Payment", autoHide: true, size: 'sm', onOk: @onPayment,
body: =>
PaymentButton: ->
return null if @invoice.isNew() or @invoice.isPaidInFull()
Payment
shouldSaveLinesImmediately: ->
not @invoice.isNew()
render: ->
<@PaymentButton />