Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / saCreditNote / saCreditNote.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x99e9=['SACreditNote','models','get','format','YYYY','has','SACreditNoteNumber','findOne','transaction','then','create','TCL:\x20error','util','../../config/logger','api','moment','request-promise','path','rimraf','./saCreditNote.attributes','define'];(function(_0x2ebbff,_0x541581){var _0x1ed41d=function(_0xa231e0){while(--_0xa231e0){_0x2ebbff['push'](_0x2ebbff['shift']());}};_0x1ed41d(++_0x541581);}(_0x99e9,0xb4));var _0x999e=function(_0x39c12e,_0x585534){_0x39c12e=_0x39c12e-0x0;var _0x58dbf4=_0x99e9[_0x39c12e];return _0x58dbf4;};'use strict';var _=require('lodash');var util=require(_0x999e('0x0'));var logger=require(_0x999e('0x1'))(_0x999e('0x2'));var moment=require(_0x999e('0x3'));var BPromise=require('bluebird');var rp=require(_0x999e('0x4'));var fs=require('fs');var path=require(_0x999e('0x5'));var rimraf=require(_0x999e('0x6'));var config=require('../../config/environment');var attributes=require(_0x999e('0x7'));module['exports']=function(_0x25421f,_0x1bda0a){return _0x25421f[_0x999e('0x8')](_0x999e('0x9'),attributes,{'tableName':'sa_creditNotes','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x46aeae,_0x38a692,_0x343a12){var _0x46f780=_0x25421f[_0x999e('0xa')];var _0x175042=_0x46aeae[_0x999e('0xb')]({'plain':!![]});var _0x180846=0x1;var _0x3cb1c2=parseInt(moment()[_0x999e('0xc')](_0x999e('0xd')));try{if(_[_0x999e('0xe')](_0x175042,'id')){return _0x46f780[_0x999e('0xf')][_0x999e('0x10')]({'where':{'year':_0x3cb1c2},'raw':!![],'logging':!![],'transaction':_0x38a692[_0x999e('0x11')]})[_0x999e('0x12')](function(_0x26b55a){if(_0x26b55a){_0x180846=_0x26b55a['number']+0x1;return _0x46f780[_0x999e('0xf')]['update']({'number':_0x180846},{'where':{'id':_0x26b55a['id']},'transaction':_0x38a692[_0x999e('0x11')],'logging':!![]});}return _0x46f780[_0x999e('0xf')][_0x999e('0x13')]({'year':_0x3cb1c2,'number':_0x180846},{'logging':!![],'transaction':_0x38a692['transaction']});})[_0x999e('0x12')](function(){_0x175042['number']=_0x180846;})[_0x999e('0x12')](function(){_0x343a12();});}}catch(_0x539598){console['log'](_0x999e('0x14'),_0x539598);_0x343a12();}}}});};