@lynsoluciones/medusa-docs
Version:
Medusa plugins to generate docs
56 lines (55 loc) • 1.76 kB
JavaScript
;
/*
*
*
* MIT License
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.POST = exports.GET = void 0;
const GET = async (req, res) => {
const documentInvoiceSettingsService = req.scope.resolve('documentInvoiceSettingsService');
try {
const lastDocumentInvoiceSettings = await documentInvoiceSettingsService.getDocumentInvoiceSettings();
res.status(200).json({
settings: lastDocumentInvoiceSettings
});
}
catch (e) {
res.status(400).json({
message: e.message
});
}
};
exports.GET = GET;
const POST = async (req, res) => {
const documentInvoiceSettingsService = req.scope.resolve('documentInvoiceSettingsService');
const body = req.body;
const formatNumber = body.formatNumber;
const forcedNumber = body.forcedNumber;
const invoiceTemplate = body.template;
try {
const newSettings = await documentInvoiceSettingsService.updateSettings(formatNumber, forcedNumber, invoiceTemplate);
if (newSettings !== undefined) {
res.status(201).json({
settings: newSettings
});
}
else {
res.status(400).json({
message: 'Cant update invoice settings'
});
}
}
catch (e) {
res.status(400).json({
message: e.message
});
}
};
exports.POST = POST;