my$svg=$dbh->selectrow_array('select data from invoice_templates where type = "svg" and reseller_id=?',undef,$provider_contract->{reseller_core_id});#is_active = 1 and
print"generated data for invoice.id=".$invoice->{id}."; invoice.serial=".$invoice->{serial}.";\n";
$invoice->{data}=$pdf;
#set sent_date to null after each data regeneration
$dbh->do('update invoices set sent_date=?,data=?,amount_net,amount_vat,amount_total where id=?',undef,undef,@$invoice->{qw/data amount_net amount_vat amount_total id/});
$dbh->do('update invoices set sent_date=?,data=?,amount_net=?,amount_vat=?,amount_total=? where id=?',undef,undef,@$invoice{qw/data amount_net amount_vat amount_total id/});
return$invoice;
}
subget_contract_balance{
@ -294,9 +285,9 @@ sub get_contract_balance{
subcreate_invoice{
my($contract_id,$stime,$etime)=@_;
#my $invoice_serial = $dbh->selectrow_array('select max(invoices.serial) from invoices inner join contract_balances on invoices.id=contract_balances.invoice_id where contract_balances.contract_id=?',undef,$contract_id );
my$invoice_serial=$dbh->selectrow_array('select max(invoices.serial) from invoices');
my$invoice_serial=$dbh->selectrow_array('select max(invoices.serial * 1) from invoices');
$invoice_serial+=1;
$dbh->do('insert into invoices(contract_id,period_start,period_end,serial)values(?,?,?,?)',undef,$contract_id,$stime->ymd,$stime->ymd,$invoice_serial);
$dbh->do('insert into invoices(contract_id,period_start,period_end,serial)values(?,?,?,?)',undef,$contract_id,$stime->ymd,$stime->ymd,$invoice_serial);
$dbh->do('update contract_balances set invoice_id = ? where contract_id=? and start=? and end=?',undef,$invoice_id,$contract_id,$stime->datetime,$etime->datetime);
return$dbh->selectrow_hashref('select * from invoices where id=?',undef,$invoice_id);