calculationlibrary 0.2.4 copy "calculationlibrary: ^0.2.4" to clipboard
calculationlibrary: ^0.2.4 copied to clipboard

outdated

Financial Calculation Library

example/main.dart

////@nodoc
import '../lib/Calculator.dart';

//  Exemplo de funcionamento
//  argument = {
//    method
//    params
//  }
void main()  {

  List<String> tests = ["addItem", "getAcc","removeItem","addAccountDiscount","addItemDiscount", "addServiceCharge"];
  String aux = "";
  String item = "";
  String acc = "";
  String argument= "";
  for(var method in tests){
    switch(method){
      case "addItem":
        item = '{"idItem": "123", "idEntry": "abc","description": "Product A", "quantity": 1, "value":60.0}';
        acc = '{"sum": 8.55, "amount": 3, "discount": 0.45, "servicecharge": 0.0, "task": [{"name": "addItem", "aparam": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}], "result": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}';

        argument = '{"method": "$method", "item": $item}';
        aux = Calculator.run(argument);

        argument = '{"method": "$method", "item": $item, "acc": $acc}';
        aux = Calculator.run(argument);
        break;
      case "getAcc":
        acc = '{"sum": 8.55, "amount": 3, "discount": 0.45, "servicecharge": 0.0, "task": [{"name": "addItem", "aparam": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}], "result": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}';

        argument = '{"method": "$method", "acc": $acc}';
        aux = Calculator.run(argument);
        break;
      case "removeItem":
        item = '{"idItem": "789", "idEntry": "ghi","description": "Product C", "quantity": 3, "value":3.0, "discount": {"type": 1, "value": 5.0}}';
        acc = '{"sum": 8.55, "amount": 3, "discount": 0.45, "servicecharge": 0.0, "task": [{"name": "addItem", "aparam": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}], "result": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}';

        argument = '{"method": "$method", "acc": $acc, "item": $item}';
        aux = Calculator.run(argument);
        break;
      case "addAccountDiscount":
        var discount = '{"type": 1, "value": 5.0}';
        acc = '{"sum": 8.55, "amount": 3, "discount": 0.45, "servicecharge": 0.0, "task": [{"name": "addItem", "aparam": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}], "result": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}';

        argument = '{"method": "$method", "acc": $acc, "discount": $discount}';
        aux = Calculator.run(argument);
        break;
      case "addItemDiscount":
        item = '{"idItem": "789", "idEntry": "ghi","description": "Product C", "quantity": 3, "value":3.0, "discount": {"type": 1, "value": 5.0}}';
        acc = '{"sum": 8.55, "amount": 3, "discount": 0.45, "servicecharge": 0.0, "task": [{"name": "addItem", "aparam": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}], "result": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}';
        var discount = '{"type": 1, "value": 5.0}';

        var argument = '{"method": "$method", "acc": $acc, "discount": $discount, "item": $item}';
        aux = Calculator.run(argument);
        break;
      case "addServiceCharge":
        var ServiceCharge = '{"type": 1, "value": 5.0}';
        acc = '{"sum": 8.55, "amount": 3, "discount": 0.45, "servicecharge": 0.0, "task": [{"name": "addItem", "aparam": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}], "result": {"idItem": 789, "idEntry": "ghi", "description": "Product C", "quantity": 3, "value": 3.0, "discount": {"type": 1, "value": 5.0}}}';

        argument = '{"method": "$method", "acc": $acc, "serviceCharge": $ServiceCharge}';
        aux = Calculator.run(argument);
        break;
      default:
        aux = "{'error': 'Método não reconhecido'}";
    }
    print(aux);
  }
}
1
likes
0
points
78
downloads

Documentation

Documentation

Publisher

unverified uploader

Weekly Downloads

Financial Calculation Library

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on calculationlibrary