1 package SL::Controller::SalesPurchase;
 
   4 use parent qw(SL::Controller::Base);
 
   6 use SL::DB::PurchaseInvoice;
 
  10 sub action_check_duplicate_invnumber {
 
  13   croak("no invnumber") unless $::form->{invnumber};
 
  14   croak("no vendor")    unless $::form->{vendor_id};
 
  16   my $exists_ap = SL::DB::Manager::PurchaseInvoice->find_by(
 
  17                    invnumber => $::form->{invnumber},
 
  18                    vendor_id => $::form->{vendor_id},
 
  20   # we are modifying a existing daily booking - allow this if
 
  21   # booking conditions are not super strict
 
  22   undef $exists_ap if ($::instance_conf->get_ap_changeable != 0
 
  23                     && $exists_ap->gldate == DateTime->today_local);
 
  26   $_[0]->render(\ !!$exists_ap, { type => 'text' });
 
  37 SL::Controller::SalesPurchase - Controller for JS driven actions
 
  41 Generic Controller Class for validation function
 
  47 =item C<action_check_duplicate_invnumber>
 
  49 Needs C<form.invnumber> and C<form.vendor_id>
 
  51 Returns true if a credit record with this invnumber for this vendor
 
  58       data: { action: 'SalesPurchase/check_duplicate_invnumber',
 
  59               vendor_id    : $('#vendor_id').val(),
 
  60               invnumber    : $('#invnumber').val()
 
  65       success: function(val) {
 
  66         exists_invnumber = val;