diff --git a/.gitignore b/.gitignore index 8616860..ab5a31d 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ venv.bak/ __pycache__/ *.py[cod] *$py.class +/coverage/ +.idea/ diff --git a/Donation/index.ts b/Donation/index.ts index 17c73e9..e82aef6 100644 --- a/Donation/index.ts +++ b/Donation/index.ts @@ -1,5 +1,7 @@ import {AzureFunction, Context, HttpRequest} from "@azure/functions" + + // POST http://localhost:7071/api/Donation const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise { context.log('HTTP trigger function processed a request.', req.body); @@ -12,10 +14,12 @@ const httpTrigger: AzureFunction = async function (context: Context, req: HttpRe amount: properties.amount, description: properties.description, isPartialPayment: false, - dueDate: "2022-03-16T09:30:42.577", // TODO - retentionDate: "2022-05-15T08:30:42.577", // TODO + dueDate: addDays(new Date(), Number(process.env['ADD_DUE_DATE_DAYS'])), + retentionDate: addDays(new Date(), Number(process.env['ADD_RETENTION_DATE_DAYS'])), fee: 0, - transfer: [] + transfer: [{ + amount: properties.amount + }] } ] } @@ -29,4 +33,9 @@ const httpTrigger: AzureFunction = async function (context: Context, req: HttpRe }; +function addDays(date: Date, days: number): Date { + date.setDate(date.getDate() + days); + return date; +} + export default httpTrigger; diff --git a/env.example b/env.example deleted file mode 100644 index e69de29..0000000 diff --git a/local.settings.json.example b/local.settings.json.example index 5240831..02d6a4d 100644 --- a/local.settings.json.example +++ b/local.settings.json.example @@ -2,6 +2,8 @@ "IsEncrypted": false, "Values": { "FUNCTIONS_WORKER_RUNTIME": "node", - "AzureWebJobsStorage": "" + "AzureWebJobsStorage": "", + "ADD_DUE_DATE_DAYS": 15, + "ADD_RETENTION_DATE_DAYS": 15 } -} \ No newline at end of file +}