1 namespace('kivi.AP', function(ns){
4 ns.check_fields_before_posting = function() {
7 // if the element transdate exists, we have a AP form otherwise we have to check the invoice form
8 var invoice_date = ($('#transdate').length === 0) ? $('#transdate').val() : $('#invdate').val();
9 if (invoice_date === '')
10 errors.push(kivi.t8('Invoice Date missing!'));
12 if ($('#duedate').val() === '')
13 errors.push(kivi.t8('Due Date missing!'));
15 if ($('#invnumber').val() === '')
16 errors.push(kivi.t8('Invoice Number missing!'));
18 if ($('#vendor_id').val() === '')
19 errors.push(kivi.t8('Vendor missing!'));
21 if (errors.length === 0)
24 alert(errors.join(' '));
29 ns.check_duplicate_invnumber = function() {
30 var exists_invnumber = false;
34 data: { action: 'SalesPurchase/check_duplicate_invnumber',
35 vendor_id : $('#vendor_id').val(),
36 invnumber : $('#invnumber').val()
41 success: function(val) {
42 exists_invnumber = val;
46 if (exists_invnumber == 1) {
47 return confirm(kivi.t8('This vendor has already a booking with this invoice number, do you really want to add the same invoice number again?'));
56 kivi.File.doc_tab_init('ap_tabs', 'ui-tabs-docs', $('#id').val(), 'purchase_invoice');