GithubHelp home page GithubHelp logo

ultrasonicsoft / ngx-swiss-five-rappen-chf-pipe Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 242 KB

5 Rappen CHF rounding + Rounding to nearest 5 cents + Swiss Franc + Angular Pipe

Home Page: https://balramchavan.medium.com/5-rappen-chf-rounding-rounding-to-nearest-5-cents-swiss-franc-angular-pipe-34f8524bd04

TypeScript 30.49% HTML 67.54% SCSS 1.97%
npm package angular chf conversation pipe swiss rappen

ngx-swiss-five-rappen-chf-pipe's Introduction

5 Rappen rounding - Swiss CHF - Angular Pipe - NgxSwissFiveRappenChfPipe

CHF is the ISO code of the currency of Switzerland and Liechtenstein. The smaller denomination, a hundredth of a franc, is a Rappen (Rp.) in German, centime(c.) in French, centesimo (ct.) in Italian. The 1 rappen coins were officially fully withdrawn from circulation and declared to be no longer legal tender as of 1 January 2007. The lowest unit is 5 cents (0,05).

Rules

Original amount Rounded to Rounding
x,x1 CHF x,x0 CHF -x,x1 CHF
x,x2 CHF x,x0 CHF -x,x2 CHF
x,x3 CHF x,x5 CHF +x,x2 CHF
x,x4 CHF x,x5 CHF +x,x1 CHF
x,x6 CHF x,x5 CHF -x,x1 CHF
x,x7 CHF x,x5 CHF -x,x2 CHF
x,x8 CHF x,x+10 CHF +x,x2 CHF
x,x9 CHF x,x+10 CHF +x,x1 CHF

Examples

Values between CHF 0,975 and CHF 1,024 will be rounded to CHF 1,00

Values between CHF 1,025 and CHF 1,074 will be rounded to CHF 1,05

Values between CHF 1,075 and CHF 1,124 will be rounded to CHF 1,10

Installation

NPM package is published at https://www.npmjs.com/package/ngx-swiss-five-rappen-chf-pipe

Run npm install --save ngx-swiss-five-rappen-chf-pipe to install package.

HTML Usage

You can apply this pipe in HTML by using pipe operator "|".

<h2 class="top-spacer">Usage</h2>
  <div class="top-spacer">
    <input type="number" [(ngModel)]="inputValue">
    <h3>Output: {{ inputValue | ngxSwissFiveRappenChf }} </h3>
  </div>

Component Usage

You can call transform() method in your component TypeScript file to convert number.

inputValue = 2.034;
  outputValue!: number;

  ngOnInit() {
    const pipe = new NgxSwissFiveRappenChfPipe();
    this.outputValue = pipe.transform(this.inputValue);
    console.debug('🔥 output', this.outputValue);
  }

ngx-swiss-five-rappen-chf-pipe's People

Contributors

ultrasonicsoft avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.