فهرست منبع

Add VAT number field to document table

Alan Lam 3 سال پیش
والد
کامیت
5e63d5896d

+ 1 - 0
controllers/document.php

@@ -234,6 +234,7 @@ $controller = new class($document_type, $document_number) {
 		if($document->isSaleOrder()) {
 			$document->invoice_status = $this->request->int("invoice_status");
 			$document->terms = $this->request->string("terms");
+			$document->vat_number = $this->request->string("vat_number");
 			$document->currency = $this->request->string("currency");
 			$document->tax_rate = $this->request->decimal("tax_rate", 2);
 			$document->dts_finalised = $this->request->dateTime("dts_finalised", "Y-m-d\TH:i", $this->user->getTimezone());

+ 12 - 0
db/migrations/20221224150239_add_vat_number_field_to_document_table.php

@@ -0,0 +1,12 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class AddVatNumberFieldToDocumentTable extends AbstractMigration {
+	public function change(): void {
+		$this->table("document")
+			->addColumn("vat_number", "string", ["limit" => 32, "null" => true, "after" => "terms"])
+			->update();
+	}
+}

+ 2 - 1
engine/Document.php

@@ -31,6 +31,7 @@ use RuntimeException;
  * @property string $date
  * @property string $po_number Used for invoices
  * @property string $terms Used for invoices
+ * @property string $vat_number Used for commercial invoices
  * @property string $delivery_company
  * @property string $tracking_number
  * @property string $delivery_cost
@@ -51,7 +52,7 @@ class Document extends Model {
 		"invoice_status", "aru_status",
 		"currency", "tax_rate",
 		"billing_address", "delivery_address",
-		"number", "date", "po_number", "terms",
+		"number", "date", "po_number", "terms", "vat_number",
 		"delivery_company", "tracking_number", "delivery_cost",
 		"notes",
 		"contact_name", "contact_phone", "contact_email",

+ 8 - 0
views/document.php

@@ -193,6 +193,14 @@ $location = $document->getLocation();
 								<input type="text" class="form-control" name="terms" id="terms" placeholder="<?=htmlspecialchars(__("Type terms"))?>" value="<?=htmlspecialchars($document->terms)?>" />
 							</div>
 						</div>
+						<div class="col-sm-6">
+							<div class="mb-3">
+								<label for="vat-number" class="form-label">
+									<?=htmlspecialchars(__("VAT No."))?>
+								</label>
+								<input type="text" class="form-control" name="vat_number" id="vat-number" placeholder="<?=htmlspecialchars(__("Type VAT no."))?>" value="<?=htmlspecialchars($document->vat_number)?>" maxlength="32" />
+							</div>
+						</div>
 						<?php
 					}
 					?>

+ 1 - 1
views/document_pdf.php

@@ -235,7 +235,7 @@ $is_part_of_aru = $document->isPartOfAru();
 						$render_card("Currency", $document->currency);
 
 						if($company && $is_commercial) {
-							$render_card("VAT No.", $company->vat_number);
+							$render_card("VAT No.", $document->vat_number);
 						}
 					}