code)?$pdf_currency->code:($company->base_currency??'IDR'); $currencySymbol=isset($pdf_currency->symbol)&&trim((string)$pdf_currency->symbol)!==''?$pdf_currency->symbol:$currencyCode; $groups=array(); $barcodesByLine=array(); foreach($barcodes as$b)$barcodesByLine[(int)$b->invoice_detail_id][]=$b; foreach($lines as$l){ $code=trim((string)($l->item_code??'')); $name=trim((string)$l->nama_item); $key=$l->service_date.'|'.$l->line_type.'|'.$code.'|'.$name.'|'.$l->unit; $label=trim(($code!==''?$code.' - ':'').$name); if(!isset($groups[$key]))$groups[$key]=array('date'=>$l->service_date,'item'=>$label,'qty'=>0,'unit'=>$l->unit,'gross'=>0,'discount'=>0,'tax'=>0,'total'=>0); $groups[$key]['qty']+=(float)$l->qty; $groups[$key]['gross']+=(float)$l->harga*(float)$l->qty; $groups[$key]['discount']+=(float)$l->discount_amount; $groups[$key]['tax']+=(float)$l->tax_amount; $groups[$key]['total']+=(float)$l->subtotal; } function ipMoney($v){return number_format((float)$v,2,',','.');} function ipQty($v){return floor((float)$v)==(float)$v?number_format((float)$v,0,',','.'):rtrim(rtrim(number_format((float)$v,4,',','.'),'0'),',');} $statusKey=$invoice->workflow_status==='posted'?$invoice->status:$invoice->workflow_status; $statusLabels=array('draft'=>'DRAFT','submitted'=>'MENUNGGU PERSETUJUAN','approved'=>'DISETUJUI','posted'=>'POSTED','unpaid'=>'BELUM LUNAS','partial'=>'DIBAYAR SEBAGIAN','paid'=>'LUNAS','cancelled'=>'DIBATALKAN','reversed'=>'DIBALIK'); $statusLabel=$statusLabels[$statusKey]??strtoupper(str_replace('_',' ',$statusKey)); $previousTotal=0;foreach($previous_invoices as$old)$previousTotal+=(float)$old->sisa_piutang;$customerOutstanding=$previousTotal+(float)$invoice->sisa_piutang; ?>
|
=html_escape($company->name??'Perusahaan')?>
=nl2br(html_escape($company->address??'-'))?>
Telp: =html_escape($company->phone??'-')?>
| INVOICE=html_escape($invoice->no_invoice)?> =html_escape($statusLabel)?>=html_escape($invoice->tanggal)?> |
Ditagihkan kepada =html_escape($invoice->customer_name)?>=nl2br(html_escape($invoice->customer_address?:'-'))?> | Informasi Invoice Tanggal Invoice: =html_escape($invoice->tanggal)?>Tanggal Jatuh Tempo: =html_escape($invoice->jatuh_tempo)?> Mata Uang: =html_escape($currencyCode)?> |
| TANGGAL | BARANG / JASA / TABUNGAN | QTY | HARGA | DISKON | PAJAK | SUBTOTAL |
|---|---|---|---|---|---|---|
| =html_escape($g['date'])?> | =html_escape($g['item'])?> | =ipQty($g['qty']).' '.html_escape($g['unit'])?> | =ipMoney($average)?> | =ipMoney($g['discount'])?> | =ipMoney($g['tax'])?> | =ipMoney($g['total'])?> |
| Belum ada item pada invoice ini. | ||||||
| Subtotal bersih | =ipMoney($invoice->subtotal_before_tax)?> |
| Diskon | =ipMoney($invoice->discount_total)?> |
| Pajak | =ipMoney($invoice->tax_total)?> |
| Total Invoice | =html_escape($currencySymbol)?> =ipMoney($invoice->total)?> |
| Sudah dibayar | =ipMoney($invoice->total_bayar)?> |
| Sisa tagihan | =ipMoney($invoice->sisa_piutang)?> |
| INVOICE | TANGGAL | JATUH TEMPO | TOTAL | TERBAYAR | SISA TAGIHAN |
|---|---|---|---|---|---|
| =html_escape($old->no_invoice)?> | =html_escape($old->tanggal)?> | =html_escape($old->jatuh_tempo)?> | =ipMoney($old->total)?> | =ipMoney($old->total_bayar)?> | =ipMoney($old->sisa_piutang)?> |
Surat Jalan: =html_escape(implode(', ',array_map(function($d){return$d->delivery_no;},$deliveries))?:'-')?>
Catatan: =html_escape($invoice->keterangan?:'-')?>
| Dibuat oleh =html_escape($invoice->creator_name?:'-')?> | Disetujui =html_escape($invoice->approver_name?:'-')?> | Diterima Customer |
Rincian seluruh item Invoice =html_escape($invoice->no_invoice)?>.
| TANGGAL | SURAT JALAN | BARANG / JASA / TABUNGAN | BARCODE / SERIAL | QTY | KETERANGAN |
|---|---|---|---|---|---|
| =html_escape($l->service_date)?> | =html_escape($b->delivery_no?:'-')?> | =html_escape($label)?> | =html_escape($b->barcode)?> =html_escape($b->serial_number?:'-')?> | =ipQty($b->qty).' '.html_escape($l->unit)?> | =nl2br(html_escape($note?:'-'))?> |
| =html_escape($l->service_date)?> | - | =html_escape($label)?> | - | =ipQty($l->qty).' '.html_escape($l->unit)?> | =nl2br(html_escape($note?:'-'))?> |
| Belum ada detail item pada invoice ini. | |||||