Invoiceplane: Difference between revisions

Onny (talk | contribs)
Invoice templates: Update example template
Onny (talk | contribs)
Invoice templates: Update example template
 
(3 intermediate revisions by the same user not shown)
Line 26: Line 26:
Invoiceplane will render and export invoices as PDF. You can create your own invoice templates or reuse existing ones. The following example fetches an invoice template and makes it available to your running Invoiceplane instance
Invoiceplane will render and export invoices as PDF. You can create your own invoice templates or reuse existing ones. The following example fetches an invoice template and makes it available to your running Invoiceplane instance


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|||<nowiki>
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, ... }:
let
let


   template-vtdirektmarketing = pkgs.stdenv.mkDerivation {
   invoiceplane-template-vtdirektmarketing = pkgs.stdenv.mkDerivation {
     name = "vtdirektmarketing";
     name = "vtdirektmarketing";
     src = pkgs.fetchgit {
     src = pkgs.fetchFromGitLab {
       url = "https://git.project-insanity.org/onny/invoiceplane-vtdirektmarketing.git";
       domain = "git.project-insanity.org";
       rev = "0a891d836e199cf0f6bd2c4276991665d5d3405e";
      owner = "onny";
       hash = "sha256-GhKd+dviufeGi3ZnyukzvwzVE5BO7jAx1SdsG/ioSeU=";
      repo = "invoiceplane-vtdirektmarketing";
       rev = "a779ea08aaf88d4a4e8afb555a8953f5432f7d49";
       hash = "sha256-H82p46n7OuJA8nzSZWcVRnxfmTrrqaNy+R5qbj0EWtw=";
     };
     };
     makeFlags = [ "DESTDIR=$(out)" ];
     makeFlags = [ "DESTDIR=$(out)" ];
Line 44: Line 46:
   services.invoiceplane.sites."localhost" = {
   services.invoiceplane.sites."localhost" = {
     enable = true;
     enable = true;
     invoiceTemplates = [ template-vtdirektmarketing ];
     invoiceTemplates = [ invoiceplane-template-vtdirektmarketing ];
   };
   };


}
}
</nowiki>}}
</nowiki>|name=|lang=Nix}}


=== Invoice mail delivery ===
=== Invoice mail delivery ===
Line 103: Line 105:


Access your Invoiceplane instance again in your browser and rerun the setup. After upgrading the tables you can login as usual. It is now recommended to change both variables in the config file above back to <code>true</code>.
Access your Invoiceplane instance again in your browser and rerun the setup. After upgrading the tables you can login as usual. It is now recommended to change both variables in the config file above back to <code>true</code>.
== Tips and tricks ==
=== Invoice template development ===
Following <code>flake.nix</code> file helps you spawning a virtual machine running a development environment of Invoiceplane. The local directory <code>/home/user/my_invoiceplane_template</code> containing a modified invoice or quote template will be mounted into the Invoiceplane web app, allowing to change the template and directly render the invoice PDF in the local web server at http://localhost:8080<syntaxhighlight lang="nix">
{
  description = "Invoiceplane invoice template development shell";
  inputs.nixpkgs.url = "nixpkgs/nixos-24.11";
  outputs = { self, nixpkgs, ... }@inputs:
  let
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
    start =
      pkgs.writeShellScriptBin "start" ''
        set -e
        export QEMU_NET_OPTS="hostfwd=tcp::8080-:80"
        ${pkgs.nixos-shell}/bin/nixos-shell --flake .
      '';
  in {
    nixosConfigurations.vm = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs.inputs = inputs;
      pkgs = import nixpkgs {
overlays = [
          (self: super: {
            invoiceplane = super.invoiceplane.overrideAttrs (oldAttrs: rec {
              installPhase = oldAttrs.installPhase + ''
                rm -r $out/application/views/invoice_templates/pdf
                ln -sf /var/lib/invoiceplane/localhost/pdf $out/application/views/invoice_templates/pdf
              '';
            });
          })
        ];
      };
      modules = [
        ({ lib, config, pkgs, ... }: {
  services.invoiceplane.sites."localhost" = {
    enable = true;
    settings.IP_URL = "http://localhost:8080";
  };
          nixos-shell.mounts.extraMounts = {
            "/var/lib/invoiceplane/localhost/pdf" = {
              target = /home/user/my_invoiceplane_template;
              cache = "none";
            };
          };
          system.stateVersion = "24.11";
          services.getty.autologinUser = "root";
        })
      ];
    };
    packages = { inherit start; };
    defaultPackage.x86_64-linux = start;
  };
}
</syntaxhighlight>To run the web server simply execute following command in the same directory as the <code>flake.nix</code> file<syntaxhighlight lang="shell">
nix run
</syntaxhighlight>


== See also ==
== See also ==