update
This commit is contained in:
@@ -15,6 +15,8 @@ class InvoiceData
|
||||
public readonly int $discountAmount,
|
||||
public readonly int $tax,
|
||||
public readonly int $total,
|
||||
/** Số đã thu; hoá đơn WHMCS Paid coi như thu đủ, còn lại lấy phần credit đã áp. */
|
||||
public readonly int $amountPaid,
|
||||
public readonly int $status,
|
||||
public readonly ?string $paymentMethod,
|
||||
public readonly ?string $dueDate,
|
||||
|
||||
@@ -24,6 +24,8 @@ class InvoiceTransformer
|
||||
$legacyId = (int) $row['id'];
|
||||
|
||||
$dueDate = $this->nullableDate($row['duedate'] ?? null);
|
||||
$status = $this->mapStatus($row['status'], $dueDate);
|
||||
$total = (int) round((float) $row['total']);
|
||||
$whmcsOrderId = $this->extractor->orderIdFor($legacyId);
|
||||
|
||||
$rawItems = $this->extractor->items($legacyId);
|
||||
@@ -46,8 +48,11 @@ class InvoiceTransformer
|
||||
subTotal: (int) round((float) $row['subtotal']),
|
||||
discountAmount: $discountAmount,
|
||||
tax: (int) round((float) $row['tax'] + (float) $row['tax2']),
|
||||
total: (int) round((float) $row['total']),
|
||||
status: $this->mapStatus($row['status'], $dueDate),
|
||||
total: $total,
|
||||
// Không có amount_paid thì mọi hoá đơn WHMCS đã thanh toán sẽ hiện "chưa thu"
|
||||
// và outstanding = total trên toàn bộ dữ liệu import.
|
||||
amountPaid: $status === 2 ? $total : (int) round((float) ($row['credit'] ?? 0)),
|
||||
status: $status,
|
||||
paymentMethod: $row['paymentmethod'] ?: null,
|
||||
dueDate: $dueDate,
|
||||
paidAt: $this->nullableDate($row['datepaid'] ?? null),
|
||||
|
||||
@@ -29,6 +29,7 @@ class InvoiceWriter
|
||||
'discount_amount' => $data->discountAmount,
|
||||
'tax' => $data->tax,
|
||||
'total' => $data->total,
|
||||
'amount_paid' => $data->amountPaid,
|
||||
'status' => $data->status,
|
||||
'payment_method' => $data->paymentMethod,
|
||||
'due_date' => $data->dueDate,
|
||||
|
||||
Reference in New Issue
Block a user