Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
It's possible to modifiy invoice creation workflow to add a webservice calling?
11-17-2018, 02:31 AM,
#1
It's possible to modifiy invoice creation workflow to add a webservice calling?
Hi everyone,
I’m looking into weberp but in my country (Argentina) we can’t make invoices without a government confirmation via API webservice so I’m looking if it’s possible to add that function during an invoice creation.

I need to add this code (it’s an example) so when I push the “creation invoice button”, the weberp prepares all the invoice data and before printing it to the invoice executes this code to get the confirmation code (cae) and then add that info to the invoice template.

I’ve been looking some of the code, but I couldn’t find which files creates the invoices, and how they work to see is it’s even possible to modify that workflow to add those intermediate steps.

This is the code. I need to fill the array with the data (which the weberp should give me) and then include the $res data to the weberp for the invoice

PHP Code:
include 'afip_src/Afip.php'

$cuitEmisor 20111111112;
$tipoComprobante 6;
$puntoVenta 1;
$last_voucher $afip->ElectronicBilling->GetLastVoucher(1,6//Devuelve el número del último comprobante creado para el punto de venta 1 y el tipo de comprobante 6 (Factura B)

$data = array(
    
'CantReg'     => 1,  // Amount of invoices
    
'PtoVta'     => 1,  // Sales point
    
'CbteTipo'     => $tipoComprobante,  // invoice type
    
'Concepto'     => $puntoVenta,  // Type of invoice
    
'DocTipo'     => 99// client ID number
    
'DocNro'     => 0,  // Client ID type
    
'CbteDesde'     => ($last_voucher+1),  // 
    
'CbteHasta'     => ($last_voucher+1),  // 
    
'CbteFch'     => intval(date('Ymd')), // 
    
'ImpTotal'     => 121// Total amount
    
'ImpTotConc'     => 0,   // Total amount which taxes don't apply
    
'ImpNeto'     => 100// Total amount without taxes
    
'ImpOpEx'     => 0,   // total amount which don't pay taxes
    
'ImpIVA'     => 21,  //Total IVA taxes amount (always 21%)
    
'ImpTrib'     => 0,   //Total amount from othes taxes
    
'MonId'     => 'PES'//Currency type (ars, usd, etc)
    
'MonCotiz'     => 1,     // Always 1
    
'Iva'         => array( // (Opcional) Alícuotas asociadas al comprobante
        
array(
            
'Id'         => 5// IVA Tax type (5 for 21%)
            
'BaseImp'     => 100// Total amount which pays IVA tax
            
'Importe'     => 21 // Total IVA tax amount
        
)
    ), 
);

$afip = new Afip(array('CUIT' => $cuitEmisor));

$res $afip->ElectronicBilling->CreateVoucher($data);

$res['CAE']; //Confirmation ID number from goverment
$res['CAEFchVto']; //Confirmation ID number expiricity date (yyyy-mm-dd)
$res['barcode']=generadorCodigoBarrasCAE($cuitEmisor,$tipoComprobante,$puntoVenta,$res['CAE'],$res['CAEFchVto']); 

Could you please help me to know which files I should look or edit to add the code, and how can I get the data to fill the array.

Or at least know if its possible to do this?
Or I can’t modify weberp this way and it would be better to just create normal invoices and then, manually (or by other software), edit the pdfs to add the goverment codes?
Reply
11-17-2018, 12:37 PM, (This post was last modified: 11-18-2018, 06:13 AM by TurboPT.)
#2
RE: It's possible to modifiy invoice creation workflow to add a webservice calling?
We have 2 files that create invoices (though one day we'll hopefully merge them into one file -- the only difference is landscape vs portrait)

Which one is used depends upon the setting to Invoice Orientation: found in Main Menu => Setup => System Parameters (1st column)

Then at the Main Menu => Receivables => Print Invoices or Credit Notes (2nd column) is the link to the associated file based on the orientation setting.

So the 2 files are:
PrintCustTrans.php (landscape)
PrintCustTransPortrait.php

Each of those files have the code to generate the PDF after retrieving the invoice details. (look to variable $pdf and its use)

Hopefully that can be a starting point? Feel free to ask other questions if needed. I might not have all the answers, but others here may join the discussion and have other ideas/opinions

I would say that what you want to add is "doable", and perhaps there can be a way to abstract the new code after more of an implementation is known.
Reply
11-22-2018, 04:03 AM,
#3
RE: It's possible to modifiy invoice creation workflow to add a webservice calling?
Thanks TurboPT, i'm looking into those files. It's quite hard to understand how everything works in there (i never used objects before).

One question, from the DB when the file retrieves data for the invoice, where can i get values like "client document id", "invoice type","total amount",etc? I saw some which gets the adresses (3 or 4 adresses actually but don't know which one is the client one)

Thanks again and I think i may came back with some questions soon
Reply
11-22-2018, 01:17 PM, (This post was last modified: 11-22-2018, 02:08 PM by TurboPT.)
#4
RE: It's possible to modifiy invoice creation workflow to add a webservice calling?
The only objects in that file are $pdf and $mail, everything else is procedural.

Also, it might help to look for this condition in the file (in a few, if not more places) that handle the invoice processing:
PHP Code:
if ($InvOrCredit=='Invoice') { 

  1. The client document id, if we're talking about the same, is passed by GET or POST to the script as FromTransNo. (Search the codebase for one of the files to see the handling)
  2. The invoice type (InvOrCredit) is also passed to the script by GET or POST.
  3. The total amount is the calculation to $DisplayTotal.



Reply
11-22-2018, 10:07 PM,
#5
RE: It's possible to modifiy invoice creation workflow to add a webservice calling?
I suggest you contact Phil Daintree and see if he can give you a quote to get it done: http://www.logicworks.co.nz
https://www.linkedin.com/in/eclipsepaulbecker
Reply
11-27-2018, 09:32 PM,
#6
RE: It's possible to modifiy invoice creation workflow to add a webservice calling?
This is becoming more common, I know there are proposals to implement similar things in several African countries, so a generalised solution to this would be good.

Tim
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)