Exemple #1
0
 /**
  * @param  Invoice $invoice
  * @return string
  */
 protected function getIssueDateAddition(Invoice $invoice)
 {
     switch ($invoice->getStatus()) {
         case Invoice::STATUS_DRAFT:
         case Invoice::STATUS_SENT:
             if ($invoice->getDueDate() === null) {
                 return 'No due date';
             }
             $dueTime = $invoice->getDueDate()->diff($invoice->getIssueDate())->days;
             return sprintf('Due in %d %s', $dueTime, $dueTime === 1 ? 'day' : 'days');
         case Invoice::STATUS_LATE:
             $lateTime = $invoice->getDueDate()->diff($invoice->getIssueDate())->days;
             return sprintf('%d %s late', $lateTime, $lateTime === 1 ? 'day' : 'days');
         case Invoice::STATUS_PAID:
             $payTime = $invoice->getPayDate()->diff($invoice->getIssueDate())->days;
             return sprintf('Paid in %d %s', $payTime, $payTime === 1 ? 'day' : 'days');
     }
     throw new RuntimeException(sprintf('Invalid invoice status "%s"', $invoice->getStatus()));
 }
Exemple #2
0
 public function generate(Invoice $invoice, $incrementer)
 {
     $issueDate = $invoice->getIssueDate();
     return sprintf($this->invoiceNumberFormat, $incrementer, $issueDate->format('Y'), $issueDate->format('m'), $issueDate->format('d'));
 }
Exemple #3
0
 /**
  * @param XMLWriter $xmlWriter
  * @param Invoice   $invoice
  */
 protected function addGenericData(XMLWriter $xmlWriter, Invoice $invoice)
 {
     $xmlWriter->writeElement('address', implode("\n", $this->addressService->formatAddress($invoice->getClient()->getAddress())));
     $xmlWriter->writeElement('invoice-id', $invoice->getInvoiceNumber());
     $xmlWriter->writeElement('issue-date', $this->dateFormatter->format($invoice->getIssueDate()));
     if ($invoice->getDueDate() !== null) {
         $xmlWriter->writeElement('due-date', $this->dateFormatter->format($invoice->getDueDate()));
     }
 }