Added customer_nr to database and invoice templates.

Used standard DATEV format(10000 – 69999)

Fixes #31
This commit is contained in:
2025-10-21 17:12:50 +02:00
parent 9e877ac722
commit 6fa3459eeb
8 changed files with 35 additions and 4 deletions
+17 -1
View File
@@ -20,4 +20,20 @@ public function index()
return ApiDataTransformer::snakeToCamel($customerArray);
});
}
}
/**
* Generate a random available customer number
*/
public static function generateCustomerNumber()
{
$newNumber = null;
while (!$newNumber) {
// DATEV standard
$randomNumber = rand(10000, 69999);
$customer = Customer::firstWhere('customer_nr', $randomNumber);
if ($customer) {
return $randomNumber;
}
}
}
}
+3 -2
View File
@@ -243,8 +243,9 @@ public function exportXml($id)
// string $name __BT-44, From MINIMUM__ The full name of the buyer
// string|null $id __BT-46, From BASIC WL__ An identifier of the buyer. In many systems, buyer identification is key information. Multiple buyer IDs can be assigned or specified. They can be differentiated by using different identification schemes. If no scheme is given, it should be known to the buyer and buyer, e.g. a previously exchanged, seller-assigned identifier of the buyer
// string|null $description __BT-X-334, From EXTENDED__ Further legal information about the buyer
// TODO: use invoice customerNr
$document->setDocumentBuyer($invoice->customer->company_name, "###KUNDENNUMMER");
if ($invoice->customer->company_name && $invoice->customer->customer_nr) {
$document->setDocumentBuyer($invoice->customer->company_name, $invoice->customer->customer_nr);
}
// Set contact of the buyer party
//
+1
View File
@@ -16,6 +16,7 @@ class Customer extends Model
protected $fillable = [
'type',
'company_name',
'customer_nr',
'vat_id',
'tax_id', // Tax identification number
'global_id', // Global Location Number (GLN) or other identification