Skip to content

Instantly share code, notes, and snippets.

@shahariaazam
Created April 8, 2015 11:29
Show Gist options
  • Select an option

  • Save shahariaazam/b5f00cb99788299900b3 to your computer and use it in GitHub Desktop.

Select an option

Save shahariaazam/b5f00cb99788299900b3 to your computer and use it in GitHub Desktop.
<?php
$erp = new Erp();
$getPartnersInvoice = $erp->search('account.invoice', array(array('partner_id', '=', 57), array('state', '=', 'open')));
$getPartnersInvoiceDetails = $erp->read('account.invoice', array($getPartnersInvoice));
//var_dump($getPartnersInvoiceDetails); die();
$dataVoucher = array(
'journal_id' => (int)$getPartnersInvoiceDetails[0]['journal_id']['data']['value'][0]['int'],
'account_id' => (int)$getPartnersInvoiceDetails[0]['account_id']['data']['value'][0]['int'],
'period_id' => (int)$getPartnersInvoiceDetails[0]['period_id']['data']['value'][0]['int'],
'move_id' => (int)$getPartnersInvoiceDetails[0]['move_id']['data']['value'][0]['int'],
'type' => 'receipt',
'partner_id' => 57,
'amount' => floatval($getPartnersInvoiceDetails[0]['amount_total']),
'reference' => 'TESTINVOICEPAY01',
'company_id' => 1
);
var_dump('Voucher Created');
var_dump($dataVoucher);
//var_dump($erp->create('account.voucher', $dataVoucher)); //117
$voucherLineData = array(
'partner_id' => 57,
'voucher_id' => 117,
'account_id' => 8,
'move_line_id' => 233,
'amount' => 21,
'type' => 'cr',
'name' => str_replace('/', '', $getPartnersInvoiceDetails[0]['number'])
);
try{
var_dump($erp->execute('account.voucher','proforma_voucher', $erp->create('account.voucher.line', $voucherLineData)));
die();
}catch(Exception $e){
var_dump($e->getMessage());
}
die();
var_dump($getPartnersInvoiceDetails); die();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment